summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koeditordetails.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
index 6ecf978..7354940 100644
--- a/korganizer/koeditordetails.cpp
+++ b/korganizer/koeditordetails.cpp
@@ -1,263 +1,267 @@
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
55template <> 55template <>
56CustomListViewItem<class Attendee *>::~CustomListViewItem() 56CustomListViewItem<class Attendee *>::~CustomListViewItem()
57{ 57{
58 delete mData; 58 delete mData;
59} 59}
60 60
61template <> 61template <>
62void CustomListViewItem<class Attendee *>::updateItem() 62void 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 setSortKey(4,"j");
71 }
72 else {
71 setPixmap(4,SmallIcon("nomailappt")); 73 setPixmap(4,SmallIcon("nomailappt"));
74 setSortKey(4,"n");
75 }
72} 76}
73 77
74 78
75KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) 79KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name)
76 : QWidget( parent, name), mDisableItemUpdate( false ) 80 : QWidget( parent, name), mDisableItemUpdate( false )
77{ 81{
78 QGridLayout *topLayout = new QGridLayout(this); 82 QGridLayout *topLayout = new QGridLayout(this);
79 topLayout->setSpacing(spacing); 83 topLayout->setSpacing(spacing);
80 84
81 QString organizer = KOPrefs::instance()->email(); 85 QString organizer = KOPrefs::instance()->email();
82 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this); 86 mOrganizerLabel = new QLabel(i18n("Organizer: %1").arg(organizer),this);
83 87
84 mListView = new KListView(this,"mListView"); 88 mListView = new KListView(this,"mListView");
85 mListView->addColumn(i18n("Name"),180); 89 mListView->addColumn(i18n("Name"),180);
86 mListView->addColumn(i18n("Email"),180); 90 mListView->addColumn(i18n("Email"),180);
87 mListView->addColumn(i18n("Role"),60); 91 mListView->addColumn(i18n("Role"),60);
88 mListView->addColumn(i18n("Status"),100); 92 mListView->addColumn(i18n("Status"),100);
89 mListView->addColumn(i18n("RSVP"),35); 93 mListView->addColumn(i18n("RSVP"),35);
90 if ( QApplication::desktop()->width() <= 320 || QApplication::desktop()->height() <= 240) { 94 if ( QApplication::desktop()->width() <= 320 || QApplication::desktop()->height() <= 240) {
91 int hei = 80; 95 int hei = 80;
92 if ( QApplication::desktop()->height() <= 240 ) 96 if ( QApplication::desktop()->height() <= 240 )
93 hei = 60; 97 hei = 60;
94 mListView->setFixedHeight(hei); 98 mListView->setFixedHeight(hei);
95 } 99 }
96 mListView->setAllColumnsShowFocus (true ); 100 mListView->setAllColumnsShowFocus (true );
97 //mListView->setSingleClick( true ); 101 //mListView->setSingleClick( true );
98 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), 102 connect(mListView,SIGNAL(selectionChanged(QListViewItem *)),
99 SLOT(updateAttendeeInput())); 103 SLOT(updateAttendeeInput()));
100 104
101 connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), 105 connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )),
102 SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); 106 SLOT(itemClicked(QListViewItem * ,const QPoint& , int )));
103 107
104 mRsvpButton = new QCheckBox(this); 108 mRsvpButton = new QCheckBox(this);
105 mRsvpButton->setText(i18n("Request response")); 109 mRsvpButton->setText(i18n("Request response"));
106 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); 110 mAddressBookButton = new QPushButton(i18n("Address &Book..."),this);
107 QLabel *attendeeLabel = new QLabel(this); 111 QLabel *attendeeLabel = new QLabel(this);
108 attendeeLabel->setText(i18n("Name:")); 112 attendeeLabel->setText(i18n("Name:"));
109 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); 113 attendeeLabel->setFixedSize( attendeeLabel->sizeHint() );
110 mNameEdit = new QLineEdit(this); 114 mNameEdit = new QLineEdit(this);
111 connect(mNameEdit,SIGNAL(textChanged(const QString &)), 115 connect(mNameEdit,SIGNAL(textChanged(const QString &)),
112 SLOT(updateAttendeeItem())); 116 SLOT(updateAttendeeItem()));
113 117
114 mUidEdit = new QLineEdit(0); 118 mUidEdit = new QLineEdit(0);
115 mUidEdit->setText(""); 119 mUidEdit->setText("");
116 120
117 QLabel *emailLabel = new QLabel(this); 121 QLabel *emailLabel = new QLabel(this);
118 emailLabel->setText(i18n("Email:")); 122 emailLabel->setText(i18n("Email:"));
119 mEmailEdit = new QLineEdit(this); 123 mEmailEdit = new QLineEdit(this);
120 connect(mEmailEdit,SIGNAL(textChanged(const QString &)), 124 connect(mEmailEdit,SIGNAL(textChanged(const QString &)),
121 SLOT(updateAttendeeItem())); 125 SLOT(updateAttendeeItem()));
122 126
123 QLabel *attendeeRoleLabel = new QLabel(this); 127 QLabel *attendeeRoleLabel = new QLabel(this);
124 attendeeRoleLabel->setText(i18n("Role:")); 128 attendeeRoleLabel->setText(i18n("Role:"));
125 mRoleCombo = new QComboBox(false,this); 129 mRoleCombo = new QComboBox(false,this);
126 mRoleCombo->insertStringList(Attendee::roleList()); 130 mRoleCombo->insertStringList(Attendee::roleList());
127 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 131 connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
128 132
129 QLabel *statusLabel = new QLabel(this); 133 QLabel *statusLabel = new QLabel(this);
130 statusLabel->setText( i18n("Status:") ); 134 statusLabel->setText( i18n("Status:") );
131 135
132 mStatusCombo = new QComboBox(false,this); 136 mStatusCombo = new QComboBox(false,this);
133 mStatusCombo->insertStringList(Attendee::statusList()); 137 mStatusCombo->insertStringList(Attendee::statusList());
134 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); 138 connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem()));
135 139
136 140
137 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); 141 connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem()));
138 QWidget *buttonBox = new QWidget(this); 142 QWidget *buttonBox = new QWidget(this);
139 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); 143 QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox);
140 144
141 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); 145 QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox);
142 buttonLayout->addWidget(newButton); 146 buttonLayout->addWidget(newButton);
143 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); 147 connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee()));
144 148
145 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); 149 mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox);
146 buttonLayout->addWidget(mRemoveButton); 150 buttonLayout->addWidget(mRemoveButton);
147 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); 151 connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee()));
148 152
149 // buttonLayout->addWidget(mAddressBookButton); 153 // buttonLayout->addWidget(mAddressBookButton);
150 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); 154 connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook()));
151 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); 155 //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () );
152 if ( QApplication::desktop()->height() <= 240 ) { 156 if ( QApplication::desktop()->height() <= 240 ) {
153 mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); 157 mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) );
154 mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); 158 mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) );
155 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 159 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
156 topLayout->addMultiCellWidget(mListView,1,1,0,5); 160 topLayout->addMultiCellWidget(mListView,1,1,0,5);
157 topLayout->addWidget(attendeeLabel,3,0); 161 topLayout->addWidget(attendeeLabel,3,0);
158 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 162 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
159 topLayout->addWidget(emailLabel,4,0); 163 topLayout->addWidget(emailLabel,4,0);
160 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 164 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
161 topLayout->addWidget(attendeeRoleLabel,5,0); 165 topLayout->addWidget(attendeeRoleLabel,5,0);
162 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 166 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
163 topLayout->addWidget(statusLabel,5,3); 167 topLayout->addWidget(statusLabel,5,3);
164 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 168 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
165 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5); 169 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5);
166 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 170 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
167 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 171 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
168 topLayout->setRowStretch(1,5); 172 topLayout->setRowStretch(1,5);
169 topLayout->setColStretch(0,0); 173 topLayout->setColStretch(0,0);
170 } else { 174 } else {
171 if (qApp->desktop()->width() < 640 ) { 175 if (qApp->desktop()->width() < 640 ) {
172 if ( qApp->desktop()->width() < 300 ) 176 if ( qApp->desktop()->width() < 300 )
173 topLayout->setSpacing(1); 177 topLayout->setSpacing(1);
174 ;//mListView->setFixedHeight(80); 178 ;//mListView->setFixedHeight(80);
175 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); 179 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3);
176 topLayout->addMultiCellWidget(mListView,1,1,0,3); 180 topLayout->addMultiCellWidget(mListView,1,1,0,3);
177 topLayout->addWidget(attendeeLabel,3,0); 181 topLayout->addWidget(attendeeLabel,3,0);
178 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); 182 topLayout->addMultiCellWidget(mNameEdit,3,3,1,2);
179 topLayout->addWidget(emailLabel,4,0); 183 topLayout->addWidget(emailLabel,4,0);
180 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); 184 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2);
181 topLayout->addWidget(attendeeRoleLabel,5,0); 185 topLayout->addWidget(attendeeRoleLabel,5,0);
182 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); 186 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3);
183 topLayout->addWidget(statusLabel,6,0); 187 topLayout->addWidget(statusLabel,6,0);
184 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); 188 topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3);
185 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); 189 topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3);
186 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 190 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
187 topLayout->addMultiCellWidget(buttonBox,3,4,3,3); 191 topLayout->addMultiCellWidget(buttonBox,3,4,3,3);
188 topLayout->setRowStretch(1,2); 192 topLayout->setRowStretch(1,2);
189 topLayout->setColStretch(0,0); 193 topLayout->setColStretch(0,0);
190 topLayout->setColStretch(1,2); 194 topLayout->setColStretch(1,2);
191 topLayout->setColStretch(2,1); 195 topLayout->setColStretch(2,1);
192 topLayout->setColStretch(3,1); 196 topLayout->setColStretch(3,1);
193 } else { 197 } else {
194 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); 198 topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5);
195 topLayout->addMultiCellWidget(mListView,1,1,0,5); 199 topLayout->addMultiCellWidget(mListView,1,1,0,5);
196 topLayout->addWidget(attendeeLabel,3,0); 200 topLayout->addWidget(attendeeLabel,3,0);
197 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); 201 topLayout->addMultiCellWidget(mNameEdit,3,3,1,4);
198 topLayout->addWidget(emailLabel,4,0); 202 topLayout->addWidget(emailLabel,4,0);
199 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); 203 topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4);
200 topLayout->addWidget(attendeeRoleLabel,5,0); 204 topLayout->addWidget(attendeeRoleLabel,5,0);
201 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); 205 topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2);
202 topLayout->addWidget(statusLabel,5,3); 206 topLayout->addWidget(statusLabel,5,3);
203 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); 207 topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5);
204 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); 208 topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5);
205 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); 209 topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1);
206 topLayout->addMultiCellWidget(buttonBox,3,4,5,5); 210 topLayout->addMultiCellWidget(buttonBox,3,4,5,5);
207 topLayout->setRowStretch(1,5); 211 topLayout->setRowStretch(1,5);
208 topLayout->setColStretch(0,0); 212 topLayout->setColStretch(0,0);
209 } 213 }
210 } 214 }
211// #if 0 215// #if 0
212// topLayout->setColStretch(2,1); 216// topLayout->setColStretch(2,1);
213// topLayout->addWidget(statusLabel,3,3); 217// topLayout->addWidget(statusLabel,3,3);
214// topLayout->addWidget(mStatusCombo,3,4); 218// topLayout->addWidget(mStatusCombo,3,4);
215// #else 219// #else
216// topLayout->addWidget(statusLabel,4,3); 220// topLayout->addWidget(statusLabel,4,3);
217// // topLayout->addWidget(mStatusCombo,4,3); 221// // topLayout->addWidget(mStatusCombo,4,3);
218// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); 222// topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5);
219 223
220// #endif 224// #endif
221// // topLayout->setRowStretch(5,1); 225// // topLayout->setRowStretch(5,1);
222// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); 226// topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1);
223// topLayout->addMultiCellWidget(buttonBox,2,3,5,5); 227// topLayout->addMultiCellWidget(buttonBox,2,3,5,5);
224// topLayout->setRowStretch(1,5); 228// topLayout->setRowStretch(1,5);
225// topLayout->setColStretch(0,0); 229// topLayout->setColStretch(0,0);
226 230
227#ifdef KORG_NOKABC 231#ifdef KORG_NOKABC
228 mAddressBookButton->hide(); 232 mAddressBookButton->hide();
229#endif 233#endif
230 234
231 updateAttendeeInput(); 235 updateAttendeeInput();
232#ifndef DESKTOP_VERSION 236#ifndef DESKTOP_VERSION
233//US listen for arriving address resultsets 237//US listen for arriving address resultsets
234 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), 238 connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)),
235 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); 239 this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&)));
236#endif 240#endif
237 241
238} 242}
239 243
240KOEditorDetails::~KOEditorDetails() 244KOEditorDetails::~KOEditorDetails()
241{ 245{
242} 246}
243 247
244void KOEditorDetails::removeAttendee() 248void KOEditorDetails::removeAttendee()
245{ 249{
246 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); 250 AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem();
247 if (!aItem) return; 251 if (!aItem) return;
248 252
249 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), 253 Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(),
250 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), 254 aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(),
251 aItem->data()->uid()); 255 aItem->data()->uid());
252 mdelAttendees.append(delA); 256 mdelAttendees.append(delA);
253 257
254 delete aItem; 258 delete aItem;
255 259
256 updateAttendeeInput(); 260 updateAttendeeInput();
257} 261}
258 262
259 263
260void KOEditorDetails::openAddressBook() 264void KOEditorDetails::openAddressBook()
261{ 265{
262#ifndef KORG_NOKABC 266#ifndef KORG_NOKABC
263 267
@@ -278,197 +282,199 @@ void KOEditorDetails::openAddressBook()
278 if (!a.isEmpty()) { 282 if (!a.isEmpty()) {
279 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); 283 insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) );
280 } 284 }
281#endif 285#endif
282#endif 286#endif
283} 287}
284 288
285 289
286void KOEditorDetails::addNewAttendee() 290void KOEditorDetails::addNewAttendee()
287{ 291{
288#if 0 292#if 0
289 // this is cool. If they didn't enter an email address, 293 // this is cool. If they didn't enter an email address,
290 // try to look it up in the address book and fill it in for them. 294 // try to look it up in the address book and fill it in for them.
291 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { 295 if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) {
292 KabAPI addrBook; 296 KabAPI addrBook;
293 QString name; 297 QString name;
294 std::list<AddressBook::Entry> entries; 298 std::list<AddressBook::Entry> entries;
295 name = mNameEdit->text(); 299 name = mNameEdit->text();
296 if (addrBook.init() == AddressBook::NoError) { 300 if (addrBook.init() == AddressBook::NoError) {
297 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { 301 if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) {
298 kdDebug() << "positive match" << endl; 302 kdDebug() << "positive match" << endl;
299 // take first email address 303 // take first email address
300 if (!entries.front().emails.isEmpty() && 304 if (!entries.front().emails.isEmpty() &&
301 entries.front().emails.first().length()>0) 305 entries.front().emails.first().length()>0)
302 mEmailEdit->setText(entries.front().emails.first()); 306 mEmailEdit->setText(entries.front().emails.first());
303 } 307 }
304 } 308 }
305 } 309 }
306#endif 310#endif
307 311
308 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); 312 Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)"));
309 insertAttendee(a); 313 insertAttendee(a);
310} 314}
311 315
312//the map includes name/email pairs, that comes from Ka/Pi 316//the map includes name/email pairs, that comes from Ka/Pi
313void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 317void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList)
314{ 318{
315 if (uid == this->name()) 319 if (uid == this->name())
316 { 320 {
317 for ( int i = 0; i < nameList.count(); i++) 321 for ( int i = 0; i < nameList.count(); i++)
318 { 322 {
319 QString _name = nameList[i]; 323 QString _name = nameList[i];
320 QString _email = emailList[i]; 324 QString _email = emailList[i];
321 QString _uid = uidList[i]; 325 QString _uid = uidList[i];
322 326
323 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); 327 Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid);
324 insertAttendee(a); 328 insertAttendee(a);
325 } 329 }
326 } 330 }
327 331
328} 332}
329 333
330void KOEditorDetails::insertAttendee(Attendee *a) 334void KOEditorDetails::insertAttendee(Attendee *a)
331{ 335{
332 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); 336 AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild();
333 while (first) { 337 while (first) {
334 if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) 338 if ( first->data()->name() == a->name() && first->data()->email() == a->email() )
335 return; 339 return;
336 first = (AttendeeListItem*) first->nextSibling(); 340 first = (AttendeeListItem*) first->nextSibling();
337 } 341 }
338 342
339 AttendeeListItem *item = new AttendeeListItem(a,mListView); 343 AttendeeListItem *item = new AttendeeListItem(a,mListView);
340 mListView->setSelected( item, true ); 344 mListView->setSelected( item, true );
341} 345}
342 346
343void KOEditorDetails::setDefaults() 347void KOEditorDetails::setDefaults()
344{ 348{
345 mRsvpButton->setChecked(true); 349 mRsvpButton->setChecked(true);
346 mListView->clear(); 350 mListView->clear();
347 mdelAttendees.clear(); 351 mdelAttendees.clear();
348 clearAttendeeInput(); 352 clearAttendeeInput();
349 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); 353 mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email()));
350 354
351 mNameEdit->setText(""); 355 mNameEdit->setText("");
352 mUidEdit->setText(""); 356 mUidEdit->setText("");
353 mEmailEdit->setText(""); 357 mEmailEdit->setText("");
354 mRoleCombo->setCurrentItem( 0 ); 358 mRoleCombo->setCurrentItem( 0 );
355 mStatusCombo->setCurrentItem( 0 ); 359 mStatusCombo->setCurrentItem( 0 );
356 360
357} 361}
358 362
359void KOEditorDetails::readEvent(Incidence *event) 363void KOEditorDetails::readEvent(Incidence *event)
360{ 364{
361 setDefaults(); 365 setDefaults();
362 //mListView->clear(); 366 //mListView->clear();
363 //mdelAttendees.clear(); 367 //mdelAttendees.clear();
364 QPtrList<Attendee> tmpAList = event->attendees(); 368 QPtrList<Attendee> tmpAList = event->attendees();
365 Attendee *a; 369 Attendee *a;
366 for (a = tmpAList.first(); a; a = tmpAList.next()) 370 for (a = tmpAList.first(); a; a = tmpAList.next())
367 insertAttendee(new Attendee(*a)); 371 insertAttendee(new Attendee(*a));
368 372
369 mListView->setSelected( mListView->firstChild(), true ); 373 mListView->setSelected( mListView->firstChild(), true );
370 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); 374 mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer()));
371} 375}
372 376
373void KOEditorDetails::writeEvent(Incidence *event) 377void KOEditorDetails::writeEvent(Incidence *event)
374{ 378{
375 event->clearAttendees(); 379 event->clearAttendees();
376 QListViewItem *item; 380 QListViewItem *item;
377 AttendeeListItem *a; 381 AttendeeListItem *a;
378 for (item = mListView->firstChild(); item; 382 for (item = mListView->firstChild(); item;
379 item = item->nextSibling()) { 383 item = item->nextSibling()) {
380 a = (AttendeeListItem *)item; 384 a = (AttendeeListItem *)item;
381 event->addAttendee(new Attendee(*(a->data()))); 385 event->addAttendee(new Attendee(*(a->data())));
382 } 386 }
383 event->setOrganizer(KOPrefs::instance()->email()); 387 event->setOrganizer(KOPrefs::instance()->email());
384} 388}
385 389
386void KOEditorDetails::cancelAttendeeEvent(Incidence *event) 390void KOEditorDetails::cancelAttendeeEvent(Incidence *event)
387{ 391{
388 event->clearAttendees(); 392 event->clearAttendees();
389 Attendee * att; 393 Attendee * att;
390 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { 394 for (att=mdelAttendees.first();att;att=mdelAttendees.next()) {
391 event->addAttendee(new Attendee(*att)); 395 event->addAttendee(new Attendee(*att));
392 } 396 }
393 mdelAttendees.clear(); 397 mdelAttendees.clear();
394} 398}
395 399
396bool KOEditorDetails::validateInput() 400bool KOEditorDetails::validateInput()
397{ 401{
398 return true; 402 return true;
399} 403}
400 404
401void KOEditorDetails::updateAttendeeInput() 405void KOEditorDetails::updateAttendeeInput()
402{ 406{
403 QListViewItem *item = mListView->selectedItem(); 407 QListViewItem *item = mListView->selectedItem();
404 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 408 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
405 if (aItem) { 409 if (aItem) {
406 fillAttendeeInput( aItem ); 410 fillAttendeeInput( aItem );
407 } else { 411 } else {
408 clearAttendeeInput(); 412 clearAttendeeInput();
409 } 413 }
410} 414}
411 415
412void KOEditorDetails::clearAttendeeInput() 416void KOEditorDetails::clearAttendeeInput()
413{ 417{
414 mNameEdit->setText(""); 418 mNameEdit->setText("");
415 mUidEdit->setText(""); 419 mUidEdit->setText("");
416 mEmailEdit->setText(""); 420 mEmailEdit->setText("");
417 mRoleCombo->setCurrentItem(0); 421 mRoleCombo->setCurrentItem(0);
418 mStatusCombo->setCurrentItem(0); 422 mStatusCombo->setCurrentItem(0);
419 mRsvpButton->setChecked(true); 423 mRsvpButton->setChecked(true);
420 setEnabledAttendeeInput( false ); 424 setEnabledAttendeeInput( false );
421} 425}
422 426
423void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) 427void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
424{ 428{
425 Attendee *a = aItem->data(); 429 Attendee *a = aItem->data();
426 mDisableItemUpdate = true; 430 mDisableItemUpdate = true;
427 mNameEdit->setText(a->name()); 431 mNameEdit->setText(a->name());
428 mUidEdit->setText(a->uid()); 432 mUidEdit->setText(a->uid());
429 mEmailEdit->setText(a->email()); 433 mEmailEdit->setText(a->email());
430 mRoleCombo->setCurrentItem(a->role()); 434 mRoleCombo->setCurrentItem(a->role());
431 mStatusCombo->setCurrentItem(a->status()); 435 mStatusCombo->setCurrentItem(a->status());
432 mRsvpButton->setChecked(a->RSVP()); 436 mRsvpButton->setChecked(a->RSVP());
433 437
434 mDisableItemUpdate = false; 438 mDisableItemUpdate = false;
435 439
436 setEnabledAttendeeInput( true ); 440 setEnabledAttendeeInput( true );
437} 441}
438 442
439void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) 443void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
440{ 444{
441 mNameEdit->setEnabled( enabled ); 445 mNameEdit->setEnabled( enabled );
442 mEmailEdit->setEnabled( enabled ); 446 mEmailEdit->setEnabled( enabled );
443 mRoleCombo->setEnabled( enabled ); 447 mRoleCombo->setEnabled( enabled );
444 mStatusCombo->setEnabled( enabled ); 448 mStatusCombo->setEnabled( enabled );
445 mRsvpButton->setEnabled( enabled ); 449 mRsvpButton->setEnabled( enabled );
446 450
447 mRemoveButton->setEnabled( enabled ); 451 mRemoveButton->setEnabled( enabled );
448} 452}
449 453
450void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) 454void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c )
451{ 455{
452 if ( item && c == 4 ) { 456 if ( item && c == 4 ) {
453 mRsvpButton->setChecked( !mRsvpButton->isChecked() ); 457 mRsvpButton->setChecked( !mRsvpButton->isChecked() );
454 updateAttendeeItem(); 458 updateAttendeeItem();
455 } 459 }
456} 460}
457void KOEditorDetails::updateAttendeeItem() 461void KOEditorDetails::updateAttendeeItem()
458{ 462{
459 if (mDisableItemUpdate) return; 463 if (mDisableItemUpdate) return;
460 464
461 QListViewItem *item = mListView->selectedItem(); 465 QListViewItem *item = mListView->selectedItem();
462 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 466 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
463 if ( !aItem ) return; 467 if ( !aItem ) return;
464 468
465 Attendee *a = aItem->data(); 469 Attendee *a = aItem->data();
466 470
467 a->setName( mNameEdit->text() ); 471 a->setName( mNameEdit->text() );
468 a->setUid( mUidEdit->text() ); 472 a->setUid( mUidEdit->text() );
469 a->setEmail( mEmailEdit->text() ); 473 a->setEmail( mEmailEdit->text() );
474 if ( mEmailEdit->text().isEmpty() )
475 mRsvpButton->setChecked( false );
476 a->setRSVP( mRsvpButton->isChecked() );
470 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); 477 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
471 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); 478 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
472 a->setRSVP( mRsvpButton->isChecked() );
473 aItem->updateItem(); 479 aItem->updateItem();
474} 480}