-rw-r--r-- | korganizer/koeditordetails.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 2e1ae6e..66f6977 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp | |||
@@ -1,433 +1,439 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
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 thse hope that it will be useful, | 10 | This program is distributed in thse 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 <qtooltip.h> | 24 | #include <qtooltip.h> |
25 | #include <qfiledialog.h> | 25 | #include <qfiledialog.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qvbox.h> | 27 | #include <qvbox.h> |
28 | #include <qbuttongroup.h> | 28 | #include <qbuttongroup.h> |
29 | #include <qvgroupbox.h> | 29 | #include <qvgroupbox.h> |
30 | #include <qwidgetstack.h> | 30 | #include <qwidgetstack.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapp.h> | 32 | #include <qapp.h> |
33 | 33 | ||
34 | #include <klocale.h> | 34 | #include <klocale.h> |
35 | #include <kglobal.h> | 35 | #include <kglobal.h> |
36 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
37 | #include <kstandarddirs.h> | 37 | #include <kstandarddirs.h> |
38 | #include <kmessagebox.h> | 38 | #include <kmessagebox.h> |
39 | #ifndef KORG_NOKABC | 39 | #ifndef KORG_NOKABC |
40 | 40 | ||
41 | #ifdef DESKTOP_VERSION | 41 | #ifdef DESKTOP_VERSION |
42 | #include <kabc/addresseedialog.h> | 42 | #include <kabc/addresseedialog.h> |
43 | #else //DESKTOP_VERSION | 43 | #else //DESKTOP_VERSION |
44 | #include <externalapphandler.h> | 44 | #include <externalapphandler.h> |
45 | #endif //DESKTOP_VERSION | 45 | #endif //DESKTOP_VERSION |
46 | 46 | ||
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <libkcal/incidence.h> | 49 | #include <libkcal/incidence.h> |
50 | 50 | ||
51 | #include "koprefs.h" | 51 | #include "koprefs.h" |
52 | 52 | ||
53 | #include "koeditordetails.h" | 53 | #include "koeditordetails.h" |
54 | 54 | ||
55 | template <> | 55 | template <> |
56 | CustomListViewItem<class Attendee *>::~CustomListViewItem() | 56 | CustomListViewItem<class Attendee *>::~CustomListViewItem() |
57 | { | 57 | { |
58 | delete mData; | 58 | delete mData; |
59 | } | 59 | } |
60 | 60 | ||
61 | template <> | 61 | template <> |
62 | void CustomListViewItem<class Attendee *>::updateItem() | 62 | void CustomListViewItem<class Attendee *>::updateItem() |
63 | { | 63 | { |
64 | setText(0,mData->name()); | 64 | setText(0,mData->name()); |
65 | setText(1,mData->email()); | 65 | setText(1,mData->email()); |
66 | setText(2,mData->roleStr()); | 66 | setText(2,mData->roleStr()); |
67 | setText(3,mData->statusStr()); | 67 | setText(3,mData->statusStr()); |
68 | if (mData->RSVP() && !mData->email().isEmpty()) | 68 | if (mData->RSVP() && !mData->email().isEmpty()) |
69 | setPixmap(4,SmallIcon("mailappt")); | 69 | setPixmap(4,SmallIcon("mailappt")); |
70 | else | 70 | else |
71 | setPixmap(4,SmallIcon("nomailappt")); | 71 | setPixmap(4,SmallIcon("nomailappt")); |
72 | } | 72 | } |
73 | 73 | ||
74 | 74 | ||
75 | KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) | 75 | KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) |
76 | : QWidget( parent, name), mDisableItemUpdate( false ) | 76 | : QWidget( parent, name), mDisableItemUpdate( false ) |
77 | { | 77 | { |
78 | QGridLayout *topLayout = new QGridLayout(this); | 78 | QGridLayout *topLayout = new QGridLayout(this); |
79 | topLayout->setSpacing(spacing); | 79 | topLayout->setSpacing(spacing); |
80 | 80 | ||
81 | QString organizer = KOPrefs::instance()->email(); | 81 | QString organizer = KOPrefs::instance()->email(); |
82 | mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); | 82 | mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); |
83 | 83 | ||
84 | mListView = new KListView(this,"mListView"); | 84 | mListView = new KListView(this,"mListView"); |
85 | mListView->addColumn(i18n("Name"),180); | 85 | mListView->addColumn(i18n("Name"),180); |
86 | mListView->addColumn(i18n("Email"),180); | 86 | mListView->addColumn(i18n("Email"),180); |
87 | mListView->addColumn(i18n("Role"),60); | 87 | mListView->addColumn(i18n("Role"),60); |
88 | mListView->addColumn(i18n("Status"),100); | 88 | mListView->addColumn(i18n("Status"),100); |
89 | mListView->addColumn(i18n("RSVP"),35); | 89 | mListView->addColumn(i18n("RSVP"),35); |
90 | if ( KOPrefs::instance()->mCompactDialogs ) { | 90 | if ( KOPrefs::instance()->mCompactDialogs ) { |
91 | //mListView->setFixedHeight(78); | 91 | //mListView->setFixedHeight(78); |
92 | } | 92 | } |
93 | 93 | ||
94 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), | 94 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), |
95 | SLOT(updateAttendeeInput())); | 95 | SLOT(updateAttendeeInput())); |
96 | 96 | ||
97 | QLabel *attendeeLabel = new QLabel(this); | 97 | QLabel *attendeeLabel = new QLabel(this); |
98 | attendeeLabel->setText(i18n("Name:")); | 98 | attendeeLabel->setText(i18n("Name:")); |
99 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); | 99 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); |
100 | mNameEdit = new QLineEdit(this); | 100 | mNameEdit = new QLineEdit(this); |
101 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), | 101 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), |
102 | SLOT(updateAttendeeItem())); | 102 | SLOT(updateAttendeeItem())); |
103 | 103 | ||
104 | mUidEdit = new QLineEdit(0); | 104 | mUidEdit = new QLineEdit(0); |
105 | mUidEdit->setText(""); | 105 | mUidEdit->setText(""); |
106 | 106 | ||
107 | QLabel *emailLabel = new QLabel(this); | 107 | QLabel *emailLabel = new QLabel(this); |
108 | emailLabel->setText(i18n("Email:")); | 108 | emailLabel->setText(i18n("Email:")); |
109 | mEmailEdit = new QLineEdit(this); | 109 | mEmailEdit = new QLineEdit(this); |
110 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), | 110 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), |
111 | SLOT(updateAttendeeItem())); | 111 | SLOT(updateAttendeeItem())); |
112 | 112 | ||
113 | QLabel *attendeeRoleLabel = new QLabel(this); | 113 | QLabel *attendeeRoleLabel = new QLabel(this); |
114 | attendeeRoleLabel->setText(i18n("Role:")); | 114 | attendeeRoleLabel->setText(i18n("Role:")); |
115 | mRoleCombo = new QComboBox(false,this); | 115 | mRoleCombo = new QComboBox(false,this); |
116 | mRoleCombo->insertStringList(Attendee::roleList()); | 116 | mRoleCombo->insertStringList(Attendee::roleList()); |
117 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 117 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
118 | 118 | ||
119 | QLabel *statusLabel = new QLabel(this); | 119 | QLabel *statusLabel = new QLabel(this); |
120 | statusLabel->setText( i18n("Status:") ); | 120 | statusLabel->setText( i18n("Status:") ); |
121 | 121 | ||
122 | mStatusCombo = new QComboBox(false,this); | 122 | mStatusCombo = new QComboBox(false,this); |
123 | mStatusCombo->insertStringList(Attendee::statusList()); | 123 | mStatusCombo->insertStringList(Attendee::statusList()); |
124 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 124 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
125 | 125 | ||
126 | mRsvpButton = new QCheckBox(this); | 126 | mRsvpButton = new QCheckBox(this); |
127 | mRsvpButton->setText(i18n("Request response")); | 127 | mRsvpButton->setText(i18n("Request response")); |
128 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); | 128 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); |
129 | QWidget *buttonBox = new QWidget(this); | 129 | QWidget *buttonBox = new QWidget(this); |
130 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); | 130 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); |
131 | 131 | ||
132 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); | 132 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); |
133 | buttonLayout->addWidget(newButton); | 133 | buttonLayout->addWidget(newButton); |
134 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); | 134 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); |
135 | 135 | ||
136 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); | 136 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); |
137 | buttonLayout->addWidget(mRemoveButton); | 137 | buttonLayout->addWidget(mRemoveButton); |
138 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); | 138 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); |
139 | 139 | ||
140 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); | 140 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); |
141 | // buttonLayout->addWidget(mAddressBookButton); | 141 | // buttonLayout->addWidget(mAddressBookButton); |
142 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); | 142 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); |
143 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); | 143 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); |
144 | 144 | ||
145 | if (qApp->desktop()->width() < 300 ) { | 145 | if (qApp->desktop()->width() < 300 ) { |
146 | mListView->setFixedHeight(80); | 146 | mListView->setFixedHeight(80); |
147 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); | 147 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); |
148 | topLayout->addMultiCellWidget(mListView,1,1,0,3); | 148 | topLayout->addMultiCellWidget(mListView,1,1,0,3); |
149 | topLayout->addWidget(attendeeLabel,3,0); | 149 | topLayout->addWidget(attendeeLabel,3,0); |
150 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); | 150 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); |
151 | topLayout->addWidget(emailLabel,4,0); | 151 | topLayout->addWidget(emailLabel,4,0); |
152 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); | 152 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); |
153 | topLayout->addWidget(attendeeRoleLabel,5,0); | 153 | topLayout->addWidget(attendeeRoleLabel,5,0); |
154 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 154 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
155 | topLayout->addWidget(statusLabel,6,0); | 155 | topLayout->addWidget(statusLabel,6,0); |
156 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,2); | 156 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,2); |
157 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); | 157 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); |
158 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 158 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
159 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); | 159 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); |
160 | topLayout->setRowStretch(1,2); | 160 | topLayout->setRowStretch(1,2); |
161 | topLayout->setColStretch(0,0); | 161 | topLayout->setColStretch(0,0); |
162 | topLayout->setColStretch(1,2); | 162 | topLayout->setColStretch(1,2); |
163 | topLayout->setColStretch(2,1); | 163 | topLayout->setColStretch(2,1); |
164 | topLayout->setColStretch(3,1); | 164 | topLayout->setColStretch(3,1); |
165 | 165 | ||
166 | } else { | 166 | } else { |
167 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); | 167 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); |
168 | topLayout->addMultiCellWidget(mListView,1,1,0,5); | 168 | topLayout->addMultiCellWidget(mListView,1,1,0,5); |
169 | topLayout->addWidget(attendeeLabel,3,0); | 169 | topLayout->addWidget(attendeeLabel,3,0); |
170 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); | 170 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); |
171 | topLayout->addWidget(emailLabel,4,0); | 171 | topLayout->addWidget(emailLabel,4,0); |
172 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); | 172 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); |
173 | topLayout->addWidget(attendeeRoleLabel,5,0); | 173 | topLayout->addWidget(attendeeRoleLabel,5,0); |
174 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 174 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
175 | topLayout->addWidget(statusLabel,5,3); | 175 | topLayout->addWidget(statusLabel,5,3); |
176 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | 176 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); |
177 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | 177 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); |
178 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 178 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
179 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | 179 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); |
180 | topLayout->setRowStretch(1,5); | 180 | topLayout->setRowStretch(1,5); |
181 | topLayout->setColStretch(0,0); | 181 | topLayout->setColStretch(0,0); |
182 | } | 182 | } |
183 | // #if 0 | 183 | // #if 0 |
184 | // topLayout->setColStretch(2,1); | 184 | // topLayout->setColStretch(2,1); |
185 | // topLayout->addWidget(statusLabel,3,3); | 185 | // topLayout->addWidget(statusLabel,3,3); |
186 | // topLayout->addWidget(mStatusCombo,3,4); | 186 | // topLayout->addWidget(mStatusCombo,3,4); |
187 | // #else | 187 | // #else |
188 | // topLayout->addWidget(statusLabel,4,3); | 188 | // topLayout->addWidget(statusLabel,4,3); |
189 | // // topLayout->addWidget(mStatusCombo,4,3); | 189 | // // topLayout->addWidget(mStatusCombo,4,3); |
190 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); | 190 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); |
191 | 191 | ||
192 | // #endif | 192 | // #endif |
193 | // // topLayout->setRowStretch(5,1); | 193 | // // topLayout->setRowStretch(5,1); |
194 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); | 194 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); |
195 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); | 195 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); |
196 | // topLayout->setRowStretch(1,5); | 196 | // topLayout->setRowStretch(1,5); |
197 | // topLayout->setColStretch(0,0); | 197 | // topLayout->setColStretch(0,0); |
198 | 198 | ||
199 | #ifdef KORG_NOKABC | 199 | #ifdef KORG_NOKABC |
200 | mAddressBookButton->hide(); | 200 | mAddressBookButton->hide(); |
201 | #endif | 201 | #endif |
202 | 202 | ||
203 | updateAttendeeInput(); | 203 | updateAttendeeInput(); |
204 | #ifndef DESKTOP_VERSION | 204 | #ifndef DESKTOP_VERSION |
205 | //US listen for arriving address resultsets | 205 | //US listen for arriving address resultsets |
206 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 206 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
207 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 207 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
208 | #endif | 208 | #endif |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | KOEditorDetails::~KOEditorDetails() | 212 | KOEditorDetails::~KOEditorDetails() |
213 | { | 213 | { |
214 | } | 214 | } |
215 | 215 | ||
216 | void KOEditorDetails::removeAttendee() | 216 | void KOEditorDetails::removeAttendee() |
217 | { | 217 | { |
218 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); | 218 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); |
219 | if (!aItem) return; | 219 | if (!aItem) return; |
220 | 220 | ||
221 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), | 221 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), |
222 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), | 222 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), |
223 | aItem->data()->uid()); | 223 | aItem->data()->uid()); |
224 | mdelAttendees.append(delA); | 224 | mdelAttendees.append(delA); |
225 | 225 | ||
226 | delete aItem; | 226 | delete aItem; |
227 | 227 | ||
228 | updateAttendeeInput(); | 228 | updateAttendeeInput(); |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | void KOEditorDetails::openAddressBook() | 232 | void KOEditorDetails::openAddressBook() |
233 | { | 233 | { |
234 | #ifndef KORG_NOKABC | 234 | #ifndef KORG_NOKABC |
235 | 235 | ||
236 | #ifdef DESKTOP_VERSION | 236 | #ifdef DESKTOP_VERSION |
237 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 237 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
238 | uint i=0; | 238 | uint i=0; |
239 | for (i=0; i < list.count(); i++) { | 239 | for (i=0; i < list.count(); i++) { |
240 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); | 240 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); |
241 | } | 241 | } |
242 | #else | 242 | #else |
243 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 243 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
244 | // the result should now arrive through method insertAttendees | 244 | // the result should now arrive through method insertAttendees |
245 | #endif | 245 | #endif |
246 | 246 | ||
247 | 247 | ||
248 | #if 0 | 248 | #if 0 |
249 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | 249 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); |
250 | if (!a.isEmpty()) { | 250 | if (!a.isEmpty()) { |
251 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); | 251 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); |
252 | } | 252 | } |
253 | #endif | 253 | #endif |
254 | #endif | 254 | #endif |
255 | } | 255 | } |
256 | 256 | ||
257 | 257 | ||
258 | void KOEditorDetails::addNewAttendee() | 258 | void KOEditorDetails::addNewAttendee() |
259 | { | 259 | { |
260 | #if 0 | 260 | #if 0 |
261 | // this is cool. If they didn't enter an email address, | 261 | // this is cool. If they didn't enter an email address, |
262 | // try to look it up in the address book and fill it in for them. | 262 | // try to look it up in the address book and fill it in for them. |
263 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { | 263 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { |
264 | KabAPI addrBook; | 264 | KabAPI addrBook; |
265 | QString name; | 265 | QString name; |
266 | std::list<AddressBook::Entry> entries; | 266 | std::list<AddressBook::Entry> entries; |
267 | name = mNameEdit->text(); | 267 | name = mNameEdit->text(); |
268 | if (addrBook.init() == AddressBook::NoError) { | 268 | if (addrBook.init() == AddressBook::NoError) { |
269 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { | 269 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { |
270 | kdDebug() << "positive match" << endl; | 270 | kdDebug() << "positive match" << endl; |
271 | // take first email address | 271 | // take first email address |
272 | if (!entries.front().emails.isEmpty() && | 272 | if (!entries.front().emails.isEmpty() && |
273 | entries.front().emails.first().length()>0) | 273 | entries.front().emails.first().length()>0) |
274 | mEmailEdit->setText(entries.front().emails.first()); | 274 | mEmailEdit->setText(entries.front().emails.first()); |
275 | } | 275 | } |
276 | } | 276 | } |
277 | } | 277 | } |
278 | #endif | 278 | #endif |
279 | 279 | ||
280 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); | 280 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); |
281 | insertAttendee(a); | 281 | insertAttendee(a); |
282 | } | 282 | } |
283 | 283 | ||
284 | //the map includes name/email pairs, that comes from Ka/Pi | 284 | //the map includes name/email pairs, that comes from Ka/Pi |
285 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 285 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
286 | { | 286 | { |
287 | if (uid == this->name()) | 287 | if (uid == this->name()) |
288 | { | 288 | { |
289 | for ( int i = 0; i < nameList.count(); i++) | 289 | for ( int i = 0; i < nameList.count(); i++) |
290 | { | 290 | { |
291 | QString _name = nameList[i]; | 291 | QString _name = nameList[i]; |
292 | QString _email = emailList[i]; | 292 | QString _email = emailList[i]; |
293 | QString _uid = uidList[i]; | 293 | QString _uid = uidList[i]; |
294 | 294 | ||
295 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); | 295 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); |
296 | insertAttendee(a); | 296 | insertAttendee(a); |
297 | } | 297 | } |
298 | } | 298 | } |
299 | 299 | ||
300 | } | 300 | } |
301 | 301 | ||
302 | |||
303 | void KOEditorDetails::insertAttendee(Attendee *a) | 302 | void KOEditorDetails::insertAttendee(Attendee *a) |
304 | { | 303 | { |
304 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); | ||
305 | while (first) { | ||
306 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) | ||
307 | return; | ||
308 | first = (AttendeeListItem*) first->nextSibling(); | ||
309 | } | ||
310 | |||
305 | AttendeeListItem *item = new AttendeeListItem(a,mListView); | 311 | AttendeeListItem *item = new AttendeeListItem(a,mListView); |
306 | mListView->setSelected( item, true ); | 312 | mListView->setSelected( item, true ); |
307 | } | 313 | } |
308 | 314 | ||
309 | void KOEditorDetails::setDefaults() | 315 | void KOEditorDetails::setDefaults() |
310 | { | 316 | { |
311 | mRsvpButton->setChecked(true); | 317 | mRsvpButton->setChecked(true); |
312 | mListView->clear(); | 318 | mListView->clear(); |
313 | mdelAttendees.clear(); | 319 | mdelAttendees.clear(); |
314 | clearAttendeeInput(); | 320 | clearAttendeeInput(); |
315 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); | 321 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); |
316 | 322 | ||
317 | mNameEdit->setText(""); | 323 | mNameEdit->setText(""); |
318 | mUidEdit->setText(""); | 324 | mUidEdit->setText(""); |
319 | mEmailEdit->setText(""); | 325 | mEmailEdit->setText(""); |
320 | mRoleCombo->setCurrentItem( 0 ); | 326 | mRoleCombo->setCurrentItem( 0 ); |
321 | mStatusCombo->setCurrentItem( 0 ); | 327 | mStatusCombo->setCurrentItem( 0 ); |
322 | 328 | ||
323 | } | 329 | } |
324 | 330 | ||
325 | void KOEditorDetails::readEvent(Incidence *event) | 331 | void KOEditorDetails::readEvent(Incidence *event) |
326 | { | 332 | { |
327 | setDefaults(); | 333 | setDefaults(); |
328 | //mListView->clear(); | 334 | //mListView->clear(); |
329 | //mdelAttendees.clear(); | 335 | //mdelAttendees.clear(); |
330 | QPtrList<Attendee> tmpAList = event->attendees(); | 336 | QPtrList<Attendee> tmpAList = event->attendees(); |
331 | Attendee *a; | 337 | Attendee *a; |
332 | for (a = tmpAList.first(); a; a = tmpAList.next()) | 338 | for (a = tmpAList.first(); a; a = tmpAList.next()) |
333 | insertAttendee(new Attendee(*a)); | 339 | insertAttendee(new Attendee(*a)); |
334 | 340 | ||
335 | mListView->setSelected( mListView->firstChild(), true ); | 341 | mListView->setSelected( mListView->firstChild(), true ); |
336 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); | 342 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); |
337 | } | 343 | } |
338 | 344 | ||
339 | void KOEditorDetails::writeEvent(Incidence *event) | 345 | void KOEditorDetails::writeEvent(Incidence *event) |
340 | { | 346 | { |
341 | event->clearAttendees(); | 347 | event->clearAttendees(); |
342 | QListViewItem *item; | 348 | QListViewItem *item; |
343 | AttendeeListItem *a; | 349 | AttendeeListItem *a; |
344 | for (item = mListView->firstChild(); item; | 350 | for (item = mListView->firstChild(); item; |
345 | item = item->nextSibling()) { | 351 | item = item->nextSibling()) { |
346 | a = (AttendeeListItem *)item; | 352 | a = (AttendeeListItem *)item; |
347 | event->addAttendee(new Attendee(*(a->data()))); | 353 | event->addAttendee(new Attendee(*(a->data()))); |
348 | } | 354 | } |
349 | event->setOrganizer(KOPrefs::instance()->email()); | 355 | event->setOrganizer(KOPrefs::instance()->email()); |
350 | } | 356 | } |
351 | 357 | ||
352 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) | 358 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) |
353 | { | 359 | { |
354 | event->clearAttendees(); | 360 | event->clearAttendees(); |
355 | Attendee * att; | 361 | Attendee * att; |
356 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { | 362 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { |
357 | event->addAttendee(new Attendee(*att)); | 363 | event->addAttendee(new Attendee(*att)); |
358 | } | 364 | } |
359 | mdelAttendees.clear(); | 365 | mdelAttendees.clear(); |
360 | } | 366 | } |
361 | 367 | ||
362 | bool KOEditorDetails::validateInput() | 368 | bool KOEditorDetails::validateInput() |
363 | { | 369 | { |
364 | return true; | 370 | return true; |
365 | } | 371 | } |
366 | 372 | ||
367 | void KOEditorDetails::updateAttendeeInput() | 373 | void KOEditorDetails::updateAttendeeInput() |
368 | { | 374 | { |
369 | QListViewItem *item = mListView->selectedItem(); | 375 | QListViewItem *item = mListView->selectedItem(); |
370 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 376 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
371 | if (aItem) { | 377 | if (aItem) { |
372 | fillAttendeeInput( aItem ); | 378 | fillAttendeeInput( aItem ); |
373 | } else { | 379 | } else { |
374 | clearAttendeeInput(); | 380 | clearAttendeeInput(); |
375 | } | 381 | } |
376 | } | 382 | } |
377 | 383 | ||
378 | void KOEditorDetails::clearAttendeeInput() | 384 | void KOEditorDetails::clearAttendeeInput() |
379 | { | 385 | { |
380 | mNameEdit->setText(""); | 386 | mNameEdit->setText(""); |
381 | mUidEdit->setText(""); | 387 | mUidEdit->setText(""); |
382 | mEmailEdit->setText(""); | 388 | mEmailEdit->setText(""); |
383 | mRoleCombo->setCurrentItem(0); | 389 | mRoleCombo->setCurrentItem(0); |
384 | mStatusCombo->setCurrentItem(0); | 390 | mStatusCombo->setCurrentItem(0); |
385 | mRsvpButton->setChecked(true); | 391 | mRsvpButton->setChecked(true); |
386 | setEnabledAttendeeInput( false ); | 392 | setEnabledAttendeeInput( false ); |
387 | } | 393 | } |
388 | 394 | ||
389 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) | 395 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) |
390 | { | 396 | { |
391 | Attendee *a = aItem->data(); | 397 | Attendee *a = aItem->data(); |
392 | mDisableItemUpdate = true; | 398 | mDisableItemUpdate = true; |
393 | mNameEdit->setText(a->name()); | 399 | mNameEdit->setText(a->name()); |
394 | mUidEdit->setText(a->uid()); | 400 | mUidEdit->setText(a->uid()); |
395 | mEmailEdit->setText(a->email()); | 401 | mEmailEdit->setText(a->email()); |
396 | mRoleCombo->setCurrentItem(a->role()); | 402 | mRoleCombo->setCurrentItem(a->role()); |
397 | mStatusCombo->setCurrentItem(a->status()); | 403 | mStatusCombo->setCurrentItem(a->status()); |
398 | mRsvpButton->setChecked(a->RSVP()); | 404 | mRsvpButton->setChecked(a->RSVP()); |
399 | 405 | ||
400 | mDisableItemUpdate = false; | 406 | mDisableItemUpdate = false; |
401 | 407 | ||
402 | setEnabledAttendeeInput( true ); | 408 | setEnabledAttendeeInput( true ); |
403 | } | 409 | } |
404 | 410 | ||
405 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) | 411 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) |
406 | { | 412 | { |
407 | mNameEdit->setEnabled( enabled ); | 413 | mNameEdit->setEnabled( enabled ); |
408 | mEmailEdit->setEnabled( enabled ); | 414 | mEmailEdit->setEnabled( enabled ); |
409 | mRoleCombo->setEnabled( enabled ); | 415 | mRoleCombo->setEnabled( enabled ); |
410 | mStatusCombo->setEnabled( enabled ); | 416 | mStatusCombo->setEnabled( enabled ); |
411 | mRsvpButton->setEnabled( enabled ); | 417 | mRsvpButton->setEnabled( enabled ); |
412 | 418 | ||
413 | mRemoveButton->setEnabled( enabled ); | 419 | mRemoveButton->setEnabled( enabled ); |
414 | } | 420 | } |
415 | 421 | ||
416 | void KOEditorDetails::updateAttendeeItem() | 422 | void KOEditorDetails::updateAttendeeItem() |
417 | { | 423 | { |
418 | if (mDisableItemUpdate) return; | 424 | if (mDisableItemUpdate) return; |
419 | 425 | ||
420 | QListViewItem *item = mListView->selectedItem(); | 426 | QListViewItem *item = mListView->selectedItem(); |
421 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 427 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
422 | if ( !aItem ) return; | 428 | if ( !aItem ) return; |
423 | 429 | ||
424 | Attendee *a = aItem->data(); | 430 | Attendee *a = aItem->data(); |
425 | 431 | ||
426 | a->setName( mNameEdit->text() ); | 432 | a->setName( mNameEdit->text() ); |
427 | a->setUid( mUidEdit->text() ); | 433 | a->setUid( mUidEdit->text() ); |
428 | a->setEmail( mEmailEdit->text() ); | 434 | a->setEmail( mEmailEdit->text() ); |
429 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); | 435 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); |
430 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); | 436 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); |
431 | a->setRSVP( mRsvpButton->isChecked() ); | 437 | a->setRSVP( mRsvpButton->isChecked() ); |
432 | aItem->updateItem(); | 438 | aItem->updateItem(); |
433 | } | 439 | } |