-rw-r--r-- | kabc/addresseedialog.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/kabc/addresseedialog.cpp b/kabc/addresseedialog.cpp index 3e7b72c..9197850 100644 --- a/kabc/addresseedialog.cpp +++ b/kabc/addresseedialog.cpp | |||
@@ -1,360 +1,363 @@ | |||
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 | ||
39 | using namespace KABC; | 39 | using namespace KABC; |
40 | 40 | ||
41 | AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : | 41 | AddresseeItem::AddresseeItem( QListView *parent, const Addressee &addressee ) : |
42 | QListViewItem( parent ), | 42 | QListViewItem( parent ), |
43 | mAddressee( addressee ) | 43 | mAddressee( addressee ) |
44 | { | 44 | { |
45 | setText( Name,addressee.realName()); | 45 | setText( Name,addressee.realName()); |
46 | setText( Email, addressee.preferredEmail() ); | 46 | setText( Email, addressee.preferredEmail() ); |
47 | setText( Category, addressee.categories().join(";") ); | 47 | setText( Category, addressee.categories().join(";") ); |
48 | } | 48 | } |
49 | 49 | ||
50 | QString AddresseeItem::key( int column, bool ) const | 50 | QString AddresseeItem::key( int column, bool ) const |
51 | { | 51 | { |
52 | 52 | ||
53 | if (column == Email) { | 53 | if (column == Email) { |
54 | QString value = text(Email); | 54 | QString value = text(Email); |
55 | int val = value.findRev("@"); | 55 | int val = value.findRev("@"); |
56 | return value.mid( val) + value.left( val ); | 56 | return value.mid( val) + value.left( val ); |
57 | } | 57 | } |
58 | return text(column).lower(); | 58 | return text(column).lower(); |
59 | } | 59 | } |
60 | 60 | ||
61 | AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : | 61 | AddresseeDialog::AddresseeDialog( QWidget *parent, bool multiple ) : |
62 | KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), | 62 | KDialogBase( KDialogBase::Plain, i18n("Select Addressee"), |
63 | Ok|Cancel, No, parent ), mMultiple( multiple ) | 63 | Ok|Cancel, No, parent ), mMultiple( multiple ) |
64 | { | 64 | { |
65 | qDebug("NEW AddresseeDialog "); | 65 | qDebug("NEW AddresseeDialog "); |
66 | QWidget *topWidget = plainPage(); | 66 | QWidget *topWidget = plainPage(); |
67 | 67 | ||
68 | QBoxLayout *topLayout = new QHBoxLayout( topWidget ); | 68 | QBoxLayout *topLayout = new QHBoxLayout( topWidget ); |
69 | 69 | ||
70 | 70 | ||
71 | KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); | 71 | KDGanttMinimizeSplitter* mMiniSplitter = new KDGanttMinimizeSplitter( Qt::Horizontal, topWidget); |
72 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); | 72 | mMiniSplitter->setMinimizeDirection ( KDGanttMinimizeSplitter::Right ); |
73 | 73 | ||
74 | topLayout->addWidget(mMiniSplitter ); | 74 | topLayout->addWidget(mMiniSplitter ); |
75 | 75 | ||
76 | QWidget *listWidget = new QWidget( mMiniSplitter ); | 76 | QWidget *listWidget = new QWidget( mMiniSplitter ); |
77 | 77 | ||
78 | QBoxLayout *listLayout = new QVBoxLayout (listWidget) ; | 78 | QVBoxLayout *listLayout = new QVBoxLayout (listWidget) ; |
79 | //topLayout->addLayout( listLayout ); | 79 | //topLayout->addLayout( listLayout ); |
80 | 80 | ||
81 | mAddresseeList = new KListView( listWidget ); | 81 | mAddresseeList = new KListView( listWidget ); |
82 | mAddresseeList->addColumn( i18n("Name") ); | 82 | mAddresseeList->addColumn( i18n("Name") ); |
83 | mAddresseeList->addColumn( i18n("Email") ); | 83 | mAddresseeList->addColumn( i18n("Email") ); |
84 | mAddresseeList->addColumn( i18n("Category") ); | 84 | mAddresseeList->addColumn( i18n("Category") ); |
85 | mAddresseeList->setAllColumnsShowFocus( true ); | 85 | mAddresseeList->setAllColumnsShowFocus( true ); |
86 | mAddresseeList->setFullWidth( true ); | 86 | mAddresseeList->setFullWidth( true ); |
87 | listLayout->addWidget( mAddresseeList ); | 87 | listLayout->addWidget( mAddresseeList ); |
88 | connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), | 88 | connect( mAddresseeList, SIGNAL( doubleClicked( QListViewItem * ) ), |
89 | SLOT( slotOk() ) ); | 89 | SLOT( slotOk() ) ); |
90 | 90 | ||
91 | QHBox* searchBox = new QHBox ( listWidget ); | 91 | //QHBox* searchBox = new QHBox ( listWidget ); |
92 | mAddresseeEdit = new QLineEdit( searchBox ); | 92 | mAddresseeEdit = new QLineEdit( listWidget ); |
93 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), | 93 | connect( mAddresseeEdit, SIGNAL( returnPressed() ), |
94 | SLOT( loadAddressBook() ) ); | 94 | SLOT( loadAddressBook() ) ); |
95 | mAddresseeEdit->setFocus(); | 95 | mAddresseeEdit->setFocus(); |
96 | QPushButton *searchButton = new QPushButton( i18n("Search!"), searchBox ); | 96 | QPushButton *searchButton = new QPushButton( i18n("Search!"), listWidget ); |
97 | connect ( searchButton, SIGNAL( clicked() ), SLOT( loadAddressBook() ) ); | 97 | connect ( searchButton, SIGNAL( clicked() ), SLOT( loadAddressBook() ) ); |
98 | 98 | ||
99 | listLayout->addWidget( searchBox ); | 99 | QHBoxLayout *searchLayout = new QHBoxLayout (listLayout) ; |
100 | searchLayout->addWidget( mAddresseeEdit ); | ||
101 | searchLayout->addWidget( searchButton ); | ||
102 | //listLayout->addWidget( searchBox ); | ||
100 | 103 | ||
101 | if ( mMultiple ) { | 104 | if ( mMultiple ) { |
102 | //QBoxLayout *selectedLayout = new QVBoxLayout; | 105 | //QBoxLayout *selectedLayout = new QVBoxLayout; |
103 | //topLayout->addLayout( selectedLayout ); | 106 | //topLayout->addLayout( selectedLayout ); |
104 | //topLayout->setSpacing( spacingHint() ); | 107 | //topLayout->setSpacing( spacingHint() ); |
105 | 108 | ||
106 | QVBox *selectedGroup = new QVBox( mMiniSplitter ); | 109 | QVBox *selectedGroup = new QVBox( mMiniSplitter ); |
107 | new QLabel ( i18n("Selected:"), selectedGroup ); | 110 | new QLabel ( i18n("Selected:"), selectedGroup ); |
108 | //selectedLayout->addWidget( selectedGroup ); | 111 | //selectedLayout->addWidget( selectedGroup ); |
109 | 112 | ||
110 | mSelectedList = new KListView( selectedGroup ); | 113 | mSelectedList = new KListView( selectedGroup ); |
111 | mSelectedList->addColumn( i18n("Name") ); | 114 | mSelectedList->addColumn( i18n("Name") ); |
112 | mSelectedList->addColumn( i18n("Email") ); | 115 | mSelectedList->addColumn( i18n("Email") ); |
113 | mSelectedList->setAllColumnsShowFocus( true ); | 116 | mSelectedList->setAllColumnsShowFocus( true ); |
114 | mSelectedList->setFullWidth( true ); | 117 | mSelectedList->setFullWidth( true ); |
115 | //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), | 118 | //connect( mSelectedList, SIGNAL( doubleClicked( QListViewItem * ) ), |
116 | // SLOT( removeSelected() ) ); | 119 | // SLOT( removeSelected() ) ); |
117 | connect( mSelectedList, SIGNAL( clicked( QListViewItem * ) ), | 120 | connect( mSelectedList, SIGNAL( clicked( QListViewItem * ) ), |
118 | SLOT( removeSelected() ) ); | 121 | SLOT( removeSelected() ) ); |
119 | connect( mSelectedList, SIGNAL( returnPressed( QListViewItem *) ), | 122 | connect( mSelectedList, SIGNAL( returnPressed( QListViewItem *) ), |
120 | SLOT( removeSelected() ) ); | 123 | SLOT( removeSelected() ) ); |
121 | 124 | ||
122 | #if 0 | 125 | #if 0 |
123 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); | 126 | QPushButton *unselectButton = new QPushButton( i18n("Unselect"), selectedGroup ); |
124 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); | 127 | connect ( unselectButton, SIGNAL( clicked() ), SLOT( removeSelected() ) ); |
125 | 128 | ||
126 | #endif | 129 | #endif |
127 | connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), | 130 | connect( mAddresseeList, SIGNAL( clicked( QListViewItem * ) ), |
128 | SLOT( addSelected( QListViewItem * ) ) ); | 131 | SLOT( addSelected( QListViewItem * ) ) ); |
129 | connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), | 132 | connect( mAddresseeList, SIGNAL( returnPressed( QListViewItem * ) ), |
130 | SLOT( selectNextItem( QListViewItem * ) ) ); | 133 | SLOT( selectNextItem( QListViewItem * ) ) ); |
131 | 134 | ||
132 | } | 135 | } |
133 | 136 | ||
134 | mAddressBook = StdAddressBook::self( true ); | 137 | mAddressBook = StdAddressBook::self( true ); |
135 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), | 138 | connect( mAddressBook, SIGNAL( addressBookChanged( AddressBook* ) ), |
136 | SLOT( addressBookChanged() ) ); | 139 | SLOT( addressBookChanged() ) ); |
137 | #if 0 | 140 | #if 0 |
138 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), | 141 | connect( mAddressBook, SIGNAL( loadingFinished( Resource* ) ), |
139 | SLOT( addressBookChanged() ) ); | 142 | SLOT( addressBookChanged() ) ); |
140 | #endif | 143 | #endif |
141 | loadAddressBook(); | 144 | loadAddressBook(); |
142 | QValueList<int> splitterSize; | 145 | QValueList<int> splitterSize; |
143 | splitterSize.append( ( width() / 5 ) * 3 ); | 146 | splitterSize.append( ( width() / 5 ) * 3 ); |
144 | splitterSize.append( ( width() / 5 ) *2 ); | 147 | splitterSize.append( ( width() / 5 ) *2 ); |
145 | mMiniSplitter->setSizes( splitterSize ); | 148 | mMiniSplitter->setSizes( splitterSize ); |
146 | } | 149 | } |
147 | 150 | ||
148 | AddresseeDialog::~AddresseeDialog() | 151 | AddresseeDialog::~AddresseeDialog() |
149 | { | 152 | { |
150 | qDebug("DELETE AddresseeDialog "); | 153 | qDebug("DELETE AddresseeDialog "); |
151 | } | 154 | } |
152 | 155 | ||
153 | void AddresseeDialog::loadAddressBook() | 156 | void AddresseeDialog::loadAddressBook() |
154 | { | 157 | { |
155 | mAddresseeList->clear(); | 158 | mAddresseeList->clear(); |
156 | mItemDict.clear(); | 159 | mItemDict.clear(); |
157 | if ( mAddresseeEdit->text().isEmpty() ) { | 160 | if ( mAddresseeEdit->text().isEmpty() ) { |
158 | AddressBook::Iterator it; | 161 | AddressBook::Iterator it; |
159 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 162 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
160 | 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-") ) |
161 | continue; | 164 | continue; |
162 | new AddresseeItem( mAddresseeList, (*it) ); | 165 | new AddresseeItem( mAddresseeList, (*it) ); |
163 | } | 166 | } |
164 | return; | 167 | return; |
165 | } | 168 | } |
166 | //mAddresseeEdit->completionObject()->clear(); | 169 | //mAddresseeEdit->completionObject()->clear(); |
167 | QRegExp re; | 170 | QRegExp re; |
168 | re.setWildcard(true); // most people understand these better. | 171 | re.setWildcard(true); // most people understand these better. |
169 | re.setCaseSensitive(false); | 172 | re.setCaseSensitive(false); |
170 | re.setPattern( "*"+ mAddresseeEdit->text() + "*"); | 173 | re.setPattern( "*"+ mAddresseeEdit->text() + "*"); |
171 | 174 | ||
172 | AddressBook::Iterator it; | 175 | AddressBook::Iterator it; |
173 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { | 176 | for( it = mAddressBook->begin(); it != mAddressBook->end(); ++it ) { |
174 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) | 177 | if ( (*it).uid().left(2) == "la" && (*it).uid().left(19) == QString("last-syncAddressee-") ) |
175 | continue; | 178 | continue; |
176 | QString name = (*it).realName(); | 179 | QString name = (*it).realName(); |
177 | name += (*it).preferredEmail(); | 180 | name += (*it).preferredEmail(); |
178 | name += (*it).categories().join(";"); | 181 | name += (*it).categories().join(";"); |
179 | #if QT_VERSION >= 0x030000 | 182 | #if QT_VERSION >= 0x030000 |
180 | if (re.search(name) != -1) | 183 | if (re.search(name) != -1) |
181 | #else | 184 | #else |
182 | if (re.match(name) != -1) | 185 | if (re.match(name) != -1) |
183 | #endif | 186 | #endif |
184 | AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); | 187 | AddresseeItem *item = new AddresseeItem( mAddresseeList, (*it) ); |
185 | } | 188 | } |
186 | } | 189 | } |
187 | 190 | ||
188 | void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) | 191 | void AddresseeDialog::addCompletionItem( const QString &str, QListViewItem *item ) |
189 | { | 192 | { |
190 | if ( str.isEmpty() ) return; | 193 | if ( str.isEmpty() ) return; |
191 | 194 | ||
192 | mItemDict.insert( str, item ); | 195 | mItemDict.insert( str, item ); |
193 | //mAddresseeEdit->completionObject()->addItem( str ); | 196 | //mAddresseeEdit->completionObject()->addItem( str ); |
194 | } | 197 | } |
195 | 198 | ||
196 | void AddresseeDialog::selectItem( const QString &str ) | 199 | void AddresseeDialog::selectItem( const QString &str ) |
197 | { | 200 | { |
198 | if ( str.isEmpty() ) return; | 201 | if ( str.isEmpty() ) return; |
199 | 202 | ||
200 | QListViewItem *item = mItemDict.find( str ); | 203 | QListViewItem *item = mItemDict.find( str ); |
201 | if ( item ) { | 204 | if ( item ) { |
202 | mAddresseeList->blockSignals( true ); | 205 | mAddresseeList->blockSignals( true ); |
203 | mAddresseeList->setSelected( item, true ); | 206 | mAddresseeList->setSelected( item, true ); |
204 | mAddresseeList->ensureItemVisible( item ); | 207 | mAddresseeList->ensureItemVisible( item ); |
205 | mAddresseeList->blockSignals( false ); | 208 | mAddresseeList->blockSignals( false ); |
206 | } | 209 | } |
207 | } | 210 | } |
208 | 211 | ||
209 | void AddresseeDialog::updateEdit( QListViewItem *item ) | 212 | void AddresseeDialog::updateEdit( QListViewItem *item ) |
210 | { | 213 | { |
211 | mAddresseeEdit->setText( item->text( 0 ) ); | 214 | mAddresseeEdit->setText( item->text( 0 ) ); |
212 | mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); | 215 | mAddresseeEdit->setSelection( 0, item->text( 0 ).length() ); |
213 | } | 216 | } |
214 | 217 | ||
215 | void AddresseeDialog::selectNextItem( QListViewItem *item ) | 218 | void AddresseeDialog::selectNextItem( QListViewItem *item ) |
216 | { | 219 | { |
217 | addSelected( item ); | 220 | addSelected( item ); |
218 | QListViewItem *next = item->nextSibling(); | 221 | QListViewItem *next = item->nextSibling(); |
219 | if ( next ) { | 222 | if ( next ) { |
220 | next->setSelected( true ); | 223 | next->setSelected( true ); |
221 | item->setSelected( false ); | 224 | item->setSelected( false ); |
222 | mAddresseeList->setCurrentItem( next ); | 225 | mAddresseeList->setCurrentItem( next ); |
223 | } | 226 | } |
224 | } | 227 | } |
225 | void AddresseeDialog::addSelected( QListViewItem *item ) | 228 | void AddresseeDialog::addSelected( QListViewItem *item ) |
226 | { | 229 | { |
227 | AddresseeItem *addrItem = (AddresseeItem *)( item ); | 230 | AddresseeItem *addrItem = (AddresseeItem *)( item ); |
228 | if ( !addrItem ) return; | 231 | if ( !addrItem ) return; |
229 | 232 | ||
230 | Addressee a = addrItem->addressee(); | 233 | Addressee a = addrItem->addressee(); |
231 | 234 | ||
232 | QListViewItem *selectedItem = mSelectedDict.find( a.uid() ); | 235 | QListViewItem *selectedItem = mSelectedDict.find( a.uid() ); |
233 | if ( !selectedItem ) { | 236 | if ( !selectedItem ) { |
234 | selectedItem = new AddresseeItem( mSelectedList, a ); | 237 | selectedItem = new AddresseeItem( mSelectedList, a ); |
235 | mSelectedDict.insert( a.uid(), selectedItem ); | 238 | mSelectedDict.insert( a.uid(), selectedItem ); |
236 | } | 239 | } |
237 | 240 | ||
238 | } | 241 | } |
239 | 242 | ||
240 | void AddresseeDialog::removeSelected() | 243 | void AddresseeDialog::removeSelected() |
241 | { | 244 | { |
242 | QListViewItem *item = mSelectedList->selectedItem(); | 245 | QListViewItem *item = mSelectedList->selectedItem(); |
243 | AddresseeItem *addrItem = (AddresseeItem *)( item ); | 246 | AddresseeItem *addrItem = (AddresseeItem *)( item ); |
244 | if ( !addrItem ) return; | 247 | if ( !addrItem ) return; |
245 | QListViewItem *next = item->nextSibling(); | 248 | QListViewItem *next = item->nextSibling(); |
246 | mSelectedDict.remove( addrItem->addressee().uid() ); | 249 | mSelectedDict.remove( addrItem->addressee().uid() ); |
247 | delete addrItem; | 250 | delete addrItem; |
248 | if ( next ) | 251 | if ( next ) |
249 | next->setSelected( true ); | 252 | next->setSelected( true ); |
250 | } | 253 | } |
251 | 254 | ||
252 | Addressee AddresseeDialog::addressee() | 255 | Addressee AddresseeDialog::addressee() |
253 | { | 256 | { |
254 | AddresseeItem *aItem = 0; | 257 | AddresseeItem *aItem = 0; |
255 | 258 | ||
256 | if ( mMultiple ) | 259 | if ( mMultiple ) |
257 | aItem = (AddresseeItem *)( mSelectedList->firstChild() ); | 260 | aItem = (AddresseeItem *)( mSelectedList->firstChild() ); |
258 | else | 261 | else |
259 | aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); | 262 | aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); |
260 | 263 | ||
261 | if (aItem) return aItem->addressee(); | 264 | if (aItem) return aItem->addressee(); |
262 | return Addressee(); | 265 | return Addressee(); |
263 | } | 266 | } |
264 | 267 | ||
265 | Addressee::List AddresseeDialog::addressees() | 268 | Addressee::List AddresseeDialog::addressees() |
266 | { | 269 | { |
267 | Addressee::List al; | 270 | Addressee::List al; |
268 | AddresseeItem *aItem = 0; | 271 | AddresseeItem *aItem = 0; |
269 | 272 | ||
270 | if ( mMultiple ) { | 273 | if ( mMultiple ) { |
271 | QListViewItem *item = mSelectedList->firstChild(); | 274 | QListViewItem *item = mSelectedList->firstChild(); |
272 | while( item ) { | 275 | while( item ) { |
273 | aItem = (AddresseeItem *)( item ); | 276 | aItem = (AddresseeItem *)( item ); |
274 | if ( aItem ) al.append( aItem->addressee() ); | 277 | if ( aItem ) al.append( aItem->addressee() ); |
275 | item = item->nextSibling(); | 278 | item = item->nextSibling(); |
276 | } | 279 | } |
277 | } | 280 | } |
278 | else | 281 | else |
279 | { | 282 | { |
280 | aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); | 283 | aItem = (AddresseeItem *)( mAddresseeList->selectedItem() ); |
281 | if (aItem) al.append( aItem->addressee() ); | 284 | if (aItem) al.append( aItem->addressee() ); |
282 | } | 285 | } |
283 | 286 | ||
284 | return al; | 287 | return al; |
285 | } | 288 | } |
286 | 289 | ||
287 | Addressee AddresseeDialog::getAddressee( QWidget *parent ) | 290 | Addressee AddresseeDialog::getAddressee( QWidget *parent ) |
288 | { | 291 | { |
289 | AddresseeDialog *dlg = new AddresseeDialog( parent ); | 292 | AddresseeDialog *dlg = new AddresseeDialog( parent ); |
290 | Addressee addressee; | 293 | Addressee addressee; |
291 | #ifdef DESKTOP_VERSION | 294 | #ifdef DESKTOP_VERSION |
292 | static int geoX = 0; | 295 | static int geoX = 0; |
293 | static int geoY = 0; | 296 | static int geoY = 0; |
294 | static int geoW = 0; | 297 | static int geoW = 0; |
295 | static int geoH = 0; | 298 | static int geoH = 0; |
296 | if ( !geoX && ! geoY && !geoW &&!geoH ) { | 299 | if ( !geoX && ! geoY && !geoW &&!geoH ) { |
297 | geoX = dlg->geometry().x(); | 300 | geoX = dlg->geometry().x(); |
298 | geoY = dlg->geometry().y(); | 301 | geoY = dlg->geometry().y(); |
299 | geoW = dlg->width(); | 302 | geoW = dlg->width(); |
300 | geoH = dlg->height(); | 303 | geoH = dlg->height(); |
301 | } else { | 304 | } else { |
302 | dlg->show(); | 305 | dlg->show(); |
303 | dlg->setGeometry(geoX , geoY,geoW , geoH ); | 306 | dlg->setGeometry(geoX , geoY,geoW , geoH ); |
304 | 307 | ||
305 | } | 308 | } |
306 | #endif | 309 | #endif |
307 | int result = dlg->exec(); | 310 | int result = dlg->exec(); |
308 | #ifdef DESKTOP_VERSION | 311 | #ifdef DESKTOP_VERSION |
309 | geoX = dlg->geometry().x(); | 312 | geoX = dlg->geometry().x(); |
310 | geoY = dlg->geometry().y(); | 313 | geoY = dlg->geometry().y(); |
311 | geoW = dlg->width(); | 314 | geoW = dlg->width(); |
312 | geoH = dlg->height(); | 315 | geoH = dlg->height(); |
313 | #endif | 316 | #endif |
314 | if ( result == QDialog::Accepted ) { | 317 | if ( result == QDialog::Accepted ) { |
315 | addressee = dlg->addressee(); | 318 | addressee = dlg->addressee(); |
316 | } | 319 | } |
317 | 320 | ||
318 | delete dlg; | 321 | delete dlg; |
319 | return addressee; | 322 | return addressee; |
320 | } | 323 | } |
321 | 324 | ||
322 | Addressee::List AddresseeDialog::getAddressees( QWidget *parent ) | 325 | Addressee::List AddresseeDialog::getAddressees( QWidget *parent ) |
323 | { | 326 | { |
324 | AddresseeDialog *dlg = new AddresseeDialog( parent, true ); | 327 | AddresseeDialog *dlg = new AddresseeDialog( parent, true ); |
325 | Addressee::List addressees; | 328 | Addressee::List addressees; |
326 | static int geoX = 0; | 329 | static int geoX = 0; |
327 | static int geoY = 0; | 330 | static int geoY = 0; |
328 | static int geoW = 0; | 331 | static int geoW = 0; |
329 | static int geoH = 0; | 332 | static int geoH = 0; |
330 | if ( QApplication::desktop()->width() <= 640 ) | 333 | if ( QApplication::desktop()->width() <= 640 ) |
331 | dlg->showMaximized(); | 334 | dlg->showMaximized(); |
332 | else { | 335 | else { |
333 | if ( !geoX && ! geoY && !geoW &&!geoH ) { | 336 | if ( !geoX && ! geoY && !geoW &&!geoH ) { |
334 | geoX = dlg->geometry().x(); | 337 | geoX = dlg->geometry().x(); |
335 | geoY = dlg->geometry().y(); | 338 | geoY = dlg->geometry().y(); |
336 | geoW = dlg->width(); | 339 | geoW = dlg->width(); |
337 | geoH = dlg->height(); | 340 | geoH = dlg->height(); |
338 | } else { | 341 | } else { |
339 | dlg->show(); | 342 | dlg->show(); |
340 | dlg->setGeometry(geoX , geoY,geoW , geoH ); | 343 | dlg->setGeometry(geoX , geoY,geoW , geoH ); |
341 | 344 | ||
342 | } | 345 | } |
343 | } | 346 | } |
344 | int result = dlg->exec(); | 347 | int result = dlg->exec(); |
345 | geoX = dlg->geometry().x(); | 348 | geoX = dlg->geometry().x(); |
346 | geoY = dlg->geometry().y(); | 349 | geoY = dlg->geometry().y(); |
347 | geoW = dlg->width(); | 350 | geoW = dlg->width(); |
348 | geoH = dlg->height(); | 351 | geoH = dlg->height(); |
349 | if ( result == QDialog::Accepted ) { | 352 | if ( result == QDialog::Accepted ) { |
350 | addressees = dlg->addressees(); | 353 | addressees = dlg->addressees(); |
351 | } | 354 | } |
352 | 355 | ||
353 | delete dlg; | 356 | delete dlg; |
354 | return addressees; | 357 | return addressees; |
355 | } | 358 | } |
356 | 359 | ||
357 | void AddresseeDialog::addressBookChanged() | 360 | void AddresseeDialog::addressBookChanged() |
358 | { | 361 | { |
359 | loadAddressBook(); | 362 | loadAddressBook(); |
360 | } | 363 | } |