Diffstat (limited to 'korganizer/koeditordetails.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | korganizer/koeditordetails.cpp | 102 |
1 files changed, 61 insertions, 41 deletions
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index 802261c..bdfc637 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp | |||
@@ -1,381 +1,401 @@ | |||
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 ( QApplication::desktop()->width() <= 320 ) { | 90 | if ( QApplication::desktop()->width() <= 320 ) { |
91 | //mListView->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding) ); | 91 | int hei = 80; |
92 | mListView->setFixedHeight(80); | 92 | if ( QApplication::desktop()->height() <= 240 ) |
93 | hei = 60; | ||
94 | mListView->setFixedHeight(hei); | ||
93 | } | 95 | } |
94 | mListView->setAllColumnsShowFocus (true ); | 96 | mListView->setAllColumnsShowFocus (true ); |
95 | //mListView->setSingleClick( true ); | 97 | //mListView->setSingleClick( true ); |
96 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), | 98 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), |
97 | SLOT(updateAttendeeInput())); | 99 | SLOT(updateAttendeeInput())); |
98 | 100 | ||
99 | connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), | 101 | connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), |
100 | SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); | 102 | SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); |
101 | 103 | ||
102 | mRsvpButton = new QCheckBox(this); | 104 | mRsvpButton = new QCheckBox(this); |
103 | mRsvpButton->setText(i18n("Request response")); | 105 | mRsvpButton->setText(i18n("Request response")); |
104 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); | 106 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); |
105 | QLabel *attendeeLabel = new QLabel(this); | 107 | QLabel *attendeeLabel = new QLabel(this); |
106 | attendeeLabel->setText(i18n("Name:")); | 108 | attendeeLabel->setText(i18n("Name:")); |
107 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); | 109 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); |
108 | mNameEdit = new QLineEdit(this); | 110 | mNameEdit = new QLineEdit(this); |
109 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), | 111 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), |
110 | SLOT(updateAttendeeItem())); | 112 | SLOT(updateAttendeeItem())); |
111 | 113 | ||
112 | mUidEdit = new QLineEdit(0); | 114 | mUidEdit = new QLineEdit(0); |
113 | mUidEdit->setText(""); | 115 | mUidEdit->setText(""); |
114 | 116 | ||
115 | QLabel *emailLabel = new QLabel(this); | 117 | QLabel *emailLabel = new QLabel(this); |
116 | emailLabel->setText(i18n("Email:")); | 118 | emailLabel->setText(i18n("Email:")); |
117 | mEmailEdit = new QLineEdit(this); | 119 | mEmailEdit = new QLineEdit(this); |
118 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), | 120 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), |
119 | SLOT(updateAttendeeItem())); | 121 | SLOT(updateAttendeeItem())); |
120 | 122 | ||
121 | QLabel *attendeeRoleLabel = new QLabel(this); | 123 | QLabel *attendeeRoleLabel = new QLabel(this); |
122 | attendeeRoleLabel->setText(i18n("Role:")); | 124 | attendeeRoleLabel->setText(i18n("Role:")); |
123 | mRoleCombo = new QComboBox(false,this); | 125 | mRoleCombo = new QComboBox(false,this); |
124 | mRoleCombo->insertStringList(Attendee::roleList()); | 126 | mRoleCombo->insertStringList(Attendee::roleList()); |
125 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 127 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
126 | 128 | ||
127 | QLabel *statusLabel = new QLabel(this); | 129 | QLabel *statusLabel = new QLabel(this); |
128 | statusLabel->setText( i18n("Status:") ); | 130 | statusLabel->setText( i18n("Status:") ); |
129 | 131 | ||
130 | mStatusCombo = new QComboBox(false,this); | 132 | mStatusCombo = new QComboBox(false,this); |
131 | mStatusCombo->insertStringList(Attendee::statusList()); | 133 | mStatusCombo->insertStringList(Attendee::statusList()); |
132 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 134 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
133 | 135 | ||
134 | 136 | ||
135 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); | 137 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); |
136 | QWidget *buttonBox = new QWidget(this); | 138 | QWidget *buttonBox = new QWidget(this); |
137 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); | 139 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); |
138 | 140 | ||
139 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); | 141 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); |
140 | buttonLayout->addWidget(newButton); | 142 | buttonLayout->addWidget(newButton); |
141 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); | 143 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); |
142 | 144 | ||
143 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); | 145 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); |
144 | buttonLayout->addWidget(mRemoveButton); | 146 | buttonLayout->addWidget(mRemoveButton); |
145 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); | 147 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); |
146 | 148 | ||
147 | // buttonLayout->addWidget(mAddressBookButton); | 149 | // buttonLayout->addWidget(mAddressBookButton); |
148 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); | 150 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); |
149 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); | 151 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); |
150 | 152 | if ( QApplication::desktop()->height() <= 240 ) { | |
151 | if (qApp->desktop()->width() < 640 ) { | 153 | mRoleCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); |
152 | if ( qApp->desktop()->width() < 300 ) | 154 | mStatusCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Minimum ,FALSE) ); |
153 | topLayout->setSpacing(1); | ||
154 | ;//mListView->setFixedHeight(80); | ||
155 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); | ||
156 | topLayout->addMultiCellWidget(mListView,1,1,0,3); | ||
157 | topLayout->addWidget(attendeeLabel,3,0); | ||
158 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); | ||
159 | topLayout->addWidget(emailLabel,4,0); | ||
160 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); | ||
161 | topLayout->addWidget(attendeeRoleLabel,5,0); | ||
162 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); | ||
163 | topLayout->addWidget(statusLabel,6,0); | ||
164 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); | ||
165 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); | ||
166 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | ||
167 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); | ||
168 | topLayout->setRowStretch(1,2); | ||
169 | topLayout->setColStretch(0,0); | ||
170 | topLayout->setColStretch(1,2); | ||
171 | topLayout->setColStretch(2,1); | ||
172 | topLayout->setColStretch(3,1); | ||
173 | |||
174 | } else { | ||
175 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); | 155 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); |
176 | topLayout->addMultiCellWidget(mListView,1,1,0,5); | 156 | topLayout->addMultiCellWidget(mListView,1,1,0,5); |
177 | topLayout->addWidget(attendeeLabel,3,0); | 157 | topLayout->addWidget(attendeeLabel,3,0); |
178 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); | 158 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); |
179 | topLayout->addWidget(emailLabel,4,0); | 159 | topLayout->addWidget(emailLabel,4,0); |
180 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); | 160 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); |
181 | topLayout->addWidget(attendeeRoleLabel,5,0); | 161 | topLayout->addWidget(attendeeRoleLabel,5,0); |
182 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 162 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
183 | topLayout->addWidget(statusLabel,5,3); | 163 | topLayout->addWidget(statusLabel,5,3); |
184 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | 164 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); |
185 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | 165 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,5); |
186 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 166 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
187 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | 167 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); |
188 | topLayout->setRowStretch(1,5); | 168 | topLayout->setRowStretch(1,5); |
189 | topLayout->setColStretch(0,0); | 169 | topLayout->setColStretch(0,0); |
170 | } else { | ||
171 | if (qApp->desktop()->width() < 640 ) { | ||
172 | if ( qApp->desktop()->width() < 300 ) | ||
173 | topLayout->setSpacing(1); | ||
174 | ;//mListView->setFixedHeight(80); | ||
175 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); | ||
176 | topLayout->addMultiCellWidget(mListView,1,1,0,3); | ||
177 | topLayout->addWidget(attendeeLabel,3,0); | ||
178 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); | ||
179 | topLayout->addWidget(emailLabel,4,0); | ||
180 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); | ||
181 | topLayout->addWidget(attendeeRoleLabel,5,0); | ||
182 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); | ||
183 | topLayout->addWidget(statusLabel,6,0); | ||
184 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); | ||
185 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); | ||
186 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | ||
187 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); | ||
188 | topLayout->setRowStretch(1,2); | ||
189 | topLayout->setColStretch(0,0); | ||
190 | topLayout->setColStretch(1,2); | ||
191 | topLayout->setColStretch(2,1); | ||
192 | topLayout->setColStretch(3,1); | ||
193 | } else { | ||
194 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); | ||
195 | topLayout->addMultiCellWidget(mListView,1,1,0,5); | ||
196 | topLayout->addWidget(attendeeLabel,3,0); | ||
197 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); | ||
198 | topLayout->addWidget(emailLabel,4,0); | ||
199 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); | ||
200 | topLayout->addWidget(attendeeRoleLabel,5,0); | ||
201 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | ||
202 | topLayout->addWidget(statusLabel,5,3); | ||
203 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | ||
204 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | ||
205 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | ||
206 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | ||
207 | topLayout->setRowStretch(1,5); | ||
208 | topLayout->setColStretch(0,0); | ||
209 | } | ||
190 | } | 210 | } |
191 | // #if 0 | 211 | // #if 0 |
192 | // topLayout->setColStretch(2,1); | 212 | // topLayout->setColStretch(2,1); |
193 | // topLayout->addWidget(statusLabel,3,3); | 213 | // topLayout->addWidget(statusLabel,3,3); |
194 | // topLayout->addWidget(mStatusCombo,3,4); | 214 | // topLayout->addWidget(mStatusCombo,3,4); |
195 | // #else | 215 | // #else |
196 | // topLayout->addWidget(statusLabel,4,3); | 216 | // topLayout->addWidget(statusLabel,4,3); |
197 | // // topLayout->addWidget(mStatusCombo,4,3); | 217 | // // topLayout->addWidget(mStatusCombo,4,3); |
198 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); | 218 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); |
199 | 219 | ||
200 | // #endif | 220 | // #endif |
201 | // // topLayout->setRowStretch(5,1); | 221 | // // topLayout->setRowStretch(5,1); |
202 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); | 222 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); |
203 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); | 223 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); |
204 | // topLayout->setRowStretch(1,5); | 224 | // topLayout->setRowStretch(1,5); |
205 | // topLayout->setColStretch(0,0); | 225 | // topLayout->setColStretch(0,0); |
206 | 226 | ||
207 | #ifdef KORG_NOKABC | 227 | #ifdef KORG_NOKABC |
208 | mAddressBookButton->hide(); | 228 | mAddressBookButton->hide(); |
209 | #endif | 229 | #endif |
210 | 230 | ||
211 | updateAttendeeInput(); | 231 | updateAttendeeInput(); |
212 | #ifndef DESKTOP_VERSION | 232 | #ifndef DESKTOP_VERSION |
213 | //US listen for arriving address resultsets | 233 | //US listen for arriving address resultsets |
214 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 234 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
215 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 235 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
216 | #endif | 236 | #endif |
217 | 237 | ||
218 | } | 238 | } |
219 | 239 | ||
220 | KOEditorDetails::~KOEditorDetails() | 240 | KOEditorDetails::~KOEditorDetails() |
221 | { | 241 | { |
222 | } | 242 | } |
223 | 243 | ||
224 | void KOEditorDetails::removeAttendee() | 244 | void KOEditorDetails::removeAttendee() |
225 | { | 245 | { |
226 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); | 246 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); |
227 | if (!aItem) return; | 247 | if (!aItem) return; |
228 | 248 | ||
229 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), | 249 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), |
230 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), | 250 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), |
231 | aItem->data()->uid()); | 251 | aItem->data()->uid()); |
232 | mdelAttendees.append(delA); | 252 | mdelAttendees.append(delA); |
233 | 253 | ||
234 | delete aItem; | 254 | delete aItem; |
235 | 255 | ||
236 | updateAttendeeInput(); | 256 | updateAttendeeInput(); |
237 | } | 257 | } |
238 | 258 | ||
239 | 259 | ||
240 | void KOEditorDetails::openAddressBook() | 260 | void KOEditorDetails::openAddressBook() |
241 | { | 261 | { |
242 | #ifndef KORG_NOKABC | 262 | #ifndef KORG_NOKABC |
243 | 263 | ||
244 | #ifdef DESKTOP_VERSION | 264 | #ifdef DESKTOP_VERSION |
245 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 265 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
246 | uint i=0; | 266 | uint i=0; |
247 | for (i=0; i < list.count(); i++) { | 267 | for (i=0; i < list.count(); i++) { |
248 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); | 268 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); |
249 | } | 269 | } |
250 | #else | 270 | #else |
251 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 271 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
252 | // the result should now arrive through method insertAttendees | 272 | // the result should now arrive through method insertAttendees |
253 | #endif | 273 | #endif |
254 | 274 | ||
255 | 275 | ||
256 | #if 0 | 276 | #if 0 |
257 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | 277 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); |
258 | if (!a.isEmpty()) { | 278 | if (!a.isEmpty()) { |
259 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); | 279 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); |
260 | } | 280 | } |
261 | #endif | 281 | #endif |
262 | #endif | 282 | #endif |
263 | } | 283 | } |
264 | 284 | ||
265 | 285 | ||
266 | void KOEditorDetails::addNewAttendee() | 286 | void KOEditorDetails::addNewAttendee() |
267 | { | 287 | { |
268 | #if 0 | 288 | #if 0 |
269 | // this is cool. If they didn't enter an email address, | 289 | // this is cool. If they didn't enter an email address, |
270 | // try to look it up in the address book and fill it in for them. | 290 | // try to look it up in the address book and fill it in for them. |
271 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { | 291 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { |
272 | KabAPI addrBook; | 292 | KabAPI addrBook; |
273 | QString name; | 293 | QString name; |
274 | std::list<AddressBook::Entry> entries; | 294 | std::list<AddressBook::Entry> entries; |
275 | name = mNameEdit->text(); | 295 | name = mNameEdit->text(); |
276 | if (addrBook.init() == AddressBook::NoError) { | 296 | if (addrBook.init() == AddressBook::NoError) { |
277 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { | 297 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { |
278 | kdDebug() << "positive match" << endl; | 298 | kdDebug() << "positive match" << endl; |
279 | // take first email address | 299 | // take first email address |
280 | if (!entries.front().emails.isEmpty() && | 300 | if (!entries.front().emails.isEmpty() && |
281 | entries.front().emails.first().length()>0) | 301 | entries.front().emails.first().length()>0) |
282 | mEmailEdit->setText(entries.front().emails.first()); | 302 | mEmailEdit->setText(entries.front().emails.first()); |
283 | } | 303 | } |
284 | } | 304 | } |
285 | } | 305 | } |
286 | #endif | 306 | #endif |
287 | 307 | ||
288 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); | 308 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); |
289 | insertAttendee(a); | 309 | insertAttendee(a); |
290 | } | 310 | } |
291 | 311 | ||
292 | //the map includes name/email pairs, that comes from Ka/Pi | 312 | //the map includes name/email pairs, that comes from Ka/Pi |
293 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 313 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
294 | { | 314 | { |
295 | if (uid == this->name()) | 315 | if (uid == this->name()) |
296 | { | 316 | { |
297 | for ( int i = 0; i < nameList.count(); i++) | 317 | for ( int i = 0; i < nameList.count(); i++) |
298 | { | 318 | { |
299 | QString _name = nameList[i]; | 319 | QString _name = nameList[i]; |
300 | QString _email = emailList[i]; | 320 | QString _email = emailList[i]; |
301 | QString _uid = uidList[i]; | 321 | QString _uid = uidList[i]; |
302 | 322 | ||
303 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); | 323 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); |
304 | insertAttendee(a); | 324 | insertAttendee(a); |
305 | } | 325 | } |
306 | } | 326 | } |
307 | 327 | ||
308 | } | 328 | } |
309 | 329 | ||
310 | void KOEditorDetails::insertAttendee(Attendee *a) | 330 | void KOEditorDetails::insertAttendee(Attendee *a) |
311 | { | 331 | { |
312 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); | 332 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); |
313 | while (first) { | 333 | while (first) { |
314 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) | 334 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) |
315 | return; | 335 | return; |
316 | first = (AttendeeListItem*) first->nextSibling(); | 336 | first = (AttendeeListItem*) first->nextSibling(); |
317 | } | 337 | } |
318 | 338 | ||
319 | AttendeeListItem *item = new AttendeeListItem(a,mListView); | 339 | AttendeeListItem *item = new AttendeeListItem(a,mListView); |
320 | mListView->setSelected( item, true ); | 340 | mListView->setSelected( item, true ); |
321 | } | 341 | } |
322 | 342 | ||
323 | void KOEditorDetails::setDefaults() | 343 | void KOEditorDetails::setDefaults() |
324 | { | 344 | { |
325 | mRsvpButton->setChecked(true); | 345 | mRsvpButton->setChecked(true); |
326 | mListView->clear(); | 346 | mListView->clear(); |
327 | mdelAttendees.clear(); | 347 | mdelAttendees.clear(); |
328 | clearAttendeeInput(); | 348 | clearAttendeeInput(); |
329 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); | 349 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); |
330 | 350 | ||
331 | mNameEdit->setText(""); | 351 | mNameEdit->setText(""); |
332 | mUidEdit->setText(""); | 352 | mUidEdit->setText(""); |
333 | mEmailEdit->setText(""); | 353 | mEmailEdit->setText(""); |
334 | mRoleCombo->setCurrentItem( 0 ); | 354 | mRoleCombo->setCurrentItem( 0 ); |
335 | mStatusCombo->setCurrentItem( 0 ); | 355 | mStatusCombo->setCurrentItem( 0 ); |
336 | 356 | ||
337 | } | 357 | } |
338 | 358 | ||
339 | void KOEditorDetails::readEvent(Incidence *event) | 359 | void KOEditorDetails::readEvent(Incidence *event) |
340 | { | 360 | { |
341 | setDefaults(); | 361 | setDefaults(); |
342 | //mListView->clear(); | 362 | //mListView->clear(); |
343 | //mdelAttendees.clear(); | 363 | //mdelAttendees.clear(); |
344 | QPtrList<Attendee> tmpAList = event->attendees(); | 364 | QPtrList<Attendee> tmpAList = event->attendees(); |
345 | Attendee *a; | 365 | Attendee *a; |
346 | for (a = tmpAList.first(); a; a = tmpAList.next()) | 366 | for (a = tmpAList.first(); a; a = tmpAList.next()) |
347 | insertAttendee(new Attendee(*a)); | 367 | insertAttendee(new Attendee(*a)); |
348 | 368 | ||
349 | mListView->setSelected( mListView->firstChild(), true ); | 369 | mListView->setSelected( mListView->firstChild(), true ); |
350 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); | 370 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); |
351 | } | 371 | } |
352 | 372 | ||
353 | void KOEditorDetails::writeEvent(Incidence *event) | 373 | void KOEditorDetails::writeEvent(Incidence *event) |
354 | { | 374 | { |
355 | event->clearAttendees(); | 375 | event->clearAttendees(); |
356 | QListViewItem *item; | 376 | QListViewItem *item; |
357 | AttendeeListItem *a; | 377 | AttendeeListItem *a; |
358 | for (item = mListView->firstChild(); item; | 378 | for (item = mListView->firstChild(); item; |
359 | item = item->nextSibling()) { | 379 | item = item->nextSibling()) { |
360 | a = (AttendeeListItem *)item; | 380 | a = (AttendeeListItem *)item; |
361 | event->addAttendee(new Attendee(*(a->data()))); | 381 | event->addAttendee(new Attendee(*(a->data()))); |
362 | } | 382 | } |
363 | event->setOrganizer(KOPrefs::instance()->email()); | 383 | event->setOrganizer(KOPrefs::instance()->email()); |
364 | } | 384 | } |
365 | 385 | ||
366 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) | 386 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) |
367 | { | 387 | { |
368 | event->clearAttendees(); | 388 | event->clearAttendees(); |
369 | Attendee * att; | 389 | Attendee * att; |
370 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { | 390 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { |
371 | event->addAttendee(new Attendee(*att)); | 391 | event->addAttendee(new Attendee(*att)); |
372 | } | 392 | } |
373 | mdelAttendees.clear(); | 393 | mdelAttendees.clear(); |
374 | } | 394 | } |
375 | 395 | ||
376 | bool KOEditorDetails::validateInput() | 396 | bool KOEditorDetails::validateInput() |
377 | { | 397 | { |
378 | return true; | 398 | return true; |
379 | } | 399 | } |
380 | 400 | ||
381 | void KOEditorDetails::updateAttendeeInput() | 401 | void KOEditorDetails::updateAttendeeInput() |