-rw-r--r-- | korganizer/koeditordetails.cpp | 7 | ||||
-rw-r--r-- | korganizer/kotodoeditor.cpp | 16 |
2 files changed, 12 insertions, 11 deletions
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp index ef8025b..2fd13bd 100644 --- a/korganizer/koeditordetails.cpp +++ b/korganizer/koeditordetails.cpp | |||
@@ -1,452 +1,453 @@ | |||
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 | mListView->setAllColumnsShowFocus (true ); | 93 | mListView->setAllColumnsShowFocus (true ); |
94 | //mListView->setSingleClick( true ); | 94 | //mListView->setSingleClick( true ); |
95 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), | 95 | connect(mListView,SIGNAL(selectionChanged(QListViewItem *)), |
96 | SLOT(updateAttendeeInput())); | 96 | SLOT(updateAttendeeInput())); |
97 | 97 | ||
98 | connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), | 98 | connect(mListView,SIGNAL(executed(QListViewItem * ,const QPoint&, int )), |
99 | SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); | 99 | SLOT(itemClicked(QListViewItem * ,const QPoint& , int ))); |
100 | 100 | ||
101 | mRsvpButton = new QCheckBox(this); | ||
102 | mRsvpButton->setText(i18n("Request response")); | ||
103 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); | ||
101 | QLabel *attendeeLabel = new QLabel(this); | 104 | QLabel *attendeeLabel = new QLabel(this); |
102 | attendeeLabel->setText(i18n("Name:")); | 105 | attendeeLabel->setText(i18n("Name:")); |
103 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); | 106 | attendeeLabel->setFixedSize( attendeeLabel->sizeHint() ); |
104 | mNameEdit = new QLineEdit(this); | 107 | mNameEdit = new QLineEdit(this); |
105 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), | 108 | connect(mNameEdit,SIGNAL(textChanged(const QString &)), |
106 | SLOT(updateAttendeeItem())); | 109 | SLOT(updateAttendeeItem())); |
107 | 110 | ||
108 | mUidEdit = new QLineEdit(0); | 111 | mUidEdit = new QLineEdit(0); |
109 | mUidEdit->setText(""); | 112 | mUidEdit->setText(""); |
110 | 113 | ||
111 | QLabel *emailLabel = new QLabel(this); | 114 | QLabel *emailLabel = new QLabel(this); |
112 | emailLabel->setText(i18n("Email:")); | 115 | emailLabel->setText(i18n("Email:")); |
113 | mEmailEdit = new QLineEdit(this); | 116 | mEmailEdit = new QLineEdit(this); |
114 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), | 117 | connect(mEmailEdit,SIGNAL(textChanged(const QString &)), |
115 | SLOT(updateAttendeeItem())); | 118 | SLOT(updateAttendeeItem())); |
116 | 119 | ||
117 | QLabel *attendeeRoleLabel = new QLabel(this); | 120 | QLabel *attendeeRoleLabel = new QLabel(this); |
118 | attendeeRoleLabel->setText(i18n("Role:")); | 121 | attendeeRoleLabel->setText(i18n("Role:")); |
119 | mRoleCombo = new QComboBox(false,this); | 122 | mRoleCombo = new QComboBox(false,this); |
120 | mRoleCombo->insertStringList(Attendee::roleList()); | 123 | mRoleCombo->insertStringList(Attendee::roleList()); |
121 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 124 | connect(mRoleCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
122 | 125 | ||
123 | QLabel *statusLabel = new QLabel(this); | 126 | QLabel *statusLabel = new QLabel(this); |
124 | statusLabel->setText( i18n("Status:") ); | 127 | statusLabel->setText( i18n("Status:") ); |
125 | 128 | ||
126 | mStatusCombo = new QComboBox(false,this); | 129 | mStatusCombo = new QComboBox(false,this); |
127 | mStatusCombo->insertStringList(Attendee::statusList()); | 130 | mStatusCombo->insertStringList(Attendee::statusList()); |
128 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); | 131 | connect(mStatusCombo,SIGNAL(activated(int)),SLOT(updateAttendeeItem())); |
129 | 132 | ||
130 | mRsvpButton = new QCheckBox(this); | 133 | |
131 | mRsvpButton->setText(i18n("Request response")); | ||
132 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); | 134 | connect(mRsvpButton,SIGNAL(clicked()),SLOT(updateAttendeeItem())); |
133 | QWidget *buttonBox = new QWidget(this); | 135 | QWidget *buttonBox = new QWidget(this); |
134 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); | 136 | QVBoxLayout *buttonLayout = new QVBoxLayout(buttonBox); |
135 | 137 | ||
136 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); | 138 | QPushButton *newButton = new QPushButton(i18n("&New"),buttonBox); |
137 | buttonLayout->addWidget(newButton); | 139 | buttonLayout->addWidget(newButton); |
138 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); | 140 | connect(newButton,SIGNAL(clicked()),SLOT(addNewAttendee())); |
139 | 141 | ||
140 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); | 142 | mRemoveButton = new QPushButton(i18n("&Remove"),buttonBox); |
141 | buttonLayout->addWidget(mRemoveButton); | 143 | buttonLayout->addWidget(mRemoveButton); |
142 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); | 144 | connect(mRemoveButton, SIGNAL(clicked()),SLOT(removeAttendee())); |
143 | 145 | ||
144 | mAddressBookButton = new QPushButton(i18n("Address &Book..."),this); | ||
145 | // buttonLayout->addWidget(mAddressBookButton); | 146 | // buttonLayout->addWidget(mAddressBookButton); |
146 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); | 147 | connect(mAddressBookButton,SIGNAL(clicked()),SLOT(openAddressBook())); |
147 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); | 148 | //mRoleCombo->setFixedSize( mRoleCombo->sizeHint () ); |
148 | 149 | ||
149 | if (qApp->desktop()->width() < 640 ) { | 150 | if (qApp->desktop()->width() < 640 ) { |
150 | if ( qApp->desktop()->width() < 300 ) | 151 | if ( qApp->desktop()->width() < 300 ) |
151 | topLayout->setSpacing(1); | 152 | topLayout->setSpacing(1); |
152 | ;//mListView->setFixedHeight(80); | 153 | ;//mListView->setFixedHeight(80); |
153 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); | 154 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,3); |
154 | topLayout->addMultiCellWidget(mListView,1,1,0,3); | 155 | topLayout->addMultiCellWidget(mListView,1,1,0,3); |
155 | topLayout->addWidget(attendeeLabel,3,0); | 156 | topLayout->addWidget(attendeeLabel,3,0); |
156 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); | 157 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,2); |
157 | topLayout->addWidget(emailLabel,4,0); | 158 | topLayout->addWidget(emailLabel,4,0); |
158 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); | 159 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,2); |
159 | topLayout->addWidget(attendeeRoleLabel,5,0); | 160 | topLayout->addWidget(attendeeRoleLabel,5,0); |
160 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); | 161 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,3); |
161 | topLayout->addWidget(statusLabel,6,0); | 162 | topLayout->addWidget(statusLabel,6,0); |
162 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); | 163 | topLayout->addMultiCellWidget(mStatusCombo,6,6,1,3); |
163 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); | 164 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,2,3); |
164 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 165 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
165 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); | 166 | topLayout->addMultiCellWidget(buttonBox,3,4,3,3); |
166 | topLayout->setRowStretch(1,2); | 167 | topLayout->setRowStretch(1,2); |
167 | topLayout->setColStretch(0,0); | 168 | topLayout->setColStretch(0,0); |
168 | topLayout->setColStretch(1,2); | 169 | topLayout->setColStretch(1,2); |
169 | topLayout->setColStretch(2,1); | 170 | topLayout->setColStretch(2,1); |
170 | topLayout->setColStretch(3,1); | 171 | topLayout->setColStretch(3,1); |
171 | 172 | ||
172 | } else { | 173 | } else { |
173 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); | 174 | topLayout->addMultiCellWidget(mOrganizerLabel,0,0,0,5); |
174 | topLayout->addMultiCellWidget(mListView,1,1,0,5); | 175 | topLayout->addMultiCellWidget(mListView,1,1,0,5); |
175 | topLayout->addWidget(attendeeLabel,3,0); | 176 | topLayout->addWidget(attendeeLabel,3,0); |
176 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); | 177 | topLayout->addMultiCellWidget(mNameEdit,3,3,1,4); |
177 | topLayout->addWidget(emailLabel,4,0); | 178 | topLayout->addWidget(emailLabel,4,0); |
178 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); | 179 | topLayout->addMultiCellWidget(mEmailEdit,4,4,1,4); |
179 | topLayout->addWidget(attendeeRoleLabel,5,0); | 180 | topLayout->addWidget(attendeeRoleLabel,5,0); |
180 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); | 181 | topLayout->addMultiCellWidget(mRoleCombo,5,5,1,2); |
181 | topLayout->addWidget(statusLabel,5,3); | 182 | topLayout->addWidget(statusLabel,5,3); |
182 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); | 183 | topLayout->addMultiCellWidget(mStatusCombo,5,5,4,5); |
183 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); | 184 | topLayout->addMultiCellWidget(mAddressBookButton,2,2,4,5); |
184 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); | 185 | topLayout->addMultiCellWidget(mRsvpButton,2,2,0,1); |
185 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); | 186 | topLayout->addMultiCellWidget(buttonBox,3,4,5,5); |
186 | topLayout->setRowStretch(1,5); | 187 | topLayout->setRowStretch(1,5); |
187 | topLayout->setColStretch(0,0); | 188 | topLayout->setColStretch(0,0); |
188 | } | 189 | } |
189 | // #if 0 | 190 | // #if 0 |
190 | // topLayout->setColStretch(2,1); | 191 | // topLayout->setColStretch(2,1); |
191 | // topLayout->addWidget(statusLabel,3,3); | 192 | // topLayout->addWidget(statusLabel,3,3); |
192 | // topLayout->addWidget(mStatusCombo,3,4); | 193 | // topLayout->addWidget(mStatusCombo,3,4); |
193 | // #else | 194 | // #else |
194 | // topLayout->addWidget(statusLabel,4,3); | 195 | // topLayout->addWidget(statusLabel,4,3); |
195 | // // topLayout->addWidget(mStatusCombo,4,3); | 196 | // // topLayout->addWidget(mStatusCombo,4,3); |
196 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); | 197 | // topLayout->addMultiCellWidget(mStatusCombo,4,4,4,5); |
197 | 198 | ||
198 | // #endif | 199 | // #endif |
199 | // // topLayout->setRowStretch(5,1); | 200 | // // topLayout->setRowStretch(5,1); |
200 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); | 201 | // topLayout->addMultiCellWidget(mRsvpButton,5,5,0,1); |
201 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); | 202 | // topLayout->addMultiCellWidget(buttonBox,2,3,5,5); |
202 | // topLayout->setRowStretch(1,5); | 203 | // topLayout->setRowStretch(1,5); |
203 | // topLayout->setColStretch(0,0); | 204 | // topLayout->setColStretch(0,0); |
204 | 205 | ||
205 | #ifdef KORG_NOKABC | 206 | #ifdef KORG_NOKABC |
206 | mAddressBookButton->hide(); | 207 | mAddressBookButton->hide(); |
207 | #endif | 208 | #endif |
208 | 209 | ||
209 | updateAttendeeInput(); | 210 | updateAttendeeInput(); |
210 | #ifndef DESKTOP_VERSION | 211 | #ifndef DESKTOP_VERSION |
211 | //US listen for arriving address resultsets | 212 | //US listen for arriving address resultsets |
212 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 213 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
213 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 214 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
214 | #endif | 215 | #endif |
215 | 216 | ||
216 | } | 217 | } |
217 | 218 | ||
218 | KOEditorDetails::~KOEditorDetails() | 219 | KOEditorDetails::~KOEditorDetails() |
219 | { | 220 | { |
220 | } | 221 | } |
221 | 222 | ||
222 | void KOEditorDetails::removeAttendee() | 223 | void KOEditorDetails::removeAttendee() |
223 | { | 224 | { |
224 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); | 225 | AttendeeListItem *aItem = (AttendeeListItem *)mListView->selectedItem(); |
225 | if (!aItem) return; | 226 | if (!aItem) return; |
226 | 227 | ||
227 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), | 228 | Attendee *delA = new Attendee(aItem->data()->name(),aItem->data()->email(), |
228 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), | 229 | aItem->data()->RSVP(),aItem->data()->status(),aItem->data()->role(), |
229 | aItem->data()->uid()); | 230 | aItem->data()->uid()); |
230 | mdelAttendees.append(delA); | 231 | mdelAttendees.append(delA); |
231 | 232 | ||
232 | delete aItem; | 233 | delete aItem; |
233 | 234 | ||
234 | updateAttendeeInput(); | 235 | updateAttendeeInput(); |
235 | } | 236 | } |
236 | 237 | ||
237 | 238 | ||
238 | void KOEditorDetails::openAddressBook() | 239 | void KOEditorDetails::openAddressBook() |
239 | { | 240 | { |
240 | #ifndef KORG_NOKABC | 241 | #ifndef KORG_NOKABC |
241 | 242 | ||
242 | #ifdef DESKTOP_VERSION | 243 | #ifdef DESKTOP_VERSION |
243 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); | 244 | KABC::Addressee::List list = KABC::AddresseeDialog::getAddressees(this); |
244 | uint i=0; | 245 | uint i=0; |
245 | for (i=0; i < list.count(); i++) { | 246 | for (i=0; i < list.count(); i++) { |
246 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); | 247 | insertAttendee( new Attendee( list[i].realName(), list[i].preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,list[i].uid()) ); |
247 | } | 248 | } |
248 | #else | 249 | #else |
249 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); | 250 | bool res = ExternalAppHandler::instance()->requestNameEmailUidListFromKAPI("QPE/Application/kopi", this->name() /* name is here the unique uid*/); |
250 | // the result should now arrive through method insertAttendees | 251 | // the result should now arrive through method insertAttendees |
251 | #endif | 252 | #endif |
252 | 253 | ||
253 | 254 | ||
254 | #if 0 | 255 | #if 0 |
255 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); | 256 | KABC::Addressee a = KABC::AddresseeDialog::getAddressee(this); |
256 | if (!a.isEmpty()) { | 257 | if (!a.isEmpty()) { |
257 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); | 258 | insertAttendee( new Attendee( a.realName(), a.preferredEmail(),false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant,a.uid()) ); |
258 | } | 259 | } |
259 | #endif | 260 | #endif |
260 | #endif | 261 | #endif |
261 | } | 262 | } |
262 | 263 | ||
263 | 264 | ||
264 | void KOEditorDetails::addNewAttendee() | 265 | void KOEditorDetails::addNewAttendee() |
265 | { | 266 | { |
266 | #if 0 | 267 | #if 0 |
267 | // this is cool. If they didn't enter an email address, | 268 | // this is cool. If they didn't enter an email address, |
268 | // try to look it up in the address book and fill it in for them. | 269 | // try to look it up in the address book and fill it in for them. |
269 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { | 270 | if (QString(mEmailEdit->text()).stripWhiteSpace().isEmpty()) { |
270 | KabAPI addrBook; | 271 | KabAPI addrBook; |
271 | QString name; | 272 | QString name; |
272 | std::list<AddressBook::Entry> entries; | 273 | std::list<AddressBook::Entry> entries; |
273 | name = mNameEdit->text(); | 274 | name = mNameEdit->text(); |
274 | if (addrBook.init() == AddressBook::NoError) { | 275 | if (addrBook.init() == AddressBook::NoError) { |
275 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { | 276 | if (addrBook.getEntryByName(name, entries, 1) == AddressBook::NoError) { |
276 | kdDebug() << "positive match" << endl; | 277 | kdDebug() << "positive match" << endl; |
277 | // take first email address | 278 | // take first email address |
278 | if (!entries.front().emails.isEmpty() && | 279 | if (!entries.front().emails.isEmpty() && |
279 | entries.front().emails.first().length()>0) | 280 | entries.front().emails.first().length()>0) |
280 | mEmailEdit->setText(entries.front().emails.first()); | 281 | mEmailEdit->setText(entries.front().emails.first()); |
281 | } | 282 | } |
282 | } | 283 | } |
283 | } | 284 | } |
284 | #endif | 285 | #endif |
285 | 286 | ||
286 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); | 287 | Attendee *a = new Attendee(i18n("(EmptyName)"),i18n("(EmptyEmail)")); |
287 | insertAttendee(a); | 288 | insertAttendee(a); |
288 | } | 289 | } |
289 | 290 | ||
290 | //the map includes name/email pairs, that comes from Ka/Pi | 291 | //the map includes name/email pairs, that comes from Ka/Pi |
291 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) | 292 | void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) |
292 | { | 293 | { |
293 | if (uid == this->name()) | 294 | if (uid == this->name()) |
294 | { | 295 | { |
295 | for ( int i = 0; i < nameList.count(); i++) | 296 | for ( int i = 0; i < nameList.count(); i++) |
296 | { | 297 | { |
297 | QString _name = nameList[i]; | 298 | QString _name = nameList[i]; |
298 | QString _email = emailList[i]; | 299 | QString _email = emailList[i]; |
299 | QString _uid = uidList[i]; | 300 | QString _uid = uidList[i]; |
300 | 301 | ||
301 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); | 302 | Attendee *a = new Attendee(_name,_email,false,KCal::Attendee::NeedsAction,KCal::Attendee::ReqParticipant, _uid); |
302 | insertAttendee(a); | 303 | insertAttendee(a); |
303 | } | 304 | } |
304 | } | 305 | } |
305 | 306 | ||
306 | } | 307 | } |
307 | 308 | ||
308 | void KOEditorDetails::insertAttendee(Attendee *a) | 309 | void KOEditorDetails::insertAttendee(Attendee *a) |
309 | { | 310 | { |
310 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); | 311 | AttendeeListItem *first = (AttendeeListItem*) mListView->firstChild(); |
311 | while (first) { | 312 | while (first) { |
312 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) | 313 | if ( first->data()->name() == a->name() && first->data()->email() == a->email() ) |
313 | return; | 314 | return; |
314 | first = (AttendeeListItem*) first->nextSibling(); | 315 | first = (AttendeeListItem*) first->nextSibling(); |
315 | } | 316 | } |
316 | 317 | ||
317 | AttendeeListItem *item = new AttendeeListItem(a,mListView); | 318 | AttendeeListItem *item = new AttendeeListItem(a,mListView); |
318 | mListView->setSelected( item, true ); | 319 | mListView->setSelected( item, true ); |
319 | } | 320 | } |
320 | 321 | ||
321 | void KOEditorDetails::setDefaults() | 322 | void KOEditorDetails::setDefaults() |
322 | { | 323 | { |
323 | mRsvpButton->setChecked(true); | 324 | mRsvpButton->setChecked(true); |
324 | mListView->clear(); | 325 | mListView->clear(); |
325 | mdelAttendees.clear(); | 326 | mdelAttendees.clear(); |
326 | clearAttendeeInput(); | 327 | clearAttendeeInput(); |
327 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); | 328 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(KOPrefs::instance()->email())); |
328 | 329 | ||
329 | mNameEdit->setText(""); | 330 | mNameEdit->setText(""); |
330 | mUidEdit->setText(""); | 331 | mUidEdit->setText(""); |
331 | mEmailEdit->setText(""); | 332 | mEmailEdit->setText(""); |
332 | mRoleCombo->setCurrentItem( 0 ); | 333 | mRoleCombo->setCurrentItem( 0 ); |
333 | mStatusCombo->setCurrentItem( 0 ); | 334 | mStatusCombo->setCurrentItem( 0 ); |
334 | 335 | ||
335 | } | 336 | } |
336 | 337 | ||
337 | void KOEditorDetails::readEvent(Incidence *event) | 338 | void KOEditorDetails::readEvent(Incidence *event) |
338 | { | 339 | { |
339 | setDefaults(); | 340 | setDefaults(); |
340 | //mListView->clear(); | 341 | //mListView->clear(); |
341 | //mdelAttendees.clear(); | 342 | //mdelAttendees.clear(); |
342 | QPtrList<Attendee> tmpAList = event->attendees(); | 343 | QPtrList<Attendee> tmpAList = event->attendees(); |
343 | Attendee *a; | 344 | Attendee *a; |
344 | for (a = tmpAList.first(); a; a = tmpAList.next()) | 345 | for (a = tmpAList.first(); a; a = tmpAList.next()) |
345 | insertAttendee(new Attendee(*a)); | 346 | insertAttendee(new Attendee(*a)); |
346 | 347 | ||
347 | mListView->setSelected( mListView->firstChild(), true ); | 348 | mListView->setSelected( mListView->firstChild(), true ); |
348 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); | 349 | mOrganizerLabel->setText(i18n("Organizer: %1").arg(event->organizer())); |
349 | } | 350 | } |
350 | 351 | ||
351 | void KOEditorDetails::writeEvent(Incidence *event) | 352 | void KOEditorDetails::writeEvent(Incidence *event) |
352 | { | 353 | { |
353 | event->clearAttendees(); | 354 | event->clearAttendees(); |
354 | QListViewItem *item; | 355 | QListViewItem *item; |
355 | AttendeeListItem *a; | 356 | AttendeeListItem *a; |
356 | for (item = mListView->firstChild(); item; | 357 | for (item = mListView->firstChild(); item; |
357 | item = item->nextSibling()) { | 358 | item = item->nextSibling()) { |
358 | a = (AttendeeListItem *)item; | 359 | a = (AttendeeListItem *)item; |
359 | event->addAttendee(new Attendee(*(a->data()))); | 360 | event->addAttendee(new Attendee(*(a->data()))); |
360 | } | 361 | } |
361 | event->setOrganizer(KOPrefs::instance()->email()); | 362 | event->setOrganizer(KOPrefs::instance()->email()); |
362 | } | 363 | } |
363 | 364 | ||
364 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) | 365 | void KOEditorDetails::cancelAttendeeEvent(Incidence *event) |
365 | { | 366 | { |
366 | event->clearAttendees(); | 367 | event->clearAttendees(); |
367 | Attendee * att; | 368 | Attendee * att; |
368 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { | 369 | for (att=mdelAttendees.first();att;att=mdelAttendees.next()) { |
369 | event->addAttendee(new Attendee(*att)); | 370 | event->addAttendee(new Attendee(*att)); |
370 | } | 371 | } |
371 | mdelAttendees.clear(); | 372 | mdelAttendees.clear(); |
372 | } | 373 | } |
373 | 374 | ||
374 | bool KOEditorDetails::validateInput() | 375 | bool KOEditorDetails::validateInput() |
375 | { | 376 | { |
376 | return true; | 377 | return true; |
377 | } | 378 | } |
378 | 379 | ||
379 | void KOEditorDetails::updateAttendeeInput() | 380 | void KOEditorDetails::updateAttendeeInput() |
380 | { | 381 | { |
381 | QListViewItem *item = mListView->selectedItem(); | 382 | QListViewItem *item = mListView->selectedItem(); |
382 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 383 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
383 | if (aItem) { | 384 | if (aItem) { |
384 | fillAttendeeInput( aItem ); | 385 | fillAttendeeInput( aItem ); |
385 | } else { | 386 | } else { |
386 | clearAttendeeInput(); | 387 | clearAttendeeInput(); |
387 | } | 388 | } |
388 | } | 389 | } |
389 | 390 | ||
390 | void KOEditorDetails::clearAttendeeInput() | 391 | void KOEditorDetails::clearAttendeeInput() |
391 | { | 392 | { |
392 | mNameEdit->setText(""); | 393 | mNameEdit->setText(""); |
393 | mUidEdit->setText(""); | 394 | mUidEdit->setText(""); |
394 | mEmailEdit->setText(""); | 395 | mEmailEdit->setText(""); |
395 | mRoleCombo->setCurrentItem(0); | 396 | mRoleCombo->setCurrentItem(0); |
396 | mStatusCombo->setCurrentItem(0); | 397 | mStatusCombo->setCurrentItem(0); |
397 | mRsvpButton->setChecked(true); | 398 | mRsvpButton->setChecked(true); |
398 | setEnabledAttendeeInput( false ); | 399 | setEnabledAttendeeInput( false ); |
399 | } | 400 | } |
400 | 401 | ||
401 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) | 402 | void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) |
402 | { | 403 | { |
403 | Attendee *a = aItem->data(); | 404 | Attendee *a = aItem->data(); |
404 | mDisableItemUpdate = true; | 405 | mDisableItemUpdate = true; |
405 | mNameEdit->setText(a->name()); | 406 | mNameEdit->setText(a->name()); |
406 | mUidEdit->setText(a->uid()); | 407 | mUidEdit->setText(a->uid()); |
407 | mEmailEdit->setText(a->email()); | 408 | mEmailEdit->setText(a->email()); |
408 | mRoleCombo->setCurrentItem(a->role()); | 409 | mRoleCombo->setCurrentItem(a->role()); |
409 | mStatusCombo->setCurrentItem(a->status()); | 410 | mStatusCombo->setCurrentItem(a->status()); |
410 | mRsvpButton->setChecked(a->RSVP()); | 411 | mRsvpButton->setChecked(a->RSVP()); |
411 | 412 | ||
412 | mDisableItemUpdate = false; | 413 | mDisableItemUpdate = false; |
413 | 414 | ||
414 | setEnabledAttendeeInput( true ); | 415 | setEnabledAttendeeInput( true ); |
415 | } | 416 | } |
416 | 417 | ||
417 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) | 418 | void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) |
418 | { | 419 | { |
419 | mNameEdit->setEnabled( enabled ); | 420 | mNameEdit->setEnabled( enabled ); |
420 | mEmailEdit->setEnabled( enabled ); | 421 | mEmailEdit->setEnabled( enabled ); |
421 | mRoleCombo->setEnabled( enabled ); | 422 | mRoleCombo->setEnabled( enabled ); |
422 | mStatusCombo->setEnabled( enabled ); | 423 | mStatusCombo->setEnabled( enabled ); |
423 | mRsvpButton->setEnabled( enabled ); | 424 | mRsvpButton->setEnabled( enabled ); |
424 | 425 | ||
425 | mRemoveButton->setEnabled( enabled ); | 426 | mRemoveButton->setEnabled( enabled ); |
426 | } | 427 | } |
427 | 428 | ||
428 | void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) | 429 | void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) |
429 | { | 430 | { |
430 | if ( item && c == 4 ) { | 431 | if ( item && c == 4 ) { |
431 | mRsvpButton->setChecked( !mRsvpButton->isChecked() ); | 432 | mRsvpButton->setChecked( !mRsvpButton->isChecked() ); |
432 | updateAttendeeItem(); | 433 | updateAttendeeItem(); |
433 | } | 434 | } |
434 | } | 435 | } |
435 | void KOEditorDetails::updateAttendeeItem() | 436 | void KOEditorDetails::updateAttendeeItem() |
436 | { | 437 | { |
437 | if (mDisableItemUpdate) return; | 438 | if (mDisableItemUpdate) return; |
438 | 439 | ||
439 | QListViewItem *item = mListView->selectedItem(); | 440 | QListViewItem *item = mListView->selectedItem(); |
440 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); | 441 | AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); |
441 | if ( !aItem ) return; | 442 | if ( !aItem ) return; |
442 | 443 | ||
443 | Attendee *a = aItem->data(); | 444 | Attendee *a = aItem->data(); |
444 | 445 | ||
445 | a->setName( mNameEdit->text() ); | 446 | a->setName( mNameEdit->text() ); |
446 | a->setUid( mUidEdit->text() ); | 447 | a->setUid( mUidEdit->text() ); |
447 | a->setEmail( mEmailEdit->text() ); | 448 | a->setEmail( mEmailEdit->text() ); |
448 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); | 449 | a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); |
449 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); | 450 | a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); |
450 | a->setRSVP( mRsvpButton->isChecked() ); | 451 | a->setRSVP( mRsvpButton->isChecked() ); |
451 | aItem->updateItem(); | 452 | aItem->updateItem(); |
452 | } | 453 | } |
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp index 9232e09..f9f037a 100644 --- a/korganizer/kotodoeditor.cpp +++ b/korganizer/kotodoeditor.cpp | |||
@@ -1,455 +1,455 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 1997, 1998 Preston Brown | 3 | Copyright (c) 1997, 1998 Preston Brown |
4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This program is free software; you can redistribute it and/or modify | 6 | This program is free software; you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by | 7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation; either version 2 of the License, or | 8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | 9 | (at your option) any later version. |
10 | 10 | ||
11 | This program is distributed in the hope that it will be useful, | 11 | This program is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. | 14 | GNU General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU General Public License | 16 | You should have received a copy of the GNU General Public License |
17 | along with this program; if not, write to the Free Software | 17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 18 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
19 | 19 | ||
20 | As a special exception, permission is given to link this program | 20 | As a special exception, permission is given to link this program |
21 | with any edition of Qt, and distribute the resulting executable, | 21 | with any edition of Qt, and distribute the resulting executable, |
22 | without including the source code for Qt in the source distribution. | 22 | without including the source code for Qt in the source distribution. |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include <qtooltip.h> | 25 | #include <qtooltip.h> |
26 | #include <qframe.h> | 26 | #include <qframe.h> |
27 | #include <qpixmap.h> | 27 | #include <qpixmap.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qhbox.h> | 29 | #include <qhbox.h> |
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qdatetime.h> | 31 | #include <qdatetime.h> |
32 | #include <qapplication.h> | 32 | #include <qapplication.h> |
33 | #include <qtabwidget.h> | 33 | #include <qtabwidget.h> |
34 | 34 | ||
35 | #include <kiconloader.h> | 35 | #include <kiconloader.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kfiledialog.h> | 37 | #include <kfiledialog.h> |
38 | #include <kstandarddirs.h> | 38 | #include <kstandarddirs.h> |
39 | #include <kmessagebox.h> | 39 | #include <kmessagebox.h> |
40 | 40 | ||
41 | #include <libkdepim/categoryselectdialog.h> | 41 | #include <libkdepim/categoryselectdialog.h> |
42 | #include <libkcal/calendarlocal.h> | 42 | #include <libkcal/calendarlocal.h> |
43 | #include <libkcal/calendarresources.h> | 43 | #include <libkcal/calendarresources.h> |
44 | #include <libkcal/resourcecalendar.h> | 44 | #include <libkcal/resourcecalendar.h> |
45 | #include <libkcal/icalformat.h> | 45 | #include <libkcal/icalformat.h> |
46 | #include <kresources/resourceselectdialog.h> | 46 | #include <kresources/resourceselectdialog.h> |
47 | #include <libkdepim/kdateedit.h> | 47 | #include <libkdepim/kdateedit.h> |
48 | 48 | ||
49 | #include "koprefs.h" | 49 | #include "koprefs.h" |
50 | #include "kolocationbox.h" | 50 | #include "kolocationbox.h" |
51 | 51 | ||
52 | #include "kotodoeditor.h" | 52 | #include "kotodoeditor.h" |
53 | extern int globalFlagBlockAgenda; | 53 | extern int globalFlagBlockAgenda; |
54 | 54 | ||
55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : | 55 | KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : |
56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) | 56 | KOIncidenceEditor( i18n("Edit To-Do"), calendar, parent ) |
57 | { | 57 | { |
58 | mTodo = 0; | 58 | mTodo = 0; |
59 | mRelatedTodo = 0; | 59 | mRelatedTodo = 0; |
60 | findButton(User1)->hide(); | 60 | findButton(User1)->hide(); |
61 | init(); | 61 | init(); |
62 | } | 62 | } |
63 | 63 | ||
64 | KOTodoEditor::~KOTodoEditor() | 64 | KOTodoEditor::~KOTodoEditor() |
65 | { | 65 | { |
66 | emit dialogClose( mTodo ); | 66 | emit dialogClose( mTodo ); |
67 | } | 67 | } |
68 | 68 | ||
69 | void KOTodoEditor::init() | 69 | void KOTodoEditor::init() |
70 | { | 70 | { |
71 | setupGeneral(); | 71 | setupGeneral(); |
72 | setupAttendeesTab(); | 72 | setupAttendeesTab(); |
73 | setupRecurrence(); | 73 | setupRecurrence(); |
74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); | 74 | connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); |
75 | } | 75 | } |
76 | void KOTodoEditor::setupRecurrence() | 76 | void KOTodoEditor::setupRecurrence() |
77 | { | 77 | { |
78 | QFrame *topFrame = addPage( i18n("Recurrence") ); | 78 | QFrame *topFrame = addPage( i18n("Recurrence") ); |
79 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); | 79 | QBoxLayout *topLayout = new QVBoxLayout( topFrame ); |
80 | 80 | ||
81 | mRecurrence = new KOEditorRecurrence( topFrame ); | 81 | mRecurrence = new KOEditorRecurrence( topFrame ); |
82 | topLayout->addWidget( mRecurrence ); | 82 | topLayout->addWidget( mRecurrence ); |
83 | } | 83 | } |
84 | 84 | ||
85 | void KOTodoEditor::setCategories( QString s ) | 85 | void KOTodoEditor::setCategories( QString s ) |
86 | { | 86 | { |
87 | mGeneral->setCategories(s); | 87 | mGeneral->setCategories(s); |
88 | } | 88 | } |
89 | void KOTodoEditor::setSecrecy( int sec ) | 89 | void KOTodoEditor::setSecrecy( int sec ) |
90 | { | 90 | { |
91 | mGeneral->setSecrecy( sec ); | 91 | mGeneral->setSecrecy( sec ); |
92 | } | 92 | } |
93 | void KOTodoEditor::reload() | 93 | void KOTodoEditor::reload() |
94 | { | 94 | { |
95 | if ( mTodo ) readTodo( mTodo ); | 95 | if ( mTodo ) readTodo( mTodo ); |
96 | } | 96 | } |
97 | 97 | ||
98 | void KOTodoEditor::setupGeneral() | 98 | void KOTodoEditor::setupGeneral() |
99 | { | 99 | { |
100 | mGeneral = new KOEditorGeneralTodo(this); | 100 | mGeneral = new KOEditorGeneralTodo(this); |
101 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); | 101 | connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); |
102 | 102 | ||
103 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); | 103 | // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); |
104 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), | 104 | //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), |
105 | // mGeneral,SLOT(setCategories(const QString &))); | 105 | // mGeneral,SLOT(setCategories(const QString &))); |
106 | 106 | ||
107 | if (KOPrefs::instance()->mCompactDialogs) { | 107 | if (KOPrefs::instance()->mCompactDialogs) { |
108 | QFrame *topFrame = addPage(i18n("General")); | 108 | QFrame *topFrame = addPage(i18n("General")); |
109 | 109 | ||
110 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 110 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
111 | if ( QApplication::desktop()->width() < 480 ) { | 111 | if ( QApplication::desktop()->width() < 480 ) { |
112 | topLayout->setMargin(1); | 112 | topLayout->setMargin(1); |
113 | topLayout->setSpacing(1); | 113 | topLayout->setSpacing(1); |
114 | } else { | 114 | } else { |
115 | topLayout->setMargin(marginHint()-1); | 115 | topLayout->setMargin(marginHint()-1); |
116 | topLayout->setSpacing(spacingHint()-1); | 116 | topLayout->setSpacing(spacingHint()-1); |
117 | } | 117 | } |
118 | mGeneral->initHeader(topFrame,topLayout); | 118 | mGeneral->initHeader(topFrame,topLayout); |
119 | mGeneral->initTime(topFrame,topLayout); | 119 | mGeneral->initTime(topFrame,topLayout); |
120 | mGeneral->initAlarm(topFrame,topLayout); | 120 | mGeneral->initAlarm(topFrame,topLayout); |
121 | mGeneral->enableAlarm( false ); | 121 | mGeneral->enableAlarm( false ); |
122 | 122 | ||
123 | 123 | ||
124 | QBoxLayout *priorityLayout; | 124 | QBoxLayout *priorityLayout; |
125 | if ( QApplication::desktop()->width() < 500 ) | 125 | if ( QApplication::desktop()->width() < 500 ) |
126 | priorityLayout = new QVBoxLayout( topLayout ); | 126 | priorityLayout = new QVBoxLayout( topLayout ); |
127 | else | 127 | else |
128 | priorityLayout = new QHBoxLayout( topLayout ); | 128 | priorityLayout = new QHBoxLayout( topLayout ); |
129 | QWidget* prioWidget = new QWidget (topFrame); | 129 | QWidget* prioWidget = new QWidget (topFrame); |
130 | priorityLayout->addWidget( prioWidget ); | 130 | priorityLayout->addWidget( prioWidget ); |
131 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); | 131 | QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); |
132 | 132 | ||
133 | 133 | ||
134 | QIconSet icon; | 134 | QIconSet icon; |
135 | if ( QApplication::desktop()->width() < 321 ) | 135 | if ( QApplication::desktop()->width() < 321 ) |
136 | icon = SmallIcon("fileexport16"); | ||
137 | else | ||
138 | icon = SmallIcon("fileexport"); | ||
139 | QPushButton * saveTemplate = new QPushButton( prioWidget); | ||
140 | saveTemplate->setIconSet (icon ) ; | ||
141 | int size = saveTemplate->sizeHint().height(); | ||
142 | saveTemplate->setFixedSize( size, size ); | ||
143 | if ( QApplication::desktop()->width() < 321 ) | ||
144 | icon = SmallIcon("fileimport16"); | 136 | icon = SmallIcon("fileimport16"); |
145 | else | 137 | else |
146 | icon = SmallIcon("fileimport"); | 138 | icon = SmallIcon("fileimport"); |
147 | QPushButton * loadTemplate = new QPushButton( prioWidget); | 139 | QPushButton * loadTemplate = new QPushButton( prioWidget); |
148 | loadTemplate->setIconSet (icon ) ; | 140 | loadTemplate->setIconSet (icon ) ; |
141 | int size = loadTemplate->sizeHint().height(); | ||
149 | loadTemplate->setFixedSize( size, size ); | 142 | loadTemplate->setFixedSize( size, size ); |
143 | if ( QApplication::desktop()->width() < 321 ) | ||
144 | icon = SmallIcon("fileexport16"); | ||
145 | else | ||
146 | icon = SmallIcon("fileexport"); | ||
147 | QPushButton * saveTemplate = new QPushButton( prioWidget); | ||
148 | saveTemplate->setIconSet (icon ) ; | ||
149 | saveTemplate->setFixedSize( size, size ); | ||
150 | 150 | ||
151 | priorityLayout2->addWidget(loadTemplate); | 151 | priorityLayout2->addWidget(loadTemplate); |
152 | priorityLayout2->addWidget(saveTemplate); | 152 | priorityLayout2->addWidget(saveTemplate); |
153 | mGeneral->initPriority(prioWidget,priorityLayout2); | 153 | mGeneral->initPriority(prioWidget,priorityLayout2); |
154 | mGeneral->initCategories( topFrame, priorityLayout ); | 154 | mGeneral->initCategories( topFrame, priorityLayout ); |
155 | topLayout->addStretch(1); | 155 | topLayout->addStretch(1); |
156 | 156 | ||
157 | QFrame *topFrame2 = addPage(i18n("Details")); | 157 | QFrame *topFrame2 = addPage(i18n("Details")); |
158 | 158 | ||
159 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); | 159 | QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); |
160 | topLayout2->setMargin(marginHint()); | 160 | topLayout2->setMargin(marginHint()); |
161 | topLayout2->setSpacing(spacingHint()); | 161 | topLayout2->setSpacing(spacingHint()); |
162 | 162 | ||
163 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); | 163 | QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); |
164 | mGeneral->initCompletion(topFrame2,completionLayout); | 164 | mGeneral->initCompletion(topFrame2,completionLayout); |
165 | 165 | ||
166 | 166 | ||
167 | mGeneral->initSecrecy( topFrame2, topLayout2 ); | 167 | mGeneral->initSecrecy( topFrame2, topLayout2 ); |
168 | mGeneral->initDescription(topFrame2,topLayout2); | 168 | mGeneral->initDescription(topFrame2,topLayout2); |
169 | 169 | ||
170 | // QHBox * hb = new QHBox ( topFrame2 ); | 170 | // QHBox * hb = new QHBox ( topFrame2 ); |
171 | // topLayout2->addWidget(hb); | 171 | // topLayout2->addWidget(hb); |
172 | // hb->setSpacing( 3 ); | 172 | // hb->setSpacing( 3 ); |
173 | 173 | ||
174 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 174 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
175 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 175 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
176 | 176 | ||
177 | } else { | 177 | } else { |
178 | QFrame *topFrame = addPage(i18n("General")); | 178 | QFrame *topFrame = addPage(i18n("General")); |
179 | 179 | ||
180 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); | 180 | QBoxLayout *topLayout = new QVBoxLayout(topFrame); |
181 | topLayout->setSpacing(spacingHint()); | 181 | topLayout->setSpacing(spacingHint()); |
182 | 182 | ||
183 | mGeneral->initHeader(topFrame,topLayout); | 183 | mGeneral->initHeader(topFrame,topLayout); |
184 | mGeneral->initTime(topFrame,topLayout); | 184 | mGeneral->initTime(topFrame,topLayout); |
185 | mGeneral->initStatus(topFrame,topLayout); | 185 | mGeneral->initStatus(topFrame,topLayout); |
186 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); | 186 | QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); |
187 | mGeneral->initAlarm(topFrame,alarmLineLayout); | 187 | mGeneral->initAlarm(topFrame,alarmLineLayout); |
188 | mGeneral->initDescription(topFrame,topLayout); | 188 | mGeneral->initDescription(topFrame,topLayout); |
189 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); | 189 | QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); |
190 | mGeneral->initCategories( topFrame, detailsLayout ); | 190 | mGeneral->initCategories( topFrame, detailsLayout ); |
191 | mGeneral->initSecrecy( topFrame, detailsLayout ); | 191 | mGeneral->initSecrecy( topFrame, detailsLayout ); |
192 | } | 192 | } |
193 | mGeneral->finishSetup(); | 193 | mGeneral->finishSetup(); |
194 | 194 | ||
195 | } | 195 | } |
196 | 196 | ||
197 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) | 197 | void KOTodoEditor::editTodo(Todo *todo, bool editDescription) |
198 | { | 198 | { |
199 | //init(); | 199 | //init(); |
200 | 200 | ||
201 | mTodo = todo; | 201 | mTodo = todo; |
202 | readTodo(mTodo); | 202 | readTodo(mTodo); |
203 | if ( editDescription ) { | 203 | if ( editDescription ) { |
204 | showPage( 1 ); | 204 | showPage( 1 ); |
205 | mGeneral->setFocusOn( 1 ); | 205 | mGeneral->setFocusOn( 1 ); |
206 | } else { | 206 | } else { |
207 | showPage( 0 ); | 207 | showPage( 0 ); |
208 | mGeneral->setFocusOn( 2 ); | 208 | mGeneral->setFocusOn( 2 ); |
209 | } | 209 | } |
210 | checkRecurrence(); | 210 | checkRecurrence(); |
211 | } | 211 | } |
212 | 212 | ||
213 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) | 213 | void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) |
214 | { | 214 | { |
215 | //init(); | 215 | //init(); |
216 | 216 | ||
217 | mTodo = 0; | 217 | mTodo = 0; |
218 | setDefaults(due,relatedTodo,allDay); | 218 | setDefaults(due,relatedTodo,allDay); |
219 | } | 219 | } |
220 | 220 | ||
221 | void KOTodoEditor::loadDefaults() | 221 | void KOTodoEditor::loadDefaults() |
222 | { | 222 | { |
223 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); | 223 | setDefaults(QDateTime::currentDateTime().addDays(7),0,false); |
224 | } | 224 | } |
225 | 225 | ||
226 | bool KOTodoEditor::processInput( bool emitTime ) | 226 | bool KOTodoEditor::processInput( bool emitTime ) |
227 | { | 227 | { |
228 | if (!validateInput()) return false; | 228 | if (!validateInput()) return false; |
229 | 229 | ||
230 | Todo *todo = 0; | 230 | Todo *todo = 0; |
231 | 231 | ||
232 | if (mTodo) todo = mTodo; | 232 | if (mTodo) todo = mTodo; |
233 | else { | 233 | else { |
234 | todo = new Todo; | 234 | todo = new Todo; |
235 | todo->setOrganizer(KOPrefs::instance()->email()); | 235 | todo->setOrganizer(KOPrefs::instance()->email()); |
236 | } | 236 | } |
237 | 237 | ||
238 | writeTodo(todo); | 238 | writeTodo(todo); |
239 | if ( emitTime ) { | 239 | if ( emitTime ) { |
240 | globalFlagBlockAgenda = 1; | 240 | globalFlagBlockAgenda = 1; |
241 | emit showAgendaView( false ); | 241 | emit showAgendaView( false ); |
242 | if ( todo->hasDueDate() ) | 242 | if ( todo->hasDueDate() ) |
243 | emit jumpToTime( todo->dtDue().date() ); | 243 | emit jumpToTime( todo->dtDue().date() ); |
244 | globalFlagBlockAgenda = 2; | 244 | globalFlagBlockAgenda = 2; |
245 | } | 245 | } |
246 | if (mTodo) { | 246 | if (mTodo) { |
247 | todo->setRevision(todo->revision()+1); | 247 | todo->setRevision(todo->revision()+1); |
248 | emit todoChanged(todo); | 248 | emit todoChanged(todo); |
249 | } else { | 249 | } else { |
250 | mCalendar->addTodo(todo); | 250 | mCalendar->addTodo(todo); |
251 | mTodo = todo; | 251 | mTodo = todo; |
252 | emit todoAdded(todo); | 252 | emit todoAdded(todo); |
253 | } | 253 | } |
254 | 254 | ||
255 | return true; | 255 | return true; |
256 | } | 256 | } |
257 | 257 | ||
258 | void KOTodoEditor::deleteTodo() | 258 | void KOTodoEditor::deleteTodo() |
259 | { | 259 | { |
260 | if (mTodo) { | 260 | if (mTodo) { |
261 | if (KOPrefs::instance()->mConfirm) { | 261 | if (KOPrefs::instance()->mConfirm) { |
262 | switch (msgItemDelete()) { | 262 | switch (msgItemDelete()) { |
263 | case KMessageBox::Continue: // OK | 263 | case KMessageBox::Continue: // OK |
264 | emit todoToBeDeleted(mTodo); | 264 | emit todoToBeDeleted(mTodo); |
265 | emit dialogClose(mTodo); | 265 | emit dialogClose(mTodo); |
266 | mCalendar->deleteTodo(mTodo); | 266 | mCalendar->deleteTodo(mTodo); |
267 | emit todoDeleted(); | 267 | emit todoDeleted(); |
268 | reject(); | 268 | reject(); |
269 | break; | 269 | break; |
270 | } | 270 | } |
271 | } | 271 | } |
272 | else { | 272 | else { |
273 | emit todoToBeDeleted(mTodo); | 273 | emit todoToBeDeleted(mTodo); |
274 | emit dialogClose(mTodo); | 274 | emit dialogClose(mTodo); |
275 | mCalendar->deleteTodo(mTodo); | 275 | mCalendar->deleteTodo(mTodo); |
276 | emit todoDeleted(); | 276 | emit todoDeleted(); |
277 | reject(); | 277 | reject(); |
278 | } | 278 | } |
279 | } else { | 279 | } else { |
280 | reject(); | 280 | reject(); |
281 | } | 281 | } |
282 | } | 282 | } |
283 | 283 | ||
284 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) | 284 | void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) |
285 | { | 285 | { |
286 | mRelatedTodo = relatedEvent; | 286 | mRelatedTodo = relatedEvent; |
287 | 287 | ||
288 | mGeneral->setDefaults(due,allDay); | 288 | mGeneral->setDefaults(due,allDay); |
289 | mDetails->setDefaults(); | 289 | mDetails->setDefaults(); |
290 | showPage( 0 ); | 290 | showPage( 0 ); |
291 | if ( mRelatedTodo ) { | 291 | if ( mRelatedTodo ) { |
292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); | 292 | mGeneral->setCategories (mRelatedTodo->categoriesStr ()); |
293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); | 293 | mGeneral->setSecrecy (mRelatedTodo->secrecy ()); |
294 | if ( mRelatedTodo->priority() < 3 ) | 294 | if ( mRelatedTodo->priority() < 3 ) |
295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); | 295 | mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); |
296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); | 296 | mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); |
297 | int len = mRelatedTodo->summary().length(); | 297 | int len = mRelatedTodo->summary().length(); |
298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); | 298 | mGeneral->mSummaryEdit->lineEdit()->setFocus(); |
299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); | 299 | mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); |
300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); | 300 | mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); |
301 | 301 | ||
302 | } else | 302 | } else |
303 | mGeneral->setFocusOn( 2 ); | 303 | mGeneral->setFocusOn( 2 ); |
304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 304 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 305 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
306 | } | 306 | } |
307 | void KOTodoEditor::checkRecurrence() | 307 | void KOTodoEditor::checkRecurrence() |
308 | { | 308 | { |
309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 309 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); | 310 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); |
311 | 311 | ||
312 | if ( mTodo ) | 312 | if ( mTodo ) |
313 | mRecurrence->readEvent( mTodo ); | 313 | mRecurrence->readEvent( mTodo ); |
314 | else { | 314 | else { |
315 | bool time = mGeneral->mTimeButton->isChecked(); | 315 | bool time = mGeneral->mTimeButton->isChecked(); |
316 | QDateTime from,to; | 316 | QDateTime from,to; |
317 | if ( time ) { | 317 | if ( time ) { |
318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 318 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 319 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
320 | } else { | 320 | } else { |
321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 321 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 322 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
323 | } | 323 | } |
324 | if ( to < from ) | 324 | if ( to < from ) |
325 | to = from; | 325 | to = from; |
326 | mRecurrence->setDefaults(from,to,!time); | 326 | mRecurrence->setDefaults(from,to,!time); |
327 | } | 327 | } |
328 | } else { | 328 | } else { |
329 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); | 329 | tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); |
330 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); | 330 | mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); |
331 | } | 331 | } |
332 | } | 332 | } |
333 | void KOTodoEditor::readTodo(Todo *todo) | 333 | void KOTodoEditor::readTodo(Todo *todo) |
334 | { | 334 | { |
335 | mGeneral->readTodo(todo); | 335 | mGeneral->readTodo(todo); |
336 | mDetails->readEvent(todo); | 336 | mDetails->readEvent(todo); |
337 | mRelatedTodo = 0;//todo->relatedTo(); | 337 | mRelatedTodo = 0;//todo->relatedTo(); |
338 | // categories | 338 | // categories |
339 | // mCategoryDialog->setSelected(todo->categories()); | 339 | // mCategoryDialog->setSelected(todo->categories()); |
340 | 340 | ||
341 | // We should handle read-only events here. | 341 | // We should handle read-only events here. |
342 | } | 342 | } |
343 | 343 | ||
344 | void KOTodoEditor::writeTodo(Todo *event) | 344 | void KOTodoEditor::writeTodo(Todo *event) |
345 | { | 345 | { |
346 | mGeneral->writeTodo(event); | 346 | mGeneral->writeTodo(event); |
347 | mDetails->writeEvent(event); | 347 | mDetails->writeEvent(event); |
348 | 348 | ||
349 | // set related event, i.e. parent to-do in this case. | 349 | // set related event, i.e. parent to-do in this case. |
350 | if (mRelatedTodo) { | 350 | if (mRelatedTodo) { |
351 | event->setRelatedTo(mRelatedTodo); | 351 | event->setRelatedTo(mRelatedTodo); |
352 | } | 352 | } |
353 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { | 353 | if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { |
354 | mRecurrence->writeEvent(event); | 354 | mRecurrence->writeEvent(event); |
355 | event->setRecurrenceID( event->dtStart().addSecs(-1) ); | 355 | event->setRecurrenceID( event->dtStart().addSecs(-1) ); |
356 | event->setRecurDates(); | 356 | event->setRecurDates(); |
357 | #if 0 | 357 | #if 0 |
358 | bool ok; | 358 | bool ok; |
359 | QDateTime next = event->getNextOccurence( event->dtStart().addSecs(-1), &ok ); | 359 | QDateTime next = event->getNextOccurence( event->dtStart().addSecs(-1), &ok ); |
360 | if ( ok ) { | 360 | if ( ok ) { |
361 | QDateTime from,to; | 361 | QDateTime from,to; |
362 | bool time = mGeneral->mTimeButton->isChecked(); | 362 | bool time = mGeneral->mTimeButton->isChecked(); |
363 | if ( time ) { | 363 | if ( time ) { |
364 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; | 364 | to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; |
365 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; | 365 | from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; |
366 | } else { | 366 | } else { |
367 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; | 367 | to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; |
368 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; | 368 | from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; |
369 | } | 369 | } |
370 | if ( to < from ) | 370 | if ( to < from ) |
371 | to = from; | 371 | to = from; |
372 | int secs = from.secsTo( to ); | 372 | int secs = from.secsTo( to ); |
373 | event->setRecurrenceID( next ); | 373 | event->setRecurrenceID( next ); |
374 | event->setDtStart( next ); | 374 | event->setDtStart( next ); |
375 | event->setDtDue( next.addSecs( secs ) ); | 375 | event->setDtDue( next.addSecs( secs ) ); |
376 | } | 376 | } |
377 | else { | 377 | else { |
378 | event->setHasRecurrenceID( false ); | 378 | event->setHasRecurrenceID( false ); |
379 | event->recurrence()->unsetRecurs(); | 379 | event->recurrence()->unsetRecurs(); |
380 | } | 380 | } |
381 | #endif | 381 | #endif |
382 | } else | 382 | } else |
383 | event->recurrence()->unsetRecurs(); | 383 | event->recurrence()->unsetRecurs(); |
384 | } | 384 | } |
385 | 385 | ||
386 | bool KOTodoEditor::validateInput() | 386 | bool KOTodoEditor::validateInput() |
387 | { | 387 | { |
388 | if (!mGeneral->validateInput()) return false; | 388 | if (!mGeneral->validateInput()) return false; |
389 | if (!mDetails->validateInput()) return false; | 389 | if (!mDetails->validateInput()) return false; |
390 | return true; | 390 | return true; |
391 | } | 391 | } |
392 | 392 | ||
393 | int KOTodoEditor::msgItemDelete() | 393 | int KOTodoEditor::msgItemDelete() |
394 | { | 394 | { |
395 | return KMessageBox::warningContinueCancel(this, | 395 | return KMessageBox::warningContinueCancel(this, |
396 | i18n("This item will be permanently deleted."), | 396 | i18n("This item will be permanently deleted."), |
397 | i18n("KOrganizer Confirmation"),i18n("Delete")); | 397 | i18n("KOrganizer Confirmation"),i18n("Delete")); |
398 | } | 398 | } |
399 | 399 | ||
400 | void KOTodoEditor::modified (int modification) | 400 | void KOTodoEditor::modified (int modification) |
401 | { | 401 | { |
402 | if (modification == KOGlobals::CATEGORY_MODIFIED || | 402 | if (modification == KOGlobals::CATEGORY_MODIFIED || |
403 | KOGlobals::UNKNOWN_MODIFIED == modification ) | 403 | KOGlobals::UNKNOWN_MODIFIED == modification ) |
404 | // mCategoryDialog->setSelected (mTodo->categories ()); | 404 | // mCategoryDialog->setSelected (mTodo->categories ()); |
405 | mGeneral->modified (mTodo, modification); | 405 | mGeneral->modified (mTodo, modification); |
406 | 406 | ||
407 | } | 407 | } |
408 | 408 | ||
409 | void KOTodoEditor::slotLoadTemplate() | 409 | void KOTodoEditor::slotLoadTemplate() |
410 | { | 410 | { |
411 | 411 | ||
412 | QString fileName =locateLocal( "templates", "todos" ); | 412 | QString fileName =locateLocal( "templates", "todos" ); |
413 | QDir t_dir; | 413 | QDir t_dir; |
414 | if ( !t_dir.exists(fileName) ) | 414 | if ( !t_dir.exists(fileName) ) |
415 | t_dir.mkdir ( fileName ); | 415 | t_dir.mkdir ( fileName ); |
416 | fileName += "/todo"; | 416 | fileName += "/todo"; |
417 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); | 417 | fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); |
418 | if ( fileName.length() == 0 ) | 418 | if ( fileName.length() == 0 ) |
419 | return; | 419 | return; |
420 | CalendarLocal cal; | 420 | CalendarLocal cal; |
421 | ICalFormat format; | 421 | ICalFormat format; |
422 | if ( !format.load( &cal, fileName ) ) { | 422 | if ( !format.load( &cal, fileName ) ) { |
423 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 423 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
424 | .arg( fileName ) ); | 424 | .arg( fileName ) ); |
425 | return ; | 425 | return ; |
426 | } | 426 | } |
427 | QPtrList<Todo> todos = cal.todos(); | 427 | QPtrList<Todo> todos = cal.todos(); |
428 | Todo * todo = todos.first(); | 428 | Todo * todo = todos.first(); |
429 | if ( !todo ) { | 429 | if ( !todo ) { |
430 | KMessageBox::error( this, | 430 | KMessageBox::error( this, |
431 | i18n("Template does not\ncontain a valid Todo.")); | 431 | i18n("Template does not\ncontain a valid Todo.")); |
432 | } else { | 432 | } else { |
433 | readTodo( todo ); | 433 | readTodo( todo ); |
434 | } | 434 | } |
435 | 435 | ||
436 | } | 436 | } |
437 | 437 | ||
438 | void KOTodoEditor::slotSaveTemplate() | 438 | void KOTodoEditor::slotSaveTemplate() |
439 | { | 439 | { |
440 | QString fileName =locateLocal( "templates", "todos" ); | 440 | QString fileName =locateLocal( "templates", "todos" ); |
441 | QDir t_dir; | 441 | QDir t_dir; |
442 | if ( !t_dir.exists(fileName) ) | 442 | if ( !t_dir.exists(fileName) ) |
443 | t_dir.mkdir ( fileName ); | 443 | t_dir.mkdir ( fileName ); |
444 | fileName += "/todo"; | 444 | fileName += "/todo"; |
445 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); | 445 | fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); |
446 | if ( fileName.length() > 0 ) | 446 | if ( fileName.length() > 0 ) |
447 | saveTemplate( fileName ); | 447 | saveTemplate( fileName ); |
448 | } | 448 | } |
449 | 449 | ||
450 | void KOTodoEditor::saveTemplate( const QString &templateName ) | 450 | void KOTodoEditor::saveTemplate( const QString &templateName ) |
451 | { | 451 | { |
452 | Todo *todo = new Todo; | 452 | Todo *todo = new Todo; |
453 | writeTodo( todo ); | 453 | writeTodo( todo ); |
454 | saveAsTemplate( todo, templateName ); | 454 | saveAsTemplate( todo, templateName ); |
455 | } | 455 | } |