summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-30 07:32:03 (UTC)
committer zautrix <zautrix>2005-04-30 07:32:03 (UTC)
commit7c31102a00920834ab8e3778f0f459b96b2fb309 (patch) (unidiff)
tree9f238caaaab4ba150e4f14708d85162af0ea5092
parentbdaded2da25b0ccef80d6e638fa12f92a4f8744d (diff)
downloadkdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.zip
kdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.tar.gz
kdepimpi-7c31102a00920834ab8e3778f0f459b96b2fb309.tar.bz2
fixes
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt6
-rw-r--r--korganizer/koeditordetails.cpp102
-rw-r--r--korganizer/koeditorgeneral.cpp16
-rw-r--r--korganizer/koeventeditor.cpp4
-rw-r--r--korganizer/kotodoeditor.cpp2
-rw-r--r--korganizer/searchdialog.cpp4
-rw-r--r--libkcal/todo.cpp6
-rw-r--r--microkde/kdatetbl.cpp17
8 files changed, 104 insertions, 53 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt
index 41b2a81..e3c4e0a 100644
--- a/bin/kdepim/WhatsNew.txt
+++ b/bin/kdepim/WhatsNew.txt
@@ -1,73 +1,79 @@
1Info about the changes in new versions of KDE-Pim/Pi 1Info about the changes in new versions of KDE-Pim/Pi
2 2
3********** VERSION 2.1.4 ************
4
5Fixed two more bugs in the KA/Pi CSV import dialog:
6Made it possible to read multi-line fields and import it to the "Note" field.
7Fixed a problem in mapping custom fields, whatever a custem field is...
8
3********** VERSION 2.1.3 ************ 9********** VERSION 2.1.3 ************
4 10
5Changed the menu structure of the alarm applet: 11Changed the menu structure of the alarm applet:
6Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List". 12Moved "Simulate" to " Play Beeps" submenu and re-added "Todo List".
7 13
8Fixed several problems in the KA/Pi CSV import dialog: 14Fixed several problems in the KA/Pi CSV import dialog:
9Added "Category", made codec configureable and made it possible to map many fields to the "Note" field. 15Added "Category", made codec configureable and made it possible to map many fields to the "Note" field.
10 16
11 17
12********** VERSION 2.1.2 ************ 18********** VERSION 2.1.2 ************
13 19
14Fixed a problem closing the alarm dialog on Zaurus with "OK" button. 20Fixed a problem closing the alarm dialog on Zaurus with "OK" button.
15 21
16Fixed a problem when importing data from Outlook with mutiple categories set. 22Fixed a problem when importing data from Outlook with mutiple categories set.
17 23
18Changed display of days in datenavigator: 24Changed display of days in datenavigator:
19Birthdays are now blue, not dark green. 25Birthdays are now blue, not dark green.
20When todo view is shown, no birtdays are shown and days with due todos are shown blue. 26When todo view is shown, no birtdays are shown and days with due todos are shown blue.
21When journal view is shown, only holidays are shown and days with journals are blue. 27When journal view is shown, only holidays are shown and days with journals are blue.
22 28
23Added Backup options to global config: 29Added Backup options to global config:
24You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ). 30You can create now x-daily backups for KO/Pi, KA/Pi (for file resources only, file resource is the standard type) and PwM/Pi ( all files you will open ).
25It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again. 31It is recommended to use another HDD/Memory card for the backup directory. If (very useful on the Zaurus) the specified backup directory does not exist you are asked if you want to try again to create a backup. That makes it possible to insert your memory card in the Zaurus and then trying again.
26The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups. 32The backup is created when the application wants to save for the first time on a backup-day. You can specify the amount of backups and the day interval of backups.
27 33
28********** VERSION 2.1.1 ************ 34********** VERSION 2.1.1 ************
29 35
30Stable release 2.1.1! 36Stable release 2.1.1!
31 37
32KO/Pi: 38KO/Pi:
33Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display. 39Fixed one problem in the layout of the edit dialogs on the Zaurus with 640x480 display.
34 40
35********** VERSION 2.1.0 ************ 41********** VERSION 2.1.0 ************
36 42
37Stable release 2.1.0! 43Stable release 2.1.0!
38 44
39Summary of changes/fixes compared to version 2.0.6: 45Summary of changes/fixes compared to version 2.0.6:
40 46
41Many bugs of version 2.0.6 fixed. 47Many bugs of version 2.0.6 fixed.
42Most of them were small bugs, but some of them were important. 48Most of them were small bugs, but some of them were important.
43It is recommended to use version 2.1.0 and not version 2.0.6. 49It is recommended to use version 2.1.0 and not version 2.0.6.
44 50
45Important changes: 51Important changes:
46 52
47Added recurring todos to KO/Pi. 53Added recurring todos to KO/Pi.
48 54
49Added global application font settings (for all KDE-Pim/Pi apps) to the general settings. 55Added global application font settings (for all KDE-Pim/Pi apps) to the general settings.
50 56
51Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more. 57Made Passwordmanager PwM/Pi more userfriendly: Rearranged some toolbar icons, optimized setting of focus, fixed layout problems and more.
52 58
53Datenavigator can now display many months. Very useful on the desktop. 59Datenavigator can now display many months. Very useful on the desktop.
54 60
55KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements. 61KO/Pi alarm applet changed: Made buttons in alarm dialog much bigger and other usebility enhancements.
56 62
57Made alarm sound working on Linux desktop. 63Made alarm sound working on Linux desktop.
58 64
59Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details. 65Made KO/Pi and KA/Pi running from a memory stick. Please read storage HowTo for details.
60 66
61Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details. 67Added timetracking feature in KO/Pi todo view. Please read timetraker HowTo for details.
62 68
63Many other usebility enhancements. 69Many other usebility enhancements.
64Special thanks to Ben for his suggestions! 70Special thanks to Ben for his suggestions!
65 71
66You can find the complete changelog 72You can find the complete changelog
67from version 1.7.7 to 2.1.0 73from version 1.7.7 to 2.1.0
68in the source package or on 74in the source package or on
69 75
70http://www.pi-sync.net/html/changelog.html 76http://www.pi-sync.net/html/changelog.html
71 77
72 78
73 79
diff --git a/korganizer/koeditordetails.cpp b/korganizer/koeditordetails.cpp
index 802261c..bdfc637 100644
--- a/korganizer/koeditordetails.cpp
+++ b/korganizer/koeditordetails.cpp
@@ -1,454 +1,474 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in thse hope that it will be useful, 10 This program is distributed in thse hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24#include <qtooltip.h> 24#include <qtooltip.h>
25#include <qfiledialog.h> 25#include <qfiledialog.h>
26#include <qlayout.h> 26#include <qlayout.h>
27#include <qvbox.h> 27#include <qvbox.h>
28#include <qbuttongroup.h> 28#include <qbuttongroup.h>
29#include <qvgroupbox.h> 29#include <qvgroupbox.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qdatetime.h> 31#include <qdatetime.h>
32#include <qapp.h> 32#include <qapp.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kiconloader.h> 36#include <kiconloader.h>
37#include <kstandarddirs.h> 37#include <kstandarddirs.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#ifndef KORG_NOKABC 39#ifndef KORG_NOKABC
40 40
41#ifdef DESKTOP_VERSION 41#ifdef DESKTOP_VERSION
42#include <kabc/addresseedialog.h> 42#include <kabc/addresseedialog.h>
43#else //DESKTOP_VERSION 43#else //DESKTOP_VERSION
44#include <externalapphandler.h> 44#include <externalapphandler.h>
45#endif //DESKTOP_VERSION 45#endif //DESKTOP_VERSION
46 46
47#endif 47#endif
48 48
49#include <libkcal/incidence.h> 49#include <libkcal/incidence.h>
50 50
51#include "koprefs.h" 51#include "koprefs.h"
52 52
53#include "koeditordetails.h" 53#include "koeditordetails.h"
54 54
55template <> 55template <>
56CustomListViewItem<class Attendee *>::~CustomListViewItem() 56CustomListViewItem<class Attendee *>::~CustomListViewItem()
57{ 57{
58 delete mData; 58 delete mData;
59} 59}
60 60
61template <> 61template <>
62void CustomListViewItem<class Attendee *>::updateItem() 62void CustomListViewItem<class Attendee *>::updateItem()
63{ 63{
64 setText(0,mData->name()); 64 setText(0,mData->name());
65 setText(1,mData->email()); 65 setText(1,mData->email());
66 setText(2,mData->roleStr()); 66 setText(2,mData->roleStr());
67 setText(3,mData->statusStr()); 67 setText(3,mData->statusStr());
68 if (mData->RSVP() && !mData->email().isEmpty()) 68 if (mData->RSVP() && !mData->email().isEmpty())
69 setPixmap(4,SmallIcon("mailappt")); 69 setPixmap(4,SmallIcon("mailappt"));
70 else 70 else
71 setPixmap(4,SmallIcon("nomailappt")); 71 setPixmap(4,SmallIcon("nomailappt"));
72} 72}
73 73
74 74
75KOEditorDetails::KOEditorDetails (int spacing,QWidget* parent,const char* name) 75KOEditorDetails::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
220KOEditorDetails::~KOEditorDetails() 240KOEditorDetails::~KOEditorDetails()
221{ 241{
222} 242}
223 243
224void KOEditorDetails::removeAttendee() 244void 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
240void KOEditorDetails::openAddressBook() 260void 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
266void KOEditorDetails::addNewAttendee() 286void 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
293void KOEditorDetails::insertAttendees(const QString& uid,const QStringList& nameList,const QStringList& emailList,const QStringList& uidList) 313void 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
310void KOEditorDetails::insertAttendee(Attendee *a) 330void 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
323void KOEditorDetails::setDefaults() 343void 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
339void KOEditorDetails::readEvent(Incidence *event) 359void 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
353void KOEditorDetails::writeEvent(Incidence *event) 373void 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
366void KOEditorDetails::cancelAttendeeEvent(Incidence *event) 386void 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
376bool KOEditorDetails::validateInput() 396bool KOEditorDetails::validateInput()
377{ 397{
378 return true; 398 return true;
379} 399}
380 400
381void KOEditorDetails::updateAttendeeInput() 401void KOEditorDetails::updateAttendeeInput()
382{ 402{
383 QListViewItem *item = mListView->selectedItem(); 403 QListViewItem *item = mListView->selectedItem();
384 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 404 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
385 if (aItem) { 405 if (aItem) {
386 fillAttendeeInput( aItem ); 406 fillAttendeeInput( aItem );
387 } else { 407 } else {
388 clearAttendeeInput(); 408 clearAttendeeInput();
389 } 409 }
390} 410}
391 411
392void KOEditorDetails::clearAttendeeInput() 412void KOEditorDetails::clearAttendeeInput()
393{ 413{
394 mNameEdit->setText(""); 414 mNameEdit->setText("");
395 mUidEdit->setText(""); 415 mUidEdit->setText("");
396 mEmailEdit->setText(""); 416 mEmailEdit->setText("");
397 mRoleCombo->setCurrentItem(0); 417 mRoleCombo->setCurrentItem(0);
398 mStatusCombo->setCurrentItem(0); 418 mStatusCombo->setCurrentItem(0);
399 mRsvpButton->setChecked(true); 419 mRsvpButton->setChecked(true);
400 setEnabledAttendeeInput( false ); 420 setEnabledAttendeeInput( false );
401} 421}
402 422
403void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem ) 423void KOEditorDetails::fillAttendeeInput( AttendeeListItem *aItem )
404{ 424{
405 Attendee *a = aItem->data(); 425 Attendee *a = aItem->data();
406 mDisableItemUpdate = true; 426 mDisableItemUpdate = true;
407 mNameEdit->setText(a->name()); 427 mNameEdit->setText(a->name());
408 mUidEdit->setText(a->uid()); 428 mUidEdit->setText(a->uid());
409 mEmailEdit->setText(a->email()); 429 mEmailEdit->setText(a->email());
410 mRoleCombo->setCurrentItem(a->role()); 430 mRoleCombo->setCurrentItem(a->role());
411 mStatusCombo->setCurrentItem(a->status()); 431 mStatusCombo->setCurrentItem(a->status());
412 mRsvpButton->setChecked(a->RSVP()); 432 mRsvpButton->setChecked(a->RSVP());
413 433
414 mDisableItemUpdate = false; 434 mDisableItemUpdate = false;
415 435
416 setEnabledAttendeeInput( true ); 436 setEnabledAttendeeInput( true );
417} 437}
418 438
419void KOEditorDetails::setEnabledAttendeeInput( bool enabled ) 439void KOEditorDetails::setEnabledAttendeeInput( bool enabled )
420{ 440{
421 mNameEdit->setEnabled( enabled ); 441 mNameEdit->setEnabled( enabled );
422 mEmailEdit->setEnabled( enabled ); 442 mEmailEdit->setEnabled( enabled );
423 mRoleCombo->setEnabled( enabled ); 443 mRoleCombo->setEnabled( enabled );
424 mStatusCombo->setEnabled( enabled ); 444 mStatusCombo->setEnabled( enabled );
425 mRsvpButton->setEnabled( enabled ); 445 mRsvpButton->setEnabled( enabled );
426 446
427 mRemoveButton->setEnabled( enabled ); 447 mRemoveButton->setEnabled( enabled );
428} 448}
429 449
430void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c ) 450void KOEditorDetails::itemClicked(QListViewItem * item ,const QPoint & pnt, int c )
431{ 451{
432 if ( item && c == 4 ) { 452 if ( item && c == 4 ) {
433 mRsvpButton->setChecked( !mRsvpButton->isChecked() ); 453 mRsvpButton->setChecked( !mRsvpButton->isChecked() );
434 updateAttendeeItem(); 454 updateAttendeeItem();
435 } 455 }
436} 456}
437void KOEditorDetails::updateAttendeeItem() 457void KOEditorDetails::updateAttendeeItem()
438{ 458{
439 if (mDisableItemUpdate) return; 459 if (mDisableItemUpdate) return;
440 460
441 QListViewItem *item = mListView->selectedItem(); 461 QListViewItem *item = mListView->selectedItem();
442 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item ); 462 AttendeeListItem *aItem = static_cast<AttendeeListItem *>( item );
443 if ( !aItem ) return; 463 if ( !aItem ) return;
444 464
445 Attendee *a = aItem->data(); 465 Attendee *a = aItem->data();
446 466
447 a->setName( mNameEdit->text() ); 467 a->setName( mNameEdit->text() );
448 a->setUid( mUidEdit->text() ); 468 a->setUid( mUidEdit->text() );
449 a->setEmail( mEmailEdit->text() ); 469 a->setEmail( mEmailEdit->text() );
450 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) ); 470 a->setRole( Attendee::Role( mRoleCombo->currentItem() ) );
451 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) ); 471 a->setStatus( Attendee::PartStat( mStatusCombo->currentItem() ) );
452 a->setRSVP( mRsvpButton->isChecked() ); 472 a->setRSVP( mRsvpButton->isChecked() );
453 aItem->updateItem(); 473 aItem->updateItem();
454} 474}
diff --git a/korganizer/koeditorgeneral.cpp b/korganizer/koeditorgeneral.cpp
index 0045b7f..bfe0aec 100644
--- a/korganizer/koeditorgeneral.cpp
+++ b/korganizer/koeditorgeneral.cpp
@@ -1,518 +1,528 @@
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 the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 <qwidget.h> 24#include <qwidget.h>
25#include <qtooltip.h> 25#include <qtooltip.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 <qtimer.h> 32#include <qtimer.h>
33#include <qfile.h> 33#include <qfile.h>
34 34
35 35
36#include <kglobal.h> 36#include <kglobal.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kiconloader.h> 39#include <kiconloader.h>
40#include <kmessagebox.h> 40#include <kmessagebox.h>
41#include <kfiledialog.h> 41#include <kfiledialog.h>
42#include <kstandarddirs.h> 42#include <kstandarddirs.h>
43 43
44#include <libkcal/todo.h> 44#include <libkcal/todo.h>
45#include <libkcal/event.h> 45#include <libkcal/event.h>
46#include <libkdepim/categoryselectdialog.h> 46#include <libkdepim/categoryselectdialog.h>
47#include <libkdepim/kdateedit.h> 47#include <libkdepim/kdateedit.h>
48 48
49#include "koprefs.h" 49#include "koprefs.h"
50#include "koglobals.h" 50#include "koglobals.h"
51 51
52#include "koeditorgeneral.h" 52#include "koeditorgeneral.h"
53#include "kolocationbox.h" 53#include "kolocationbox.h"
54#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#else 56#else
57#include <qapplication.h> 57#include <qapplication.h>
58#endif 58#endif
59 59
60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) : 60KOEditorGeneral::KOEditorGeneral(QObject* parent, const char* name) :
61 QObject( parent, name) 61 QObject( parent, name)
62{ 62{
63 mNextFocus = 0; 63 mNextFocus = 0;
64} 64}
65 65
66KOEditorGeneral::~KOEditorGeneral() 66KOEditorGeneral::~KOEditorGeneral()
67{ 67{
68} 68}
69 69
70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout) 70void KOEditorGeneral::initHeader(QWidget *parent,QBoxLayout *topLayout)
71{ 71{
72 QGridLayout *headerLayout = new QGridLayout(topLayout); 72 QGridLayout *headerLayout = new QGridLayout(topLayout);
73 73
74#if 0 74#if 0
75 mOwnerLabel = new QLabel(i18n("Owner:"),parent); 75 mOwnerLabel = new QLabel(i18n("Owner:"),parent);
76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1); 76 headerLayout->addMultiCellWidget(mOwnerLabel,0,0,0,1);
77#endif 77#endif
78 78
79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent); 79 QLabel *summaryLabel = new QLabel(i18n("Summary:"),parent);
80 headerLayout->addWidget(summaryLabel,1,0); 80 headerLayout->addWidget(summaryLabel,1,0);
81 81
82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10); 82 mSummaryEdit = new KOLocationBox(TRUE,parent, 10);
83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 83 mSummaryEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) ); 84 //mSummaryEdit->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5 ,(QSizePolicy::SizeType)3 ,FALSE) );
85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() ); 85 //qDebug("h %d %d ", summaryLabel->sizeHint().height(),mSummaryEdit->sizeHint().height() );
86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2; 86 int hei = (summaryLabel->sizeHint().height() + mSummaryEdit->sizeHint().height())/2;
87 if ( QApplication::desktop()->width() > 320 ) 87 if ( QApplication::desktop()->width() > 320 )
88 mSummaryEdit->setMaximumHeight( hei +6 ); 88 mSummaryEdit->setMaximumHeight( hei +6 );
89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding ); 89 //qDebug("%d %d %d %d %d %d ", QSizePolicy::Fixed , QSizePolicy::Minimum , QSizePolicy:: Maximum , QSizePolicy:: Preferred , QSizePolicy:: MinimumExpanding , QSizePolicy::Expanding );
90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink } 90 // SizeType { Fixed = 0, Minimum = MayGrow, Maximum = MayShrink, Preferred = MayGrow|MayShrink, MinimumExpanding = Minimum|ExpMask, Expanding = MinimumExpanding|MayShrink }
91 // mSummaryEdit = new QLineEdit(parent); 91 // mSummaryEdit = new QLineEdit(parent);
92 headerLayout->addWidget(mSummaryEdit,1,1); 92 headerLayout->addWidget(mSummaryEdit,1,1);
93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 93 connect ( mSummaryEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
94 94
95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent); 95 QLabel *locationLabel = new QLabel(i18n("Location:"),parent);
96 headerLayout->addWidget(locationLabel,2,0); 96 if ( QApplication::desktop()->height() < 320 )
97 headerLayout->addWidget(locationLabel,1,2);
98 else
99 headerLayout->addWidget(locationLabel,2,0);
97 100
98 mLocationEdit = new KOLocationBox(TRUE,parent,10); 101 mLocationEdit = new KOLocationBox(TRUE,parent,10);
99 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) ); 102 mLocationEdit->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::MinimumExpanding ,FALSE) );
100 if ( QApplication::desktop()->width() > 320 ) 103 if ( QApplication::desktop()->width() > 320 )
101 mLocationEdit->setMaximumHeight( hei + 6); 104 mLocationEdit->setMaximumHeight( hei + 6);
102 105
103 // mLocationEdit = new QLineEdit(parent); 106 // mLocationEdit = new QLineEdit(parent);
104 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) ); 107 connect ( mLocationEdit->lineEdit(), SIGNAL ( returnPressed() ), this, SIGNAL (allAccepted () ) );
105 headerLayout->addWidget(mLocationEdit,2,1); 108 if ( QApplication::desktop()->height() < 320 ) {
106 headerLayout->setColStretch( 1, 10); 109 headerLayout->addWidget(mLocationEdit,1,3);
110 headerLayout->setColStretch( 1, 10);
111 headerLayout->setColStretch( 3, 10);
112 }
113 else {
114 headerLayout->addWidget(mLocationEdit,2,1);
115 headerLayout->setColStretch( 1, 10);
116 }
107} 117}
108void KOEditorGeneral::setFocusOn( int i ) 118void KOEditorGeneral::setFocusOn( int i )
109{ 119{
110 mNextFocus = i; 120 mNextFocus = i;
111 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() )); 121 QTimer::singleShot( 0, this, SLOT ( slotSetFocusOn() ));
112} 122}
113void KOEditorGeneral::slotSetFocusOn() 123void KOEditorGeneral::slotSetFocusOn()
114{ 124{
115 mNextFocus; 125 mNextFocus;
116 if ( mNextFocus == 1 ) { 126 if ( mNextFocus == 1 ) {
117 mDescriptionEdit->setFocus(); 127 mDescriptionEdit->setFocus();
118 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333); 128 mDescriptionEdit->setCursorPosition( mDescriptionEdit->numLines (), 333);
119 } 129 }
120 if ( mNextFocus == 2 ) { 130 if ( mNextFocus == 2 ) {
121 mSummaryEdit->setFocus(); 131 mSummaryEdit->setFocus();
122 } 132 }
123} 133}
124void KOEditorGeneral::editCategories() 134void KOEditorGeneral::editCategories()
125{ 135{
126 // qDebug("KOEditorGeneral::editCategories() "); 136 // qDebug("KOEditorGeneral::editCategories() ");
127 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 ); 137 KPIM::CategorySelectDialog* csd = new KPIM::CategorySelectDialog( KOPrefs::instance(), 0 );
128 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &))); 138 connect(csd,SIGNAL(categoriesSelected(const QString &)), this ,SLOT(setCategories(const QString &)));
129 //KOGlobals::fitDialogToScreen( csd ); 139 //KOGlobals::fitDialogToScreen( csd );
130 csd->setColorEnabled(); 140 csd->setColorEnabled();
131 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) ); 141 csd->setSelected( QStringList::split (",", mCategoriesLabel->text()) );
132 csd->exec(); 142 csd->exec();
133 delete csd; 143 delete csd;
134} 144}
135void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout) 145void KOEditorGeneral::initCategories(QWidget *parent, QBoxLayout *topLayout)
136{ 146{
137 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout ); 147 QBoxLayout *categoriesLayout = new QHBoxLayout( topLayout );
138 148
139 mCategoriesButton = new QPushButton(parent); 149 mCategoriesButton = new QPushButton(parent);
140 mCategoriesButton->setText(i18n("Categories...")); 150 mCategoriesButton->setText(i18n("Categories..."));
141 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() )); 151 connect(mCategoriesButton,SIGNAL(clicked()),this, SLOT(editCategories() ));
142 categoriesLayout->addWidget(mCategoriesButton); 152 categoriesLayout->addWidget(mCategoriesButton);
143 153
144 mCategoriesLabel = new QLabel(parent); 154 mCategoriesLabel = new QLabel(parent);
145 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken); 155 mCategoriesLabel->setFrameStyle(QFrame::Panel|QFrame::Sunken);
146 categoriesLayout->addWidget(mCategoriesLabel,1); 156 categoriesLayout->addWidget(mCategoriesLabel,1);
147} 157}
148 158
149void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout) 159void KOEditorGeneral::initSecrecy(QWidget *parent, QBoxLayout *topLayout)
150{ 160{
151 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout ); 161 QBoxLayout *secrecyLayout = new QHBoxLayout( topLayout );
152 162
153 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent); 163 QLabel *secrecyLabel = new QLabel(i18n("Access:"),parent);
154 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent); 164 mCancelBox = new QCheckBox ( i18n("Cancelled"), parent);
155 secrecyLayout->addWidget(mCancelBox); 165 secrecyLayout->addWidget(mCancelBox);
156 secrecyLayout->addWidget(secrecyLabel); 166 secrecyLayout->addWidget(secrecyLabel);
157 167
158 mSecrecyCombo = new QComboBox(parent); 168 mSecrecyCombo = new QComboBox(parent);
159 mSecrecyCombo->insertStringList(Incidence::secrecyList()); 169 mSecrecyCombo->insertStringList(Incidence::secrecyList());
160 secrecyLayout->addWidget(mSecrecyCombo); 170 secrecyLayout->addWidget(mSecrecyCombo);
161} 171}
162 172
163void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout) 173void KOEditorGeneral::initDescription(QWidget *parent,QBoxLayout *topLayout)
164{ 174{
165 mDescriptionEdit = new KTextEdit(parent); 175 mDescriptionEdit = new KTextEdit(parent);
166 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont ); 176 mDescriptionEdit->setFont(KOPrefs::instance()->mEditBoxFont );
167 mDescriptionEdit->append(""); 177 mDescriptionEdit->append("");
168 mDescriptionEdit->setReadOnly(false); 178 mDescriptionEdit->setReadOnly(false);
169 mDescriptionEdit->setOverwriteMode(false); 179 mDescriptionEdit->setOverwriteMode(false);
170 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth ); 180 mDescriptionEdit->setWordWrap( KTextEdit::WidgetWidth );
171 topLayout->addWidget(mDescriptionEdit); 181 topLayout->addWidget(mDescriptionEdit);
172#ifndef DESKTOP_VERSION 182#ifndef DESKTOP_VERSION
173 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold ); 183 QPEApplication::setStylusOperation( mDescriptionEdit, QPEApplication::RightOnHold );
174#endif 184#endif
175 185
176} 186}
177 187
178void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout) 188void KOEditorGeneral::initAlarm(QWidget *parent,QBoxLayout *topLayout)
179{ 189{
180 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout); 190 QBoxLayout *alarmLayout = new QHBoxLayout(topLayout);
181 191
182 //mAlarmBell = new QLabel(parent); 192 //mAlarmBell = new QLabel(parent);
183 //mAlarmBell->setPixmap(SmallIcon("bell")); 193 //mAlarmBell->setPixmap(SmallIcon("bell"));
184 //alarmLayout->addWidget(mAlarmBell); 194 //alarmLayout->addWidget(mAlarmBell);
185 if ( QApplication::desktop()->width() < 320 ) 195 if ( QApplication::desktop()->width() < 320 )
186 mAlarmButton = new QCheckBox(i18n("Rem."),parent); 196 mAlarmButton = new QCheckBox(i18n("Rem."),parent);
187 else 197 else
188 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent); 198 mAlarmButton = new QCheckBox(i18n("Reminder:"),parent);
189 199
190 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool))); 200 connect(mAlarmButton, SIGNAL(toggled(bool)), SLOT(enableAlarmEdit(bool)));
191 alarmLayout->addWidget(mAlarmButton); 201 alarmLayout->addWidget(mAlarmButton);
192 202
193 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ; 203 mAlarmTimeEdit = new QSpinBox ( 0, 9999, 1, parent, "mAlarmTimeEdit " ) ;
194 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus ); 204 mAlarmTimeEdit->setButtonSymbols( QSpinBox::PlusMinus );
195 alarmLayout->addWidget(mAlarmTimeEdit); 205 alarmLayout->addWidget(mAlarmTimeEdit);
196 mAlarmIncrCombo = new QComboBox(false, parent); 206 mAlarmIncrCombo = new QComboBox(false, parent);
197 if ( QApplication::desktop()->width() < 320 ) { 207 if ( QApplication::desktop()->width() < 320 ) {
198 mAlarmIncrCombo->insertItem(i18n("min")); 208 mAlarmIncrCombo->insertItem(i18n("min"));
199 mAlarmIncrCombo->insertItem(i18n("hou")); 209 mAlarmIncrCombo->insertItem(i18n("hou"));
200 mAlarmIncrCombo->insertItem(i18n("day")); 210 mAlarmIncrCombo->insertItem(i18n("day"));
201 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() ); 211 mAlarmTimeEdit->setMaximumWidth( mAlarmTimeEdit->sizeHint().width() );
202 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() ); 212 mAlarmIncrCombo->setMaximumWidth( mAlarmIncrCombo->sizeHint().width() );
203 } else { 213 } else {
204 mAlarmIncrCombo->insertItem(i18n("minute(s)")); 214 mAlarmIncrCombo->insertItem(i18n("minute(s)"));
205 mAlarmIncrCombo->insertItem(i18n("hour(s)")); 215 mAlarmIncrCombo->insertItem(i18n("hour(s)"));
206 mAlarmIncrCombo->insertItem(i18n("day(s)")); 216 mAlarmIncrCombo->insertItem(i18n("day(s)"));
207 } 217 }
208 218
209 // mAlarmIncrCombo->setMinimumHeight(20); 219 // mAlarmIncrCombo->setMinimumHeight(20);
210 alarmLayout->addWidget(mAlarmIncrCombo); 220 alarmLayout->addWidget(mAlarmIncrCombo);
211 mAlarmSoundButton = new QPushButton(parent); 221 mAlarmSoundButton = new QPushButton(parent);
212 mAlarmSoundButton->setPixmap(SmallIcon("playsound")); 222 mAlarmSoundButton->setPixmap(SmallIcon("playsound"));
213 mAlarmSoundButton->setToggleButton(true); 223 mAlarmSoundButton->setToggleButton(true);
214 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 224 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
215 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound())); 225 connect(mAlarmSoundButton, SIGNAL(clicked()), SLOT(pickAlarmSound()));
216 alarmLayout->addWidget(mAlarmSoundButton); 226 alarmLayout->addWidget(mAlarmSoundButton);
217 227
218 mAlarmProgramButton = new QPushButton(parent); 228 mAlarmProgramButton = new QPushButton(parent);
219 mAlarmProgramButton->setPixmap(SmallIcon("run")); 229 mAlarmProgramButton->setPixmap(SmallIcon("run"));
220 mAlarmProgramButton->setToggleButton(true); 230 mAlarmProgramButton->setToggleButton(true);
221 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 231 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
222 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram())); 232 connect(mAlarmProgramButton, SIGNAL(clicked()), SLOT(pickAlarmProgram()));
223 alarmLayout->addWidget(mAlarmProgramButton); 233 alarmLayout->addWidget(mAlarmProgramButton);
224 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 ); 234 mAlarmSoundButton->setMaximumWidth( mAlarmSoundButton->sizeHint().width() + 4 );
225 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 ); 235 mAlarmProgramButton->setMaximumWidth(mAlarmProgramButton->sizeHint().width() + 4 );
226 // if ( KOPrefs::instance()->mCompactDialogs ) { 236 // if ( KOPrefs::instance()->mCompactDialogs ) {
227 // mAlarmSoundButton->hide(); 237 // mAlarmSoundButton->hide();
228 // mAlarmProgramButton->hide(); 238 // mAlarmProgramButton->hide();
229 // } 239 // }
230} 240}
231 241
232void KOEditorGeneral::pickAlarmSound() 242void KOEditorGeneral::pickAlarmSound()
233{ 243{
234 244
235 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() ); 245 //qDebug("KOEditorGeneral::pickAlarmSound() %d",mAlarmSoundButton->isOn() );
236 246
237 bool oldState = mAlarmSoundButton->isOn(); 247 bool oldState = mAlarmSoundButton->isOn();
238 248
239 QString fileName(KFileDialog::getOpenFileName(mAlarmSound, 249 QString fileName(KFileDialog::getOpenFileName(mAlarmSound,
240 i18n("*.wav|Wav Files"), 0)); 250 i18n("*.wav|Wav Files"), 0));
241 if (!fileName.isEmpty()) { 251 if (!fileName.isEmpty()) {
242 mAlarmSound = fileName; 252 mAlarmSound = fileName;
243 QToolTip::remove(mAlarmSoundButton); 253 QToolTip::remove(mAlarmSoundButton);
244 QString dispStr = i18n("Playing '%1'").arg(fileName); 254 QString dispStr = i18n("Playing '%1'").arg(fileName);
245 QToolTip::add(mAlarmSoundButton, dispStr); 255 QToolTip::add(mAlarmSoundButton, dispStr);
246 mAlarmProgramButton->setOn(false); 256 mAlarmProgramButton->setOn(false);
247 mAlarmSoundButton->setOn(true); 257 mAlarmSoundButton->setOn(true);
248 QToolTip::add(mAlarmProgramButton, i18n("No program set")); 258 QToolTip::add(mAlarmProgramButton, i18n("No program set"));
249 } else { 259 } else {
250 mAlarmProgramButton->setOn(oldState); 260 mAlarmProgramButton->setOn(oldState);
251 mAlarmSoundButton->setOn(!oldState); 261 mAlarmSoundButton->setOn(!oldState);
252 262
253 263
254 } 264 }
255 265
256 if (mAlarmProgramButton->isOn()) 266 if (mAlarmProgramButton->isOn())
257 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 267 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
258 if ( mAlarmSoundButton->isOn()) 268 if ( mAlarmSoundButton->isOn())
259 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 269 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
260 270
261} 271}
262 272
263void KOEditorGeneral::pickAlarmProgram() 273void KOEditorGeneral::pickAlarmProgram()
264{ 274{
265 bool oldState = mAlarmProgramButton->isOn(); 275 bool oldState = mAlarmProgramButton->isOn();
266 276
267 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0)); 277 QString fileName(KFileDialog::getOpenFileName(mAlarmProgram,i18n("Procedure Alarm: ") , 0));
268 if (!fileName.isEmpty()) { 278 if (!fileName.isEmpty()) {
269 mAlarmProgram = fileName; 279 mAlarmProgram = fileName;
270 QToolTip::remove(mAlarmProgramButton); 280 QToolTip::remove(mAlarmProgramButton);
271 QString dispStr = i18n("Running '%1'").arg(fileName); 281 QString dispStr = i18n("Running '%1'").arg(fileName);
272 QToolTip::add(mAlarmProgramButton, dispStr); 282 QToolTip::add(mAlarmProgramButton, dispStr);
273 mAlarmSoundButton->setOn(false); 283 mAlarmSoundButton->setOn(false);
274 mAlarmProgramButton->setOn(true); 284 mAlarmProgramButton->setOn(true);
275 QToolTip::add(mAlarmSoundButton, i18n("No sound set")); 285 QToolTip::add(mAlarmSoundButton, i18n("No sound set"));
276 } else { 286 } else {
277 mAlarmProgramButton->setOn(!oldState); 287 mAlarmProgramButton->setOn(!oldState);
278 mAlarmSoundButton->setOn(oldState); 288 mAlarmSoundButton->setOn(oldState);
279 } 289 }
280 290
281 if (mAlarmProgramButton->isOn()) 291 if (mAlarmProgramButton->isOn())
282 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) ); 292 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Proc.Al.: ") + getFittingPath(mAlarmProgram) );
283 if ( mAlarmSoundButton->isOn()) 293 if ( mAlarmSoundButton->isOn())
284 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) ); 294 ((QWidget*)parent())->topLevelWidget()->setCaption(i18n("Audio Al.: ") + getFittingPath(mAlarmSound) );
285 295
286} 296}
287 297
288 298
289QString KOEditorGeneral::getFittingPath( const QString s ) 299QString KOEditorGeneral::getFittingPath( const QString s )
290{ 300{
291 int maxlen = 50; 301 int maxlen = 50;
292 if ( QApplication::desktop()->width() < 640 ) { 302 if ( QApplication::desktop()->width() < 640 ) {
293 if ( QApplication::desktop()->width() < 320 ) 303 if ( QApplication::desktop()->width() < 320 )
294 maxlen = 22; 304 maxlen = 22;
295 else 305 else
296 maxlen = 35; 306 maxlen = 35;
297 } 307 }
298 if ( s.length() > maxlen ) { 308 if ( s.length() > maxlen ) {
299 return "..."+s.right(maxlen -3); 309 return "..."+s.right(maxlen -3);
300 } 310 }
301 return s; 311 return s;
302} 312}
303 313
304void KOEditorGeneral::enableAlarmEdit(bool enable) 314void KOEditorGeneral::enableAlarmEdit(bool enable)
305{ 315{
306 if ( enable ) { 316 if ( enable ) {
307 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) { 317 if (!mAlarmProgramButton->isOn() && !mAlarmSoundButton->isOn()) {
308 mAlarmSoundButton->setOn( true ); 318 mAlarmSoundButton->setOn( true );
309 if ( mAlarmSound.isEmpty() ) 319 if ( mAlarmSound.isEmpty() )
310 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 320 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
311 else { 321 else {
312 if ( ! QFile::exists( mAlarmSound ) ) 322 if ( ! QFile::exists( mAlarmSound ) )
313 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 323 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
314 } 324 }
315 } 325 }
316 } 326 }
317 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage); 327 ((QWidget*)parent())->topLevelWidget()->setCaption(mAlarmMessage);
318 mAlarmTimeEdit->setEnabled(enable); 328 mAlarmTimeEdit->setEnabled(enable);
319 mAlarmSoundButton->setEnabled(enable); 329 mAlarmSoundButton->setEnabled(enable);
320 mAlarmProgramButton->setEnabled(enable); 330 mAlarmProgramButton->setEnabled(enable);
321 mAlarmIncrCombo->setEnabled(enable); 331 mAlarmIncrCombo->setEnabled(enable);
322} 332}
323 333
324void KOEditorGeneral::disableAlarmEdit(bool disable) 334void KOEditorGeneral::disableAlarmEdit(bool disable)
325{ 335{
326 enableAlarmEdit( !disable ); 336 enableAlarmEdit( !disable );
327} 337}
328 338
329void KOEditorGeneral::enableAlarm( bool enable ) 339void KOEditorGeneral::enableAlarm( bool enable )
330{ 340{
331 enableAlarmEdit( enable ); 341 enableAlarmEdit( enable );
332} 342}
333 343
334void KOEditorGeneral::alarmDisable(bool disable) 344void KOEditorGeneral::alarmDisable(bool disable)
335{ 345{
336 if (!disable) { 346 if (!disable) {
337 //mAlarmBell->setEnabled(true); 347 //mAlarmBell->setEnabled(true);
338 mAlarmButton->setEnabled(true); 348 mAlarmButton->setEnabled(true);
339 } else { 349 } else {
340 //mAlarmBell->setEnabled(false); 350 //mAlarmBell->setEnabled(false);
341 mAlarmButton->setEnabled(false); 351 mAlarmButton->setEnabled(false);
342 mAlarmButton->setChecked(false); 352 mAlarmButton->setChecked(false);
343 mAlarmTimeEdit->setEnabled(false); 353 mAlarmTimeEdit->setEnabled(false);
344 mAlarmSoundButton->setEnabled(false); 354 mAlarmSoundButton->setEnabled(false);
345 mAlarmProgramButton->setEnabled(false); 355 mAlarmProgramButton->setEnabled(false);
346 mAlarmIncrCombo->setEnabled(false); 356 mAlarmIncrCombo->setEnabled(false);
347 } 357 }
348} 358}
349 359
350void KOEditorGeneral::setCategories(const QString &str) 360void KOEditorGeneral::setCategories(const QString &str)
351{ 361{
352 mCategoriesLabel->setText(str); 362 mCategoriesLabel->setText(str);
353} 363}
354 364
355void KOEditorGeneral::setDefaults(bool allDay) 365void KOEditorGeneral::setDefaults(bool allDay)
356{ 366{
357#if 0 367#if 0
358 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName()); 368 mOwnerLabel->setText(i18n("Owner: ") + KOPrefs::instance()->fullName());
359#endif 369#endif
360 370
361 mAlarmMessage = i18n("Edit new item"); 371 mAlarmMessage = i18n("Edit new item");
362 enableAlarmEdit( !allDay ); 372 enableAlarmEdit( !allDay );
363 373
364 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 374 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
365 int alarmTime; 375 int alarmTime;
366 int a[] = { 1,5,10,15,30,60,180, 1440 }; 376 int a[] = { 1,5,10,15,30,60,180, 1440 };
367 int index = KOPrefs::instance()->mAlarmTime; 377 int index = KOPrefs::instance()->mAlarmTime;
368 if (index < 0 || index > 7) { 378 if (index < 0 || index > 7) {
369 alarmTime = 15; 379 alarmTime = 15;
370 } else { 380 } else {
371 alarmTime = a[index]; 381 alarmTime = a[index];
372 } 382 }
373 mAlarmButton ->setChecked( false ); 383 mAlarmButton ->setChecked( false );
374 mAlarmTimeEdit->setValue(alarmTime); 384 mAlarmTimeEdit->setValue(alarmTime);
375 mAlarmIncrCombo->setCurrentItem(0); 385 mAlarmIncrCombo->setCurrentItem(0);
376 enableAlarmEdit( false ); 386 enableAlarmEdit( false );
377 //alarmDisable (false); 387 //alarmDisable (false);
378 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic); 388 mSecrecyCombo->setCurrentItem(Incidence::SecrecyPublic);
379 mCancelBox->setChecked( false ); 389 mCancelBox->setChecked( false );
380 mSummaryEdit->setEditText(""); 390 mSummaryEdit->setEditText("");
381 mLocationEdit->setEditText(""); 391 mLocationEdit->setEditText("");
382 mDescriptionEdit->setText(""); 392 mDescriptionEdit->setText("");
383 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 393 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
384 setCategories(""); 394 setCategories("");
385} 395}
386void KOEditorGeneral::setSecrecy( int num ) 396void KOEditorGeneral::setSecrecy( int num )
387{ 397{
388 mSecrecyCombo->setCurrentItem(num); 398 mSecrecyCombo->setCurrentItem(num);
389} 399}
390void KOEditorGeneral::readIncidence(Incidence *event) 400void KOEditorGeneral::readIncidence(Incidence *event)
391{ 401{
392 402
393 mAlarmMessage = event->summary(); 403 mAlarmMessage = event->summary();
394 if ( ! event->location().isEmpty() ) 404 if ( ! event->location().isEmpty() )
395 mAlarmMessage += " ("+event->location()+")"; 405 mAlarmMessage += " ("+event->location()+")";
396 mAlarmIncrCombo->setCurrentItem(0); 406 mAlarmIncrCombo->setCurrentItem(0);
397 mSummaryEdit->setEditText(event->summary()); 407 mSummaryEdit->setEditText(event->summary());
398 mLocationEdit->setEditText(event->location()); 408 mLocationEdit->setEditText(event->location());
399 mDescriptionEdit->setText(event->description()); 409 mDescriptionEdit->setText(event->description());
400 410
401#if 0 411#if 0
402 // organizer information 412 // organizer information
403 mOwnerLabel->setText(i18n("Owner: ") + event->organizer()); 413 mOwnerLabel->setText(i18n("Owner: ") + event->organizer());
404#endif 414#endif
405 415
406 enableAlarmEdit( event->isAlarmEnabled() ); 416 enableAlarmEdit( event->isAlarmEnabled() );
407 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) "); 417 //qDebug("KOEditorGeneral::readIncidence(Incidence *event) ");
408 if(!event->isAlarmEnabled()) { 418 if(!event->isAlarmEnabled()) {
409 // TODO: Implement a KPrefsComboItem to solve this in a clean way. 419 // TODO: Implement a KPrefsComboItem to solve this in a clean way.
410 int alarmTime; 420 int alarmTime;
411 int a[] = { 1,5,10,15,30,60,180, 1440 }; 421 int a[] = { 1,5,10,15,30,60,180, 1440 };
412 int index = KOPrefs::instance()->mAlarmTime; 422 int index = KOPrefs::instance()->mAlarmTime;
413 if (index < 0 || index > 7) { 423 if (index < 0 || index > 7) {
414 alarmTime = 15; 424 alarmTime = 15;
415 } else { 425 } else {
416 alarmTime = a[index]; 426 alarmTime = a[index];
417 } 427 }
418 mAlarmTimeEdit->setValue(alarmTime); 428 mAlarmTimeEdit->setValue(alarmTime);
419 } 429 }
420 mAlarmButton->setChecked( event->isAlarmEnabled() ); 430 mAlarmButton->setChecked( event->isAlarmEnabled() );
421 mSecrecyCombo->setCurrentItem(event->secrecy()); 431 mSecrecyCombo->setCurrentItem(event->secrecy());
422 mCancelBox->setChecked( event->cancelled() ); 432 mCancelBox->setChecked( event->cancelled() );
423 mAlarmProgramButton->setOn(false); 433 mAlarmProgramButton->setOn(false);
424 mAlarmSoundButton->setOn(false); 434 mAlarmSoundButton->setOn(false);
425 435
426 // set up alarm stuff 436 // set up alarm stuff
427 QPtrList<Alarm> alarms = event->alarms(); 437 QPtrList<Alarm> alarms = event->alarms();
428 Alarm* alarm; 438 Alarm* alarm;
429 mAlarmIncrCombo->setCurrentItem(0); 439 mAlarmIncrCombo->setCurrentItem(0);
430 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) { 440 for ( alarm = alarms.first(); alarm; alarm = alarms.next() ) {
431 int offset; 441 int offset;
432 if ( alarm->hasTime() ) { 442 if ( alarm->hasTime() ) {
433 QDateTime t = alarm->time(); 443 QDateTime t = alarm->time();
434 offset = event->dtStart().secsTo( t ); 444 offset = event->dtStart().secsTo( t );
435 } else { 445 } else {
436 offset = alarm->startOffset().asSeconds(); 446 offset = alarm->startOffset().asSeconds();
437 } 447 }
438 if ( offset != 0 ) { 448 if ( offset != 0 ) {
439 offset = offset / -60; // make minutes 449 offset = offset / -60; // make minutes
440 if (offset % 60 == 0) { // divides evenly into hours? 450 if (offset % 60 == 0) { // divides evenly into hours?
441 offset = offset / 60; 451 offset = offset / 60;
442 mAlarmIncrCombo->setCurrentItem(1); 452 mAlarmIncrCombo->setCurrentItem(1);
443 if (offset % 24 == 0) { // divides evenly into days? 453 if (offset % 24 == 0) { // divides evenly into days?
444 offset = offset / 24; 454 offset = offset / 24;
445 mAlarmIncrCombo->setCurrentItem(2); 455 mAlarmIncrCombo->setCurrentItem(2);
446 } 456 }
447 } 457 }
448 } 458 }
449 mAlarmTimeEdit->setValue( offset ); 459 mAlarmTimeEdit->setValue( offset );
450 if (alarm->type() == Alarm::Procedure) { 460 if (alarm->type() == Alarm::Procedure) {
451 461
452 mAlarmProgram = alarm->programFile(); 462 mAlarmProgram = alarm->programFile();
453 mAlarmProgramButton->setOn(true); 463 mAlarmProgramButton->setOn(true);
454 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram); 464 QString dispStr = i18n("Running '%1'").arg(mAlarmProgram);
455 QToolTip::add(mAlarmProgramButton, dispStr); 465 QToolTip::add(mAlarmProgramButton, dispStr);
456 } 466 }
457 else if (alarm->type() == Alarm::Audio) { 467 else if (alarm->type() == Alarm::Audio) {
458 mAlarmSound = alarm->audioFile(); 468 mAlarmSound = alarm->audioFile();
459 if ( ! QFile::exists( mAlarmSound ) ) 469 if ( ! QFile::exists( mAlarmSound ) )
460 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile; 470 mAlarmSound = KOPrefs::instance()->mDefaultAlarmFile;
461 mAlarmSoundButton->setOn(true); 471 mAlarmSoundButton->setOn(true);
462 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound); 472 QString dispStr = i18n("Playing '%1'").arg(mAlarmSound);
463 QToolTip::add(mAlarmSoundButton, dispStr); 473 QToolTip::add(mAlarmSoundButton, dispStr);
464 } 474 }
465 mAlarmButton->setChecked(alarm->enabled()); 475 mAlarmButton->setChecked(alarm->enabled());
466 enableAlarmEdit( alarm->enabled() ); 476 enableAlarmEdit( alarm->enabled() );
467 //qDebug("nableAlarmEdit( alarm->enabled() )********* "); 477 //qDebug("nableAlarmEdit( alarm->enabled() )********* ");
468 // TODO: Deal with multiple alarms 478 // TODO: Deal with multiple alarms
469 break; // For now, stop after the first alarm 479 break; // For now, stop after the first alarm
470 } 480 }
471 481
472 setCategories(event->categoriesStr()); 482 setCategories(event->categoriesStr());
473} 483}
474 484
475void KOEditorGeneral::writeIncidence(Incidence *event) 485void KOEditorGeneral::writeIncidence(Incidence *event)
476{ 486{
477 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl; 487 // kdDebug() << "KOEditorGeneral::writeEvent()" << endl;
478 mLocationEdit->save(KOLocationBox::LOCATION); 488 mLocationEdit->save(KOLocationBox::LOCATION);
479 event->setSummary(mSummaryEdit->currentText()); 489 event->setSummary(mSummaryEdit->currentText());
480 event->setLocation(mLocationEdit->currentText()); 490 event->setLocation(mLocationEdit->currentText());
481 event->setDescription(mDescriptionEdit->text()); 491 event->setDescription(mDescriptionEdit->text());
482 event->setCategories(mCategoriesLabel->text()); 492 event->setCategories(mCategoriesLabel->text());
483 event->setSecrecy(mSecrecyCombo->currentItem()); 493 event->setSecrecy(mSecrecyCombo->currentItem());
484 event->setCancelled(mCancelBox->isChecked() );; 494 event->setCancelled(mCancelBox->isChecked() );;
485 // alarm stuff 495 // alarm stuff
486 if (mAlarmButton->isChecked()) { 496 if (mAlarmButton->isChecked()) {
487 if (event->alarms().count() == 0) 497 if (event->alarms().count() == 0)
488 event->newAlarm(); 498 event->newAlarm();
489 QPtrList<Alarm> alarms = event->alarms(); 499 QPtrList<Alarm> alarms = event->alarms();
490 Alarm *alarm; 500 Alarm *alarm;
491 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) { 501 for (alarm = alarms.first(); alarm; alarm = alarms.next() ) {
492 alarm->setEnabled(true); 502 alarm->setEnabled(true);
493 int j = mAlarmTimeEdit->value()* -60; 503 int j = mAlarmTimeEdit->value()* -60;
494 if (mAlarmIncrCombo->currentItem() == 1) 504 if (mAlarmIncrCombo->currentItem() == 1)
495 j = j * 60; 505 j = j * 60;
496 else if (mAlarmIncrCombo->currentItem() == 2) 506 else if (mAlarmIncrCombo->currentItem() == 2)
497 j = j * (60 * 24); 507 j = j * (60 * 24);
498 alarm->setStartOffset( j ); 508 alarm->setStartOffset( j );
499 509
500 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) { 510 if (!mAlarmProgram.isEmpty() && mAlarmProgramButton->isOn()) {
501 alarm->setProcedureAlarm(mAlarmProgram); 511 alarm->setProcedureAlarm(mAlarmProgram);
502 } 512 }
503 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn()) 513 else if (!mAlarmSound.isEmpty() && mAlarmSoundButton->isOn())
504 alarm->setAudioAlarm(mAlarmSound); 514 alarm->setAudioAlarm(mAlarmSound);
505 else 515 else
506 alarm->setType(Alarm::Invalid); 516 alarm->setType(Alarm::Invalid);
507 //alarm->setAudioAlarm("default"); 517 //alarm->setAudioAlarm("default");
508 // TODO: Deal with multiple alarms 518 // TODO: Deal with multiple alarms
509 break; // For now, stop after the first alarm 519 break; // For now, stop after the first alarm
510 } 520 }
511 } else { 521 } else {
512 Alarm* alarm = event->alarms().first(); 522 Alarm* alarm = event->alarms().first();
513 if ( alarm ) { 523 if ( alarm ) {
514 alarm->setEnabled(false); 524 alarm->setEnabled(false);
515 alarm->setType(Alarm::Invalid); 525 alarm->setType(Alarm::Invalid);
516 } 526 }
517 } 527 }
518} 528}
diff --git a/korganizer/koeventeditor.cpp b/korganizer/koeventeditor.cpp
index e23e680..02d4a78 100644
--- a/korganizer/koeventeditor.cpp
+++ b/korganizer/koeventeditor.cpp
@@ -1,376 +1,378 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001,2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001,2002 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 the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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 <qframe.h> 25#include <qframe.h>
26#include <qpixmap.h> 26#include <qpixmap.h>
27#include <qhbox.h> 27#include <qhbox.h>
28#include <qdir.h> 28#include <qdir.h>
29#include <qlayout.h> 29#include <qlayout.h>
30#include <qwidgetstack.h> 30#include <qwidgetstack.h>
31#include <qapplication.h> 31#include <qapplication.h>
32 32
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <kstandarddirs.h> 34#include <kstandarddirs.h>
35#include <kdebug.h> 35#include <kdebug.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kfiledialog.h> 37#include <kfiledialog.h>
38#include <kmessagebox.h> 38#include <kmessagebox.h>
39#include <libkcal/calendarresources.h> 39#include <libkcal/calendarresources.h>
40#include <libkcal/resourcecalendar.h> 40#include <libkcal/resourcecalendar.h>
41#include <kresources/resourceselectdialog.h> 41#include <kresources/resourceselectdialog.h>
42 42
43#include <libkdepim/categoryselectdialog.h> 43#include <libkdepim/categoryselectdialog.h>
44#include <libkcal/calendarlocal.h> 44#include <libkcal/calendarlocal.h>
45#include <libkcal/icalformat.h> 45#include <libkcal/icalformat.h>
46 46
47#include "koprefs.h" 47#include "koprefs.h"
48 48
49#include "koeventeditor.h" 49#include "koeventeditor.h"
50extern int globalFlagBlockAgenda; 50extern int globalFlagBlockAgenda;
51 51
52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) : 52KOEventEditor::KOEventEditor( Calendar *calendar, QWidget *parent ) :
53 KOIncidenceEditor( i18n("Edit Event"), calendar, parent ) 53 KOIncidenceEditor( i18n("Edit Event"), calendar, parent )
54{ 54{
55 mEvent = 0; 55 mEvent = 0;
56 init(); 56 init();
57 if ( QApplication::desktop()->height() <= 240 )
58 hideButtons();
57} 59}
58 60
59KOEventEditor::~KOEventEditor() 61KOEventEditor::~KOEventEditor()
60{ 62{
61 //emit dialogClose( mEvent ); 63 //emit dialogClose( mEvent );
62} 64}
63 65
64void KOEventEditor::init() 66void KOEventEditor::init()
65{ 67{
66 68
67 setupGeneral(); 69 setupGeneral();
68 setupAttendeesTab(); 70 setupAttendeesTab();
69 setupRecurrence(); 71 setupRecurrence();
70 72
71 // Propagate date time settings to recurrence tab 73 // Propagate date time settings to recurrence tab
72 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)), 74 connect(mGeneral,SIGNAL(dateTimesChanged(QDateTime,QDateTime)),
73 mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime))); 75 mRecurrence,SLOT(setDateTimes(QDateTime,QDateTime)));
74 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)), 76 connect(mGeneral,SIGNAL(dateTimeStrChanged(const QString &)),
75 mRecurrence,SLOT(setDateTimeStr(const QString &))); 77 mRecurrence,SLOT(setDateTimeStr(const QString &)));
76 78
77 // Category dialog 79 // Category dialog
78 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 80 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
79 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)), 81 //connect(mCategoryDialog,SIGNAL(categoriesSelected(const QString &)),
80 // mGeneral,SLOT(setCategories(const QString &))); 82 // mGeneral,SLOT(setCategories(const QString &)));
81 83
82 84
83} 85}
84 86
85void KOEventEditor::reload() 87void KOEventEditor::reload()
86{ 88{
87 if ( mEvent ) readEvent( mEvent ); 89 if ( mEvent ) readEvent( mEvent );
88} 90}
89 91
90void KOEventEditor::setSecrecy( int sec ) 92void KOEventEditor::setSecrecy( int sec )
91{ 93{
92 mGeneral->setSecrecy( sec ); 94 mGeneral->setSecrecy( sec );
93} 95}
94void KOEventEditor::setCategories( QString s ) 96void KOEventEditor::setCategories( QString s )
95{ 97{
96 mGeneral->setCategories(s); 98 mGeneral->setCategories(s);
97 99
98} 100}
99void KOEventEditor::setupGeneral() 101void KOEventEditor::setupGeneral()
100{ 102{
101 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" ); 103 mGeneral = new KOEditorGeneralEvent( this, "KOEditorGeneralEvent" );
102 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 104 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
103 105
104 if( KOPrefs::instance()->mCompactDialogs ) { 106 if( KOPrefs::instance()->mCompactDialogs ) {
105 QFrame *topFrame = addPage(i18n("General")); 107 QFrame *topFrame = addPage(i18n("General"));
106 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 108 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
107 topLayout->setSpacing(spacingHint()-1); 109 topLayout->setSpacing(spacingHint()-1);
108 topLayout->setMargin(marginHint()-1); 110 topLayout->setMargin(marginHint()-1);
109 mGeneral->initHeader(topFrame,topLayout); 111 mGeneral->initHeader(topFrame,topLayout);
110 mGeneral->initTime(topFrame,topLayout); 112 mGeneral->initTime(topFrame,topLayout);
111// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 113// QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
112 mGeneral->initAlarm(topFrame,topLayout); 114 mGeneral->initAlarm(topFrame,topLayout);
113 mGeneral->enableAlarm( false ); 115 mGeneral->enableAlarm( false );
114 116
115 QBoxLayout *buttonLayout; 117 QBoxLayout *buttonLayout;
116 if ( QApplication::desktop()->width() < 500 ) 118 if ( QApplication::desktop()->width() < 500 && QApplication::desktop()->height() > 240 )
117 buttonLayout = new QVBoxLayout( topLayout ); 119 buttonLayout = new QVBoxLayout( topLayout );
118 else 120 else
119 buttonLayout = new QHBoxLayout( topLayout ); 121 buttonLayout = new QHBoxLayout( topLayout );
120 QHBox* buttonWidget = new QHBox (topFrame); 122 QHBox* buttonWidget = new QHBox (topFrame);
121 QIconSet icon; 123 QIconSet icon;
122 if ( QApplication::desktop()->width() < 321 ) 124 if ( QApplication::desktop()->width() < 321 )
123 icon = SmallIcon("fileexport16"); 125 icon = SmallIcon("fileexport16");
124 else 126 else
125 icon = SmallIcon("fileexport"); 127 icon = SmallIcon("fileexport");
126 QPushButton * loadTemplate = new QPushButton( buttonWidget); 128 QPushButton * loadTemplate = new QPushButton( buttonWidget);
127 QPushButton * saveTemplate = new QPushButton( buttonWidget); 129 QPushButton * saveTemplate = new QPushButton( buttonWidget);
128 saveTemplate->setIconSet (icon ) ; 130 saveTemplate->setIconSet (icon ) ;
129 int size = saveTemplate->sizeHint().height(); 131 int size = saveTemplate->sizeHint().height();
130 saveTemplate->setFixedSize( size, size ); 132 saveTemplate->setFixedSize( size, size );
131 if ( QApplication::desktop()->width() < 321 ) 133 if ( QApplication::desktop()->width() < 321 )
132 icon = SmallIcon("fileimport16"); 134 icon = SmallIcon("fileimport16");
133 else 135 else
134 icon = SmallIcon("fileimport"); 136 icon = SmallIcon("fileimport");
135 loadTemplate->setIconSet (icon ) ; 137 loadTemplate->setIconSet (icon ) ;
136 loadTemplate->setFixedSize( size, size ); 138 loadTemplate->setFixedSize( size, size );
137 buttonLayout->addWidget( buttonWidget ); 139 buttonLayout->addWidget( buttonWidget );
138 mGeneral->initCategories( topFrame, buttonLayout ); 140 mGeneral->initCategories( topFrame, buttonLayout );
139 141
140 topLayout->addStretch( 1 ); 142 topLayout->addStretch( 1 );
141 143
142 QFrame *topFrame2 = addPage(i18n("Details")); 144 QFrame *topFrame2 = addPage(i18n("Details"));
143 145
144 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 146 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
145 topLayout2->setSpacing(spacingHint()); 147 topLayout2->setSpacing(spacingHint());
146 148
147 mGeneral->initClass(topFrame2,topLayout2); 149 mGeneral->initClass(topFrame2,topLayout2);
148 mGeneral->initSecrecy( topFrame2, topLayout2 ); 150 mGeneral->initSecrecy( topFrame2, topLayout2 );
149 mGeneral->initDescription(topFrame2,topLayout2); 151 mGeneral->initDescription(topFrame2,topLayout2);
150 152
151 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 153 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
152 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 154 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
153 } else { 155 } else {
154 QFrame *topFrame = addPage(i18n("General")); 156 QFrame *topFrame = addPage(i18n("General"));
155 157
156 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 158 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
157 topLayout->setSpacing(spacingHint()); 159 topLayout->setSpacing(spacingHint());
158 160
159 mGeneral->initHeader(topFrame,topLayout); 161 mGeneral->initHeader(topFrame,topLayout);
160 mGeneral->initTime(topFrame,topLayout); 162 mGeneral->initTime(topFrame,topLayout);
161 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 163 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
162 mGeneral->initAlarm(topFrame,alarmLineLayout); 164 mGeneral->initAlarm(topFrame,alarmLineLayout);
163 mGeneral->initClass(topFrame,alarmLineLayout); 165 mGeneral->initClass(topFrame,alarmLineLayout);
164 mGeneral->initDescription(topFrame,topLayout); 166 mGeneral->initDescription(topFrame,topLayout);
165 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 167 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
166 mGeneral->initCategories( topFrame, detailsLayout ); 168 mGeneral->initCategories( topFrame, detailsLayout );
167 mGeneral->initSecrecy( topFrame, detailsLayout ); 169 mGeneral->initSecrecy( topFrame, detailsLayout );
168 } 170 }
169 171
170 mGeneral->finishSetup(); 172 mGeneral->finishSetup();
171 173
172} 174}
173 175
174void KOEventEditor::setupRecurrence() 176void KOEventEditor::setupRecurrence()
175{ 177{
176 QFrame *topFrame = addPage( i18n("Recurrence") ); 178 QFrame *topFrame = addPage( i18n("Recurrence") );
177 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 179 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
178 180
179 mRecurrence = new KOEditorRecurrence( topFrame ); 181 mRecurrence = new KOEditorRecurrence( topFrame );
180 topLayout->addWidget( mRecurrence ); 182 topLayout->addWidget( mRecurrence );
181} 183}
182 184
183void KOEventEditor::editEvent(Event *event, bool showDescription) 185void KOEventEditor::editEvent(Event *event, bool showDescription)
184{ 186{
185 // init(); 187 // init();
186 188
187 mEvent = event; 189 mEvent = event;
188 readEvent(mEvent); 190 readEvent(mEvent);
189 if ( showDescription ) { 191 if ( showDescription ) {
190 showPage( 1 ); 192 showPage( 1 );
191 mGeneral->setFocusOn( 1 ); 193 mGeneral->setFocusOn( 1 );
192 } else { 194 } else {
193 showPage( 0 ); 195 showPage( 0 );
194 mGeneral->setFocusOn( 2 ); 196 mGeneral->setFocusOn( 2 );
195 } 197 }
196} 198}
197 199
198void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay ) 200void KOEventEditor::newEvent( QDateTime from, QDateTime to, bool allDay )
199{ 201{
200 // init(); 202 // init();
201 203
202 mEvent = 0; 204 mEvent = 0;
203 setDefaults(from,to,allDay); 205 setDefaults(from,to,allDay);
204} 206}
205 207
206void KOEventEditor::loadDefaults() 208void KOEventEditor::loadDefaults()
207{ 209{
208 int fmt = KOPrefs::instance()->mStartTime; 210 int fmt = KOPrefs::instance()->mStartTime;
209 211
210 QDateTime from(QDate::currentDate(), QTime(fmt,0,0)); 212 QDateTime from(QDate::currentDate(), QTime(fmt,0,0));
211 QDateTime to(QDate::currentDate(), 213 QDateTime to(QDate::currentDate(),
212 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0)); 214 QTime(fmt+KOPrefs::instance()->mDefaultDuration,0,0));
213 215
214 setDefaults(from,to,false); 216 setDefaults(from,to,false);
215} 217}
216 218
217bool KOEventEditor::processInput( bool emitTime ) 219bool KOEventEditor::processInput( bool emitTime )
218{ 220{
219 if (!validateInput()) return false; 221 if (!validateInput()) return false;
220 222
221 Event *event = 0; 223 Event *event = 0;
222 224
223 if (mEvent) event = mEvent; 225 if (mEvent) event = mEvent;
224 else { 226 else {
225 event = new Event; 227 event = new Event;
226 event->setOrganizer(KOPrefs::instance()->email()); 228 event->setOrganizer(KOPrefs::instance()->email());
227 } 229 }
228 230
229 writeEvent(event); 231 writeEvent(event);
230 if ( emitTime ) { 232 if ( emitTime ) {
231 globalFlagBlockAgenda = 1; 233 globalFlagBlockAgenda = 1;
232 emit showAgendaView( false ); 234 emit showAgendaView( false );
233 emit jumpToTime( event->dtStart().date() ); 235 emit jumpToTime( event->dtStart().date() );
234 globalFlagBlockAgenda = 2; 236 globalFlagBlockAgenda = 2;
235 237
236 } 238 }
237 if (mEvent) { 239 if (mEvent) {
238 event->setRevision(event->revision()+1); 240 event->setRevision(event->revision()+1);
239 emit eventChanged(event); 241 emit eventChanged(event);
240 } else { 242 } else {
241 mCalendar->addEvent(event); 243 mCalendar->addEvent(event);
242 mEvent = event; 244 mEvent = event;
243 emit eventAdded(event); 245 emit eventAdded(event);
244 } 246 }
245 247
246 return true; 248 return true;
247} 249}
248 250
249void KOEventEditor::deleteEvent() 251void KOEventEditor::deleteEvent()
250{ 252{
251 kdDebug() << "Delete event" << endl; 253 kdDebug() << "Delete event" << endl;
252 254
253 if (mEvent) { 255 if (mEvent) {
254 if (KOPrefs::instance()->mConfirm) { 256 if (KOPrefs::instance()->mConfirm) {
255 switch (msgItemDelete()) { 257 switch (msgItemDelete()) {
256 case KMessageBox::Continue: // OK 258 case KMessageBox::Continue: // OK
257 emit eventToBeDeleted(mEvent); 259 emit eventToBeDeleted(mEvent);
258 emit dialogClose(mEvent); 260 emit dialogClose(mEvent);
259 mCalendar->deleteEvent(mEvent); 261 mCalendar->deleteEvent(mEvent);
260 emit eventDeleted(); 262 emit eventDeleted();
261 reject(); 263 reject();
262 break; 264 break;
263 } 265 }
264 } 266 }
265 else { 267 else {
266 emit eventToBeDeleted(mEvent); 268 emit eventToBeDeleted(mEvent);
267 emit dialogClose(mEvent); 269 emit dialogClose(mEvent);
268 mCalendar->deleteEvent(mEvent); 270 mCalendar->deleteEvent(mEvent);
269 emit eventDeleted(); 271 emit eventDeleted();
270 reject(); 272 reject();
271 } 273 }
272 } else { 274 } else {
273 reject(); 275 reject();
274 } 276 }
275} 277}
276 278
277void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay) 279void KOEventEditor::setDefaults(QDateTime from, QDateTime to, bool allDay)
278{ 280{
279 mGeneral->setDefaults(from,to,allDay); 281 mGeneral->setDefaults(from,to,allDay);
280 mDetails->setDefaults(); 282 mDetails->setDefaults();
281 mRecurrence->setDefaults(from,to,allDay); 283 mRecurrence->setDefaults(from,to,allDay);
282 showPage( 0 ); 284 showPage( 0 );
283 mGeneral->setFocusOn( 2 ); 285 mGeneral->setFocusOn( 2 );
284} 286}
285 287
286void KOEventEditor::readEvent( Event *event, bool tmpl ) 288void KOEventEditor::readEvent( Event *event, bool tmpl )
287{ 289{
288 mGeneral->readEvent( event, tmpl ); 290 mGeneral->readEvent( event, tmpl );
289 mDetails->readEvent( event ); 291 mDetails->readEvent( event );
290 mRecurrence->readEvent( event ); 292 mRecurrence->readEvent( event );
291 293
292 // categories 294 // categories
293 //mCategoryDialog->setSelected( event->categories() ); 295 //mCategoryDialog->setSelected( event->categories() );
294} 296}
295 297
296void KOEventEditor::writeEvent(Event *event) 298void KOEventEditor::writeEvent(Event *event)
297{ 299{
298 mGeneral->writeEvent( event ); 300 mGeneral->writeEvent( event );
299 mDetails->writeEvent( event ); 301 mDetails->writeEvent( event );
300 302
301 if ( event->organizer() == KOPrefs::instance()->email() ) { 303 if ( event->organizer() == KOPrefs::instance()->email() ) {
302 Event *ev = new Event( *event ); 304 Event *ev = new Event( *event );
303 ev->registerObserver(0); 305 ev->registerObserver(0);
304 mDetails->cancelAttendeeEvent( ev ); 306 mDetails->cancelAttendeeEvent( ev );
305 if ( ev->attendeeCount() > 0 ) { 307 if ( ev->attendeeCount() > 0 ) {
306 emit deleteAttendee( ev ); 308 emit deleteAttendee( ev );
307 } 309 }
308 delete(ev); 310 delete(ev);
309 } 311 }
310 312
311 mRecurrence->writeEvent(event); 313 mRecurrence->writeEvent(event);
312} 314}
313 315
314bool KOEventEditor::validateInput() 316bool KOEventEditor::validateInput()
315{ 317{
316 if (!mGeneral->validateInput()) return false; 318 if (!mGeneral->validateInput()) return false;
317 if (!mDetails->validateInput()) return false; 319 if (!mDetails->validateInput()) return false;
318 if (!mRecurrence->validateInput()) return false; 320 if (!mRecurrence->validateInput()) return false;
319 return true; 321 return true;
320} 322}
321 323
322int KOEventEditor::msgItemDelete() 324int KOEventEditor::msgItemDelete()
323{ 325{
324 return KMessageBox::warningContinueCancel(this, 326 return KMessageBox::warningContinueCancel(this,
325 i18n("This item will be permanently deleted."), 327 i18n("This item will be permanently deleted."),
326 i18n("KOrganizer Confirmation"),i18n("Delete")); 328 i18n("KOrganizer Confirmation"),i18n("Delete"));
327} 329}
328 330
329void KOEventEditor::slotLoadTemplate() 331void KOEventEditor::slotLoadTemplate()
330{ 332{
331 333
332 QString fileName =locateLocal( "templates", "events" ); 334 QString fileName =locateLocal( "templates", "events" );
333 QDir t_dir; 335 QDir t_dir;
334 if ( !t_dir.exists(fileName) ) 336 if ( !t_dir.exists(fileName) )
335 t_dir.mkdir ( fileName ); 337 t_dir.mkdir ( fileName );
336 fileName += "/event"; 338 fileName += "/event";
337 fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this ); 339 fileName = KFileDialog::getOpenFileName( fileName , i18n("Load Event template"), this );
338 if ( fileName.length() == 0 ) 340 if ( fileName.length() == 0 )
339 return; 341 return;
340 CalendarLocal cal; 342 CalendarLocal cal;
341 ICalFormat format; 343 ICalFormat format;
342 if ( !format.load( &cal, fileName ) ) { 344 if ( !format.load( &cal, fileName ) ) {
343 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 345 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
344 .arg( fileName ) ); 346 .arg( fileName ) );
345 return ; 347 return ;
346 } 348 }
347 QPtrList<Event> events = cal.events(); 349 QPtrList<Event> events = cal.events();
348 Event* event = events.first(); 350 Event* event = events.first();
349 if ( !event ) { 351 if ( !event ) {
350 KMessageBox::error( this, 352 KMessageBox::error( this,
351 i18n("Template does not contain\na valid Event.")); 353 i18n("Template does not contain\na valid Event."));
352 } else { 354 } else {
353 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl; 355 kdDebug() << "KOEventEditor::slotLoadTemplate(): readTemplate" << endl;
354 readEvent( event, true ); 356 readEvent( event, true );
355 } 357 }
356} 358}
357 359
358 360
359void KOEventEditor::slotSaveTemplate() 361void KOEventEditor::slotSaveTemplate()
360{ 362{
361 QString fileName =locateLocal( "templates", "events" ); 363 QString fileName =locateLocal( "templates", "events" );
362 QDir t_dir; 364 QDir t_dir;
363 if ( !t_dir.exists(fileName) ) 365 if ( !t_dir.exists(fileName) )
364 t_dir.mkdir ( fileName ); 366 t_dir.mkdir ( fileName );
365 fileName += "/event"; 367 fileName += "/event";
366 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this ); 368 fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Event template"), this );
367 if ( fileName.length() > 0 ) 369 if ( fileName.length() > 0 )
368 saveTemplate( fileName ); 370 saveTemplate( fileName );
369} 371}
370 372
371void KOEventEditor::saveTemplate( const QString &templateName ) 373void KOEventEditor::saveTemplate( const QString &templateName )
372{ 374{
373 Event *event = new Event; 375 Event *event = new Event;
374 writeEvent( event ); 376 writeEvent( event );
375 saveAsTemplate( event, templateName ); 377 saveAsTemplate( event, templateName );
376} 378}
diff --git a/korganizer/kotodoeditor.cpp b/korganizer/kotodoeditor.cpp
index 5513e8b..9073bca 100644
--- a/korganizer/kotodoeditor.cpp
+++ b/korganizer/kotodoeditor.cpp
@@ -1,444 +1,446 @@
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"
53extern int globalFlagBlockAgenda; 53extern int globalFlagBlockAgenda;
54 54
55KOTodoEditor::KOTodoEditor( Calendar *calendar, QWidget *parent ) : 55KOTodoEditor::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 if ( QApplication::desktop()->height() <= 240 )
63 hideButtons();
62} 64}
63 65
64KOTodoEditor::~KOTodoEditor() 66KOTodoEditor::~KOTodoEditor()
65{ 67{
66 emit dialogClose( mTodo ); 68 emit dialogClose( mTodo );
67} 69}
68 70
69void KOTodoEditor::init() 71void KOTodoEditor::init()
70{ 72{
71 setupGeneral(); 73 setupGeneral();
72 setupAttendeesTab(); 74 setupAttendeesTab();
73 setupRecurrence(); 75 setupRecurrence();
74 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence())); 76 connect(mGeneral,SIGNAL(datesChecked()),this ,SLOT(checkRecurrence()));
75 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") ); 77 mRecurrence->setDateTimeStr( i18n("<i>The recurrence is computed from the start datetime!</i>") );
76} 78}
77void KOTodoEditor::setupRecurrence() 79void KOTodoEditor::setupRecurrence()
78{ 80{
79 QFrame *topFrame = addPage( i18n("Recurrence") ); 81 QFrame *topFrame = addPage( i18n("Recurrence") );
80 QBoxLayout *topLayout = new QVBoxLayout( topFrame ); 82 QBoxLayout *topLayout = new QVBoxLayout( topFrame );
81 83
82 mRecurrence = new KOEditorRecurrence( topFrame ); 84 mRecurrence = new KOEditorRecurrence( topFrame );
83 topLayout->addWidget( mRecurrence ); 85 topLayout->addWidget( mRecurrence );
84} 86}
85 87
86void KOTodoEditor::setCategories( QString s ) 88void KOTodoEditor::setCategories( QString s )
87{ 89{
88 mGeneral->setCategories(s); 90 mGeneral->setCategories(s);
89} 91}
90void KOTodoEditor::setSecrecy( int sec ) 92void KOTodoEditor::setSecrecy( int sec )
91{ 93{
92 mGeneral->setSecrecy( sec ); 94 mGeneral->setSecrecy( sec );
93} 95}
94void KOTodoEditor::reload() 96void KOTodoEditor::reload()
95{ 97{
96 if ( mTodo ) readTodo( mTodo ); 98 if ( mTodo ) readTodo( mTodo );
97} 99}
98 100
99void KOTodoEditor::setupGeneral() 101void KOTodoEditor::setupGeneral()
100{ 102{
101 mGeneral = new KOEditorGeneralTodo(this); 103 mGeneral = new KOEditorGeneralTodo(this);
102 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) ); 104 connect ( mGeneral, SIGNAL ( allAccepted() ), this, SLOT ( slotOk () ) );
103 105
104 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show())); 106 // connect(mGeneral,SIGNAL(openCategoryDialog()),mCategoryDialog,SLOT(show()));
105 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)), 107 //connect(mCategoryDialog, SIGNAL(categoriesSelected(const QString &)),
106 // mGeneral,SLOT(setCategories(const QString &))); 108 // mGeneral,SLOT(setCategories(const QString &)));
107 109
108 if (KOPrefs::instance()->mCompactDialogs) { 110 if (KOPrefs::instance()->mCompactDialogs) {
109 QFrame *topFrame = addPage(i18n("General")); 111 QFrame *topFrame = addPage(i18n("General"));
110 112
111 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 113 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
112 if ( QApplication::desktop()->width() < 480 ) { 114 if ( QApplication::desktop()->width() < 480 ) {
113 topLayout->setMargin(marginHintSmall()); 115 topLayout->setMargin(marginHintSmall());
114 topLayout->setSpacing(spacingHintSmall()); 116 topLayout->setSpacing(spacingHintSmall());
115 } else { 117 } else {
116 topLayout->setMargin(marginHint()); 118 topLayout->setMargin(marginHint());
117 topLayout->setSpacing(spacingHint()); 119 topLayout->setSpacing(spacingHint());
118 } 120 }
119 mGeneral->initHeader(topFrame,topLayout); 121 mGeneral->initHeader(topFrame,topLayout);
120 mGeneral->initTime(topFrame,topLayout); 122 mGeneral->initTime(topFrame,topLayout);
121 mGeneral->initAlarm(topFrame,topLayout); 123 mGeneral->initAlarm(topFrame,topLayout);
122 mGeneral->enableAlarm( false ); 124 mGeneral->enableAlarm( false );
123 125
124 126
125 QBoxLayout *priorityLayout; 127 QBoxLayout *priorityLayout;
126 if ( QApplication::desktop()->width() < 500 ) 128 if ( QApplication::desktop()->width() < 500 )
127 priorityLayout = new QVBoxLayout( topLayout ); 129 priorityLayout = new QVBoxLayout( topLayout );
128 else 130 else
129 priorityLayout = new QHBoxLayout( topLayout ); 131 priorityLayout = new QHBoxLayout( topLayout );
130 QWidget* prioWidget = new QWidget (topFrame); 132 QWidget* prioWidget = new QWidget (topFrame);
131 priorityLayout->addWidget( prioWidget ); 133 priorityLayout->addWidget( prioWidget );
132 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget); 134 QHBoxLayout* priorityLayout2 = new QHBoxLayout( prioWidget);
133 135
134 136
135 QIconSet icon; 137 QIconSet icon;
136 if ( QApplication::desktop()->width() < 321 ) 138 if ( QApplication::desktop()->width() < 321 )
137 icon = SmallIcon("fileimport16"); 139 icon = SmallIcon("fileimport16");
138 else 140 else
139 icon = SmallIcon("fileimport"); 141 icon = SmallIcon("fileimport");
140 QPushButton * loadTemplate = new QPushButton( prioWidget); 142 QPushButton * loadTemplate = new QPushButton( prioWidget);
141 loadTemplate->setIconSet (icon ) ; 143 loadTemplate->setIconSet (icon ) ;
142 int size = loadTemplate->sizeHint().height(); 144 int size = loadTemplate->sizeHint().height();
143 loadTemplate->setFixedSize( size, size ); 145 loadTemplate->setFixedSize( size, size );
144 if ( QApplication::desktop()->width() < 321 ) 146 if ( QApplication::desktop()->width() < 321 )
145 icon = SmallIcon("fileexport16"); 147 icon = SmallIcon("fileexport16");
146 else 148 else
147 icon = SmallIcon("fileexport"); 149 icon = SmallIcon("fileexport");
148 QPushButton * saveTemplate = new QPushButton( prioWidget); 150 QPushButton * saveTemplate = new QPushButton( prioWidget);
149 saveTemplate->setIconSet (icon ) ; 151 saveTemplate->setIconSet (icon ) ;
150 saveTemplate->setFixedSize( size, size ); 152 saveTemplate->setFixedSize( size, size );
151 153
152 priorityLayout2->addWidget(loadTemplate); 154 priorityLayout2->addWidget(loadTemplate);
153 priorityLayout2->addWidget(saveTemplate); 155 priorityLayout2->addWidget(saveTemplate);
154 mGeneral->initPriority(prioWidget,priorityLayout2); 156 mGeneral->initPriority(prioWidget,priorityLayout2);
155 mGeneral->initCategories( topFrame, priorityLayout ); 157 mGeneral->initCategories( topFrame, priorityLayout );
156 topLayout->addStretch(1); 158 topLayout->addStretch(1);
157 159
158 QFrame *topFrame2 = addPage(i18n("Details")); 160 QFrame *topFrame2 = addPage(i18n("Details"));
159 161
160 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2); 162 QBoxLayout *topLayout2 = new QVBoxLayout(topFrame2);
161 topLayout2->setMargin(marginHint()); 163 topLayout2->setMargin(marginHint());
162 topLayout2->setSpacing(spacingHint()); 164 topLayout2->setSpacing(spacingHint());
163 165
164 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 ); 166 QHBoxLayout *completionLayout = new QHBoxLayout( topLayout2 );
165 mGeneral->initCompletion(topFrame2,completionLayout); 167 mGeneral->initCompletion(topFrame2,completionLayout);
166 168
167 169
168 mGeneral->initSecrecy( topFrame2, topLayout2 ); 170 mGeneral->initSecrecy( topFrame2, topLayout2 );
169 mGeneral->initDescription(topFrame2,topLayout2); 171 mGeneral->initDescription(topFrame2,topLayout2);
170 172
171 // QHBox * hb = new QHBox ( topFrame2 ); 173 // QHBox * hb = new QHBox ( topFrame2 );
172 // topLayout2->addWidget(hb); 174 // topLayout2->addWidget(hb);
173 // hb->setSpacing( 3 ); 175 // hb->setSpacing( 3 );
174 176
175 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); 177 connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) );
176 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); 178 connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) );
177 179
178 } else { 180 } else {
179 QFrame *topFrame = addPage(i18n("General")); 181 QFrame *topFrame = addPage(i18n("General"));
180 182
181 QBoxLayout *topLayout = new QVBoxLayout(topFrame); 183 QBoxLayout *topLayout = new QVBoxLayout(topFrame);
182 topLayout->setSpacing(spacingHint()); 184 topLayout->setSpacing(spacingHint());
183 185
184 mGeneral->initHeader(topFrame,topLayout); 186 mGeneral->initHeader(topFrame,topLayout);
185 mGeneral->initTime(topFrame,topLayout); 187 mGeneral->initTime(topFrame,topLayout);
186 mGeneral->initStatus(topFrame,topLayout); 188 mGeneral->initStatus(topFrame,topLayout);
187 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout); 189 QBoxLayout *alarmLineLayout = new QHBoxLayout(topLayout);
188 mGeneral->initAlarm(topFrame,alarmLineLayout); 190 mGeneral->initAlarm(topFrame,alarmLineLayout);
189 mGeneral->initDescription(topFrame,topLayout); 191 mGeneral->initDescription(topFrame,topLayout);
190 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout); 192 QBoxLayout *detailsLayout = new QHBoxLayout(topLayout);
191 mGeneral->initCategories( topFrame, detailsLayout ); 193 mGeneral->initCategories( topFrame, detailsLayout );
192 mGeneral->initSecrecy( topFrame, detailsLayout ); 194 mGeneral->initSecrecy( topFrame, detailsLayout );
193 } 195 }
194 mGeneral->finishSetup(); 196 mGeneral->finishSetup();
195 197
196} 198}
197 199
198void KOTodoEditor::editTodo(Todo *todo, bool editDescription) 200void KOTodoEditor::editTodo(Todo *todo, bool editDescription)
199{ 201{
200 //init(); 202 //init();
201 203
202 mTodo = todo; 204 mTodo = todo;
203 readTodo(mTodo); 205 readTodo(mTodo);
204 if ( editDescription ) { 206 if ( editDescription ) {
205 showPage( 1 ); 207 showPage( 1 );
206 mGeneral->setFocusOn( 1 ); 208 mGeneral->setFocusOn( 1 );
207 } else { 209 } else {
208 showPage( 0 ); 210 showPage( 0 );
209 mGeneral->setFocusOn( 2 ); 211 mGeneral->setFocusOn( 2 );
210 } 212 }
211 checkRecurrence(); 213 checkRecurrence();
212} 214}
213 215
214void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay) 216void KOTodoEditor::newTodo(QDateTime due,Todo *relatedTodo,bool allDay)
215{ 217{
216 //init(); 218 //init();
217 219
218 mTodo = 0; 220 mTodo = 0;
219 setDefaults(due,relatedTodo,allDay); 221 setDefaults(due,relatedTodo,allDay);
220} 222}
221 223
222void KOTodoEditor::loadDefaults() 224void KOTodoEditor::loadDefaults()
223{ 225{
224 setDefaults(QDateTime::currentDateTime().addDays(7),0,false); 226 setDefaults(QDateTime::currentDateTime().addDays(7),0,false);
225} 227}
226 228
227bool KOTodoEditor::processInput( bool emitTime ) 229bool KOTodoEditor::processInput( bool emitTime )
228{ 230{
229 if (!validateInput()) return false; 231 if (!validateInput()) return false;
230 232
231 Todo *todo = 0; 233 Todo *todo = 0;
232 234
233 if (mTodo) todo = mTodo; 235 if (mTodo) todo = mTodo;
234 else { 236 else {
235 todo = new Todo; 237 todo = new Todo;
236 todo->setOrganizer(KOPrefs::instance()->email()); 238 todo->setOrganizer(KOPrefs::instance()->email());
237 } 239 }
238 240
239 writeTodo(todo); 241 writeTodo(todo);
240 if ( emitTime ) { 242 if ( emitTime ) {
241 globalFlagBlockAgenda = 1; 243 globalFlagBlockAgenda = 1;
242 emit showAgendaView( false ); 244 emit showAgendaView( false );
243 if ( todo->hasDueDate() ) 245 if ( todo->hasDueDate() )
244 emit jumpToTime( todo->dtDue().date() ); 246 emit jumpToTime( todo->dtDue().date() );
245 globalFlagBlockAgenda = 2; 247 globalFlagBlockAgenda = 2;
246 } 248 }
247 if (mTodo) { 249 if (mTodo) {
248 todo->setRevision(todo->revision()+1); 250 todo->setRevision(todo->revision()+1);
249 emit todoChanged(todo); 251 emit todoChanged(todo);
250 } else { 252 } else {
251 mCalendar->addTodo(todo); 253 mCalendar->addTodo(todo);
252 mTodo = todo; 254 mTodo = todo;
253 emit todoAdded(todo); 255 emit todoAdded(todo);
254 } 256 }
255 257
256 return true; 258 return true;
257} 259}
258 260
259void KOTodoEditor::deleteTodo() 261void KOTodoEditor::deleteTodo()
260{ 262{
261 if (mTodo) { 263 if (mTodo) {
262 if (KOPrefs::instance()->mConfirm) { 264 if (KOPrefs::instance()->mConfirm) {
263 switch (msgItemDelete()) { 265 switch (msgItemDelete()) {
264 case KMessageBox::Continue: // OK 266 case KMessageBox::Continue: // OK
265 emit todoToBeDeleted(mTodo); 267 emit todoToBeDeleted(mTodo);
266 emit dialogClose(mTodo); 268 emit dialogClose(mTodo);
267 mCalendar->deleteTodo(mTodo); 269 mCalendar->deleteTodo(mTodo);
268 emit todoDeleted(); 270 emit todoDeleted();
269 reject(); 271 reject();
270 break; 272 break;
271 } 273 }
272 } 274 }
273 else { 275 else {
274 emit todoToBeDeleted(mTodo); 276 emit todoToBeDeleted(mTodo);
275 emit dialogClose(mTodo); 277 emit dialogClose(mTodo);
276 mCalendar->deleteTodo(mTodo); 278 mCalendar->deleteTodo(mTodo);
277 emit todoDeleted(); 279 emit todoDeleted();
278 reject(); 280 reject();
279 } 281 }
280 } else { 282 } else {
281 reject(); 283 reject();
282 } 284 }
283} 285}
284 286
285void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay) 287void KOTodoEditor::setDefaults(QDateTime due,Todo *relatedEvent,bool allDay)
286{ 288{
287 mRelatedTodo = relatedEvent; 289 mRelatedTodo = relatedEvent;
288 290
289 mGeneral->setDefaults(due,allDay); 291 mGeneral->setDefaults(due,allDay);
290 mDetails->setDefaults(); 292 mDetails->setDefaults();
291 showPage( 0 ); 293 showPage( 0 );
292 if ( mRelatedTodo ) { 294 if ( mRelatedTodo ) {
293 mGeneral->setCategories (mRelatedTodo->categoriesStr ()); 295 mGeneral->setCategories (mRelatedTodo->categoriesStr ());
294 mGeneral->setSecrecy (mRelatedTodo->secrecy ()); 296 mGeneral->setSecrecy (mRelatedTodo->secrecy ());
295 if ( mRelatedTodo->priority() < 3 ) 297 if ( mRelatedTodo->priority() < 3 )
296 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1); 298 mGeneral->mPriorityCombo->setCurrentItem(mRelatedTodo->priority()-1);
297 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": "); 299 mGeneral->mSummaryEdit->lineEdit()->setText(mRelatedTodo->summary()+": ");
298 int len = mRelatedTodo->summary().length(); 300 int len = mRelatedTodo->summary().length();
299 mGeneral->mSummaryEdit->lineEdit()->setFocus(); 301 mGeneral->mSummaryEdit->lineEdit()->setFocus();
300 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 ); 302 mGeneral->mSummaryEdit->lineEdit()->setCursorPosition ( len+2 );
301 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 ); 303 mGeneral->mSummaryEdit->lineEdit()->setSelection ( 0, len+2 );
302 304
303 } else 305 } else
304 mGeneral->setFocusOn( 2 ); 306 mGeneral->setFocusOn( 2 );
305 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 307 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
306 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); 308 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
307} 309}
308void KOTodoEditor::checkRecurrence() 310void KOTodoEditor::checkRecurrence()
309{ 311{
310 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 312 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
311 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true ); 313 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), true );
312 314
313 if ( mTodo ) 315 if ( mTodo )
314 mRecurrence->readEvent( mTodo ); 316 mRecurrence->readEvent( mTodo );
315 else { 317 else {
316 bool time = mGeneral->mTimeButton->isChecked(); 318 bool time = mGeneral->mTimeButton->isChecked();
317 QDateTime from,to; 319 QDateTime from,to;
318 if ( time ) { 320 if ( time ) {
319 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ; 321 to = QDateTime( mGeneral->mDueDateEdit->date(), mGeneral->mDueTimeEdit->getTime() ) ;
320 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ; 322 from = QDateTime( mGeneral->mStartDateEdit->date(),mGeneral->mStartTimeEdit->getTime( )) ;
321 } else { 323 } else {
322 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ; 324 to = QDateTime( mGeneral->mDueDateEdit->date(), QTime( 0,0,0) ) ;
323 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ; 325 from = QDateTime( mGeneral->mStartDateEdit->date(),QTime( 0,0,0) ) ;
324 } 326 }
325 if ( to < from ) 327 if ( to < from )
326 to = from; 328 to = from;
327 mRecurrence->setDefaults(from,to,!time); 329 mRecurrence->setDefaults(from,to,!time);
328 } 330 }
329 } else { 331 } else {
330 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false ); 332 tabWidget()->setTabEnabled ( mRecurrence->parentWidget(), false );
331 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true); 333 mRecurrence->setDefaults(QDateTime::currentDateTime(),QDateTime::currentDateTime().addSecs( 3600 ),true);
332 } 334 }
333} 335}
334void KOTodoEditor::readTodo(Todo *todo) 336void KOTodoEditor::readTodo(Todo *todo)
335{ 337{
336 mGeneral->readTodo(todo); 338 mGeneral->readTodo(todo);
337 mDetails->readEvent(todo); 339 mDetails->readEvent(todo);
338 mRelatedTodo = 0;//todo->relatedTo(); 340 mRelatedTodo = 0;//todo->relatedTo();
339 // categories 341 // categories
340 // mCategoryDialog->setSelected(todo->categories()); 342 // mCategoryDialog->setSelected(todo->categories());
341 343
342 // We should handle read-only events here. 344 // We should handle read-only events here.
343} 345}
344 346
345void KOTodoEditor::writeTodo(Todo *event) 347void KOTodoEditor::writeTodo(Todo *event)
346{ 348{
347 bool maybeComputeRecurrenceTime = false; 349 bool maybeComputeRecurrenceTime = false;
348 if( event->hasRecurrenceID() && event->percentComplete() < 100) 350 if( event->hasRecurrenceID() && event->percentComplete() < 100)
349 maybeComputeRecurrenceTime = true; 351 maybeComputeRecurrenceTime = true;
350 event->setHasRecurrenceID( false ); 352 event->setHasRecurrenceID( false );
351 mGeneral->writeTodo(event); 353 mGeneral->writeTodo(event);
352 mDetails->writeEvent(event); 354 mDetails->writeEvent(event);
353 355
354 // set related event, i.e. parent to-do in this case. 356 // set related event, i.e. parent to-do in this case.
355 if (mRelatedTodo) { 357 if (mRelatedTodo) {
356 event->setRelatedTo(mRelatedTodo); 358 event->setRelatedTo(mRelatedTodo);
357 } 359 }
358 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) { 360 if ( mGeneral->mDueCheck->isChecked() && mGeneral->mStartCheck->isChecked()) {
359 mRecurrence->writeEvent(event); 361 mRecurrence->writeEvent(event);
360 if ( event->doesRecur() ) { 362 if ( event->doesRecur() ) {
361 int addSec = -1 ; 363 int addSec = -1 ;
362 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 ) 364 if ( maybeComputeRecurrenceTime && event->percentComplete() == 100 )
363 addSec = 1; 365 addSec = 1;
364 event->setRecurrenceID( event->dtStart().addSecs( addSec ) ); 366 event->setRecurrenceID( event->dtStart().addSecs( addSec ) );
365 event->setRecurDates(); 367 event->setRecurDates();
366 } else { 368 } else {
367 event->setHasRecurrenceID( false ); 369 event->setHasRecurrenceID( false );
368 } 370 }
369 } else { 371 } else {
370 event->setHasRecurrenceID( false ); 372 event->setHasRecurrenceID( false );
371 event->recurrence()->unsetRecurs(); 373 event->recurrence()->unsetRecurs();
372 } 374 }
373} 375}
374 376
375bool KOTodoEditor::validateInput() 377bool KOTodoEditor::validateInput()
376{ 378{
377 if (!mGeneral->validateInput()) return false; 379 if (!mGeneral->validateInput()) return false;
378 if (!mDetails->validateInput()) return false; 380 if (!mDetails->validateInput()) return false;
379 return true; 381 return true;
380} 382}
381 383
382int KOTodoEditor::msgItemDelete() 384int KOTodoEditor::msgItemDelete()
383{ 385{
384 return KMessageBox::warningContinueCancel(this, 386 return KMessageBox::warningContinueCancel(this,
385 i18n("This item will be permanently deleted."), 387 i18n("This item will be permanently deleted."),
386 i18n("KOrganizer Confirmation"),i18n("Delete")); 388 i18n("KOrganizer Confirmation"),i18n("Delete"));
387} 389}
388 390
389void KOTodoEditor::modified (int modification) 391void KOTodoEditor::modified (int modification)
390{ 392{
391 if (modification == KOGlobals::CATEGORY_MODIFIED || 393 if (modification == KOGlobals::CATEGORY_MODIFIED ||
392 KOGlobals::UNKNOWN_MODIFIED == modification ) 394 KOGlobals::UNKNOWN_MODIFIED == modification )
393 // mCategoryDialog->setSelected (mTodo->categories ()); 395 // mCategoryDialog->setSelected (mTodo->categories ());
394 mGeneral->modified (mTodo, modification); 396 mGeneral->modified (mTodo, modification);
395 397
396} 398}
397 399
398void KOTodoEditor::slotLoadTemplate() 400void KOTodoEditor::slotLoadTemplate()
399{ 401{
400 402
401 QString fileName =locateLocal( "templates", "todos" ); 403 QString fileName =locateLocal( "templates", "todos" );
402 QDir t_dir; 404 QDir t_dir;
403 if ( !t_dir.exists(fileName) ) 405 if ( !t_dir.exists(fileName) )
404 t_dir.mkdir ( fileName ); 406 t_dir.mkdir ( fileName );
405 fileName += "/todo"; 407 fileName += "/todo";
406 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this ); 408 fileName = KFileDialog::getSaveFileName( fileName , "Load Todo template", this );
407 if ( fileName.length() == 0 ) 409 if ( fileName.length() == 0 )
408 return; 410 return;
409 CalendarLocal cal; 411 CalendarLocal cal;
410 ICalFormat format; 412 ICalFormat format;
411 if ( !format.load( &cal, fileName ) ) { 413 if ( !format.load( &cal, fileName ) ) {
412 KMessageBox::error( this, i18n("Error loading template file\n '%1'.") 414 KMessageBox::error( this, i18n("Error loading template file\n '%1'.")
413 .arg( fileName ) ); 415 .arg( fileName ) );
414 return ; 416 return ;
415 } 417 }
416 QPtrList<Todo> todos = cal.todos(); 418 QPtrList<Todo> todos = cal.todos();
417 Todo * todo = todos.first(); 419 Todo * todo = todos.first();
418 if ( !todo ) { 420 if ( !todo ) {
419 KMessageBox::error( this, 421 KMessageBox::error( this,
420 i18n("Template does not\ncontain a valid Todo.")); 422 i18n("Template does not\ncontain a valid Todo."));
421 } else { 423 } else {
422 readTodo( todo ); 424 readTodo( todo );
423 } 425 }
424 426
425} 427}
426 428
427void KOTodoEditor::slotSaveTemplate() 429void KOTodoEditor::slotSaveTemplate()
428{ 430{
429 QString fileName =locateLocal( "templates", "todos" ); 431 QString fileName =locateLocal( "templates", "todos" );
430 QDir t_dir; 432 QDir t_dir;
431 if ( !t_dir.exists(fileName) ) 433 if ( !t_dir.exists(fileName) )
432 t_dir.mkdir ( fileName ); 434 t_dir.mkdir ( fileName );
433 fileName += "/todo"; 435 fileName += "/todo";
434 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this ); 436 fileName = KFileDialog::getSaveFileName( fileName , "Save as Todo template", this );
435 if ( fileName.length() > 0 ) 437 if ( fileName.length() > 0 )
436 saveTemplate( fileName ); 438 saveTemplate( fileName );
437} 439}
438 440
439void KOTodoEditor::saveTemplate( const QString &templateName ) 441void KOTodoEditor::saveTemplate( const QString &templateName )
440{ 442{
441 Todo *todo = new Todo; 443 Todo *todo = new Todo;
442 writeTodo( todo ); 444 writeTodo( todo );
443 saveAsTemplate( todo, templateName ); 445 saveAsTemplate( todo, templateName );
444} 446}
diff --git a/korganizer/searchdialog.cpp b/korganizer/searchdialog.cpp
index 007d1f3..59bf1a2 100644
--- a/korganizer/searchdialog.cpp
+++ b/korganizer/searchdialog.cpp
@@ -1,462 +1,464 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 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 <qlayout.h> 25#include <qlayout.h>
26#include <qcheckbox.h> 26#include <qcheckbox.h>
27#include <qgroupbox.h> 27#include <qgroupbox.h>
28#include <qlabel.h> 28#include <qlabel.h>
29#include <qlistview.h> 29#include <qlistview.h>
30#include <qwhatsthis.h> 30#include <qwhatsthis.h>
31#include <qlineedit.h> 31#include <qlineedit.h>
32#include <qpushbutton.h> 32#include <qpushbutton.h>
33 33
34#include <klocale.h> 34#include <klocale.h>
35#include <kmessagebox.h> 35#include <kmessagebox.h>
36 36
37#include <libkdepim/kdateedit.h> 37#include <libkdepim/kdateedit.h>
38 38
39#include "koglobals.h" 39#include "koglobals.h"
40#include "koprefs.h" 40#include "koprefs.h"
41#include "klineedit.h" 41#include "klineedit.h"
42 42
43#include "calendarview.h" 43#include "calendarview.h"
44#include "koviewmanager.h" 44#include "koviewmanager.h"
45#include "searchdialog.h" 45#include "searchdialog.h"
46 46
47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent) 47SearchDialog::SearchDialog(Calendar *calendar,CalendarView *parent)
48 : QVBox( 0 ) 48 : QVBox( 0 )
49 49
50{ 50{
51 mCalendar = calendar; 51 mCalendar = calendar;
52 QFrame *topFrame = new QFrame( this ) ;//plainPage(); 52 QFrame *topFrame = new QFrame( this ) ;//plainPage();
53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint()); 53 QVBoxLayout *layout = new QVBoxLayout(topFrame,KDialog::marginHint(),KDialog::spacingHint());
54 54
55 // Search expression 55 // Search expression
56 QHBoxLayout *subLayout = new QHBoxLayout(); 56 QHBoxLayout *subLayout = new QHBoxLayout();
57 layout->addLayout(subLayout); 57 layout->addLayout(subLayout);
58 searchLabel = new QLabel(topFrame); 58 searchLabel = new QLabel(topFrame);
59 searchLabel->setText(i18n("Search for:")); 59 searchLabel->setText(i18n("Search for:"));
60 subLayout->addWidget(searchLabel); 60 subLayout->addWidget(searchLabel);
61 61
62 searchEdit = new KLineEdit(topFrame); 62 searchEdit = new KLineEdit(topFrame);
63 subLayout->addWidget(searchEdit); 63 subLayout->addWidget(searchEdit);
64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame ); 64 QPushButton *OkButton = new QPushButton( i18n("&Find"), topFrame );
65 //OkButton->setDefault( true ); 65 //OkButton->setDefault( true );
66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch())); 66 connect(OkButton,SIGNAL(clicked()),SLOT(doSearch()));
67 subLayout->addWidget(OkButton); 67 subLayout->addWidget(OkButton);
68 searchEdit->setText("*"); // Find all events by default 68 searchEdit->setText("*"); // Find all events by default
69 searchEdit->setFocus(); 69 searchEdit->setFocus();
70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & ))); 70 connect(searchEdit, SIGNAL(textChanged ( const QString & )),this,SLOT(searchTextChanged( const QString & )));
71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch())); 71 connect(searchEdit, SIGNAL( returnPressed () ),this,SLOT(doSearch()));
72 // Subjects to search 72 // Subjects to search
73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"), 73 // QGroupBox *subjectGroup = new QGroupBox(1,Vertical,i18n("Search In"),
74 // topFrame); 74 // topFrame);
75 75
76 QHBox *incidenceGroup = new QHBox( topFrame ); 76 QHBox *incidenceGroup = new QHBox( topFrame );
77 layout->addWidget(incidenceGroup); 77 layout->addWidget(incidenceGroup);
78 78
79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup); 79 mSearchEvent = new QCheckBox(i18n("Events"),incidenceGroup);
80 //mSearchEvent->setChecked(true); 80 //mSearchEvent->setChecked(true);
81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup); 81 mSearchTodo = new QCheckBox(i18n("Todos"),incidenceGroup);
82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup); 82 mSearchJournal = new QCheckBox(i18n("Journals"),incidenceGroup);
83 83
84 QHBox *subjectGroup = new QHBox( topFrame ); 84 QHBox *subjectGroup = new QHBox( topFrame );
85 layout->addWidget(subjectGroup); 85 layout->addWidget(subjectGroup);
86 86
87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup); 87 mSummaryCheck = new QCheckBox(i18n("Summary/Loc."),subjectGroup);
88 mSummaryCheck->setChecked(true); 88 mSummaryCheck->setChecked(true);
89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup); 89 mDescriptionCheck = new QCheckBox(i18n("Details"),subjectGroup);
90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup); 90 mCategoryCheck = new QCheckBox(i18n("Categories"),subjectGroup);
91 91
92 QHBox *attendeeGroup = new QHBox( topFrame ); 92 QHBox *attendeeGroup = new QHBox( topFrame );
93 layout->addWidget(attendeeGroup ); 93 layout->addWidget(attendeeGroup );
94 new QLabel( i18n("Attendee:"),attendeeGroup ); 94 new QLabel( i18n("Attendee:"),attendeeGroup );
95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup ); 95 mSearchAName = new QCheckBox(i18n("Name"),attendeeGroup );
96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup ); 96 mSearchAEmail = new QCheckBox(i18n("Email"), attendeeGroup );
97 // Date range 97 // Date range
98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"), 98 // QGroupBox *rangeGroup = new QGroupBox(1,Horizontal,i18n("Date Range"),
99 // topFrame); 99 // topFrame);
100 // layout->addWidget(rangeGroup); 100 // layout->addWidget(rangeGroup);
101 101
102 QWidget *rangeWidget = new QWidget(topFrame); 102 QWidget *rangeWidget = new QWidget(topFrame);
103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint()); 103 QHBoxLayout *rangeLayout = new QHBoxLayout(rangeWidget,0,KDialog::spacingHint());
104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget)); 104 rangeLayout->addWidget(new QLabel(i18n("From:"),rangeWidget));
105 mStartDate = new KDateEdit(rangeWidget); 105 mStartDate = new KDateEdit(rangeWidget);
106 rangeLayout->addWidget(mStartDate); 106 rangeLayout->addWidget(mStartDate);
107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget)); 107 rangeLayout->addWidget(new QLabel(i18n("To:"),rangeWidget));
108 mEndDate = new KDateEdit(rangeWidget); 108 mEndDate = new KDateEdit(rangeWidget);
109 mEndDate->setDate(QDate::currentDate().addDays(365)); 109 mEndDate->setDate(QDate::currentDate().addDays(365));
110 rangeLayout->addWidget(mEndDate); 110 rangeLayout->addWidget(mEndDate);
111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget ); 111 QToolButton *wt = QWhatsThis::whatsThisButton ( rangeWidget );
112 rangeLayout->addWidget( (QWidget*)wt ); 112 rangeLayout->addWidget( (QWidget*)wt );
113 layout->addWidget(rangeWidget); 113 layout->addWidget(rangeWidget);
114 // Results list view 114 // Results list view
115 listView = new KOListView(mCalendar,topFrame); 115 listView = new KOListView(mCalendar,topFrame);
116 layout->addWidget(listView); 116 layout->addWidget(listView);
117 117 //layout->setStretchFactor( listView, 333 );
118 //listView->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Expanding) );
119 //listView->setMaximumHeight( 50 );
118 listView->readSettings(KOGlobals::config(),"SearchListView Layout"); 120 listView->readSettings(KOGlobals::config(),"SearchListView Layout");
119 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList())); 121 connect(searchEdit,SIGNAL(scrollDOWN()),SLOT(setFocusToList()));
120 122
121 setCaption( i18n("KO/Pi Find: ")); 123 setCaption( i18n("KO/Pi Find: "));
122#ifdef DESKTOP_VERSION 124#ifdef DESKTOP_VERSION
123 OkButton = new QPushButton( i18n("Close"), this ); 125 OkButton = new QPushButton( i18n("Close"), this );
124 connect(OkButton,SIGNAL(clicked()),SLOT(hide())); 126 connect(OkButton,SIGNAL(clicked()),SLOT(hide()));
125#endif 127#endif
126} 128}
127 129
128SearchDialog::~SearchDialog() 130SearchDialog::~SearchDialog()
129{ 131{
130 132
131} 133}
132void SearchDialog::raiseAndSelect() 134void SearchDialog::raiseAndSelect()
133{ 135{
134 136
135 static int currentState = 0; 137 static int currentState = 0;
136 138
137 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() ) 139 if ( !mSearchJournal->isChecked() && !mSearchTodo->isChecked() && !mSearchEvent->isChecked() )
138 currentState = 0; 140 currentState = 0;
139 int newState = 0; 141 int newState = 0;
140 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 142 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
141 newState = VIEW_J_VIEW; 143 newState = VIEW_J_VIEW;
142 } 144 }
143 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 145 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
144 newState = VIEW_T_VIEW; 146 newState = VIEW_T_VIEW;
145 } 147 }
146 else { 148 else {
147 newState = VIEW_A_VIEW; 149 newState = VIEW_A_VIEW;
148 } 150 }
149 if ( newState != currentState ) { 151 if ( newState != currentState ) {
150 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) { 152 if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_J_VIEW ) {
151 if ( ! mSearchJournal->isChecked() ) { 153 if ( ! mSearchJournal->isChecked() ) {
152 mSearchJournal->setChecked( true ); 154 mSearchJournal->setChecked( true );
153 mSearchTodo->setChecked( false ); 155 mSearchTodo->setChecked( false );
154 mSearchEvent->setChecked( false ); 156 mSearchEvent->setChecked( false );
155 } 157 }
156 } 158 }
157 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) { 159 else if ( KOPrefs::instance()->mCurrentDisplayedView == VIEW_T_VIEW ) {
158 if ( ! mSearchTodo->isChecked() ) { 160 if ( ! mSearchTodo->isChecked() ) {
159 mSearchTodo->setChecked( true ); 161 mSearchTodo->setChecked( true );
160 mSearchJournal->setChecked( false ); 162 mSearchJournal->setChecked( false );
161 mSearchEvent->setChecked( false ); 163 mSearchEvent->setChecked( false );
162 } 164 }
163 } 165 }
164 else { 166 else {
165 if ( ! mSearchEvent->isChecked() ) { 167 if ( ! mSearchEvent->isChecked() ) {
166 mSearchEvent->setChecked( true ); 168 mSearchEvent->setChecked( true );
167 mSearchJournal->setChecked( false ); 169 mSearchJournal->setChecked( false );
168 mSearchTodo->setChecked( false ); 170 mSearchTodo->setChecked( false );
169 } 171 }
170 } 172 }
171 } 173 }
172 currentState = newState; 174 currentState = newState;
173 raise(); 175 raise();
174} 176}
175void SearchDialog::setFocusToList() 177void SearchDialog::setFocusToList()
176{ 178{
177 listView->resetFocus(); 179 listView->resetFocus();
178} 180}
179void SearchDialog::accept() 181void SearchDialog::accept()
180{ 182{
181 doSearch(); 183 doSearch();
182} 184}
183void SearchDialog::updateList() 185void SearchDialog::updateList()
184{ 186{
185 //listView->updateList(); 187 //listView->updateList();
186 if ( isVisible() ) { 188 if ( isVisible() ) {
187 updateView(); 189 updateView();
188 //qDebug("SearchDialog::updated "); 190 //qDebug("SearchDialog::updated ");
189 } 191 }
190 else { 192 else {
191 listView->clear(); 193 listView->clear();
192 //qDebug("SearchDialog::cleared "); 194 //qDebug("SearchDialog::cleared ");
193 195
194 } 196 }
195} 197}
196void SearchDialog::searchTextChanged( const QString &_text ) 198void SearchDialog::searchTextChanged( const QString &_text )
197{ 199{
198#if 0 200#if 0
199 enableButton( KDialogBase::User1, !_text.isEmpty() ); 201 enableButton( KDialogBase::User1, !_text.isEmpty() );
200#endif 202#endif
201} 203}
202 204
203void SearchDialog::doSearch() 205void SearchDialog::doSearch()
204{ 206{
205 QRegExp re; 207 QRegExp re;
206 208
207 re.setWildcard(true); // most people understand these better. 209 re.setWildcard(true); // most people understand these better.
208 re.setCaseSensitive(false); 210 re.setCaseSensitive(false);
209 QString st = searchEdit->text(); 211 QString st = searchEdit->text();
210 if ( st.right(1) != "*") 212 if ( st.right(1) != "*")
211 st += "*"; 213 st += "*";
212 re.setPattern(st); 214 re.setPattern(st);
213 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) { 215 if (!mSearchEvent->isChecked() && !mSearchTodo->isChecked() && !mSearchJournal->isChecked() ) {
214 KMessageBox::sorry(this, 216 KMessageBox::sorry(this,
215 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals")); 217 i18n("Please select at least one\nof the types to search for:\n\nEvents\nTodos\nJournals"));
216 return; 218 return;
217 } 219 }
218 if (!re.isValid() ) { 220 if (!re.isValid() ) {
219 KMessageBox::sorry(this, 221 KMessageBox::sorry(this,
220 i18n("Invalid search expression,\ncannot perform " 222 i18n("Invalid search expression,\ncannot perform "
221 "the search.\nPlease enter a search expression\n" 223 "the search.\nPlease enter a search expression\n"
222 "using the wildcard characters\n '*' and '?'" 224 "using the wildcard characters\n '*' and '?'"
223 "where needed.")); 225 "where needed."));
224 return; 226 return;
225 } 227 }
226 search(re); 228 search(re);
227 listView->setStartDate( mStartDate->date() ); 229 listView->setStartDate( mStartDate->date() );
228 listView->showEvents(mMatchedEvents); 230 listView->showEvents(mMatchedEvents);
229 listView->addTodos(mMatchedTodos); 231 listView->addTodos(mMatchedTodos);
230 listView->addJournals(mMatchedJournals); 232 listView->addJournals(mMatchedJournals);
231 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) { 233 if (mMatchedEvents.count() + mMatchedJournals.count() + mMatchedTodos.count() == 0) {
232 setCaption(i18n("No items found. Use '*' and '?' where needed.")); 234 setCaption(i18n("No items found. Use '*' and '?' where needed."));
233 } else { 235 } else {
234 QString mess; 236 QString mess;
235 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() ); 237 mess = mess.sprintf( i18n("%d item(s) found."), mMatchedEvents.count()+ mMatchedJournals.count() + mMatchedTodos.count() );
236 setCaption( i18n("KO/Pi Find: ") + mess); 238 setCaption( i18n("KO/Pi Find: ") + mess);
237 239
238 } 240 }
239 searchEdit->setFocus(); 241 searchEdit->setFocus();
240} 242}
241void SearchDialog::updateConfig() 243void SearchDialog::updateConfig()
242{ 244{
243 listView->updateConfig(); 245 listView->updateConfig();
244} 246}
245void SearchDialog::updateView() 247void SearchDialog::updateView()
246{ 248{
247 //qDebug("SearchDialog::updateView() %d ", isVisible()); 249 //qDebug("SearchDialog::updateView() %d ", isVisible());
248 QRegExp re; 250 QRegExp re;
249 re.setWildcard(true); // most people understand these better. 251 re.setWildcard(true); // most people understand these better.
250 re.setCaseSensitive(false); 252 re.setCaseSensitive(false);
251 QString st = searchEdit->text(); 253 QString st = searchEdit->text();
252 if ( st.right(1) != "*") 254 if ( st.right(1) != "*")
253 st += "*"; 255 st += "*";
254 re.setPattern(st); 256 re.setPattern(st);
255 if (re.isValid()) { 257 if (re.isValid()) {
256 search(re); 258 search(re);
257 } else { 259 } else {
258 mMatchedEvents.clear(); 260 mMatchedEvents.clear();
259 mMatchedTodos.clear(); 261 mMatchedTodos.clear();
260 mMatchedJournals.clear(); 262 mMatchedJournals.clear();
261 } 263 }
262 listView->setStartDate( mStartDate->date() ); 264 listView->setStartDate( mStartDate->date() );
263 listView->showEvents(mMatchedEvents); 265 listView->showEvents(mMatchedEvents);
264 listView->addTodos(mMatchedTodos); 266 listView->addTodos(mMatchedTodos);
265 listView->addJournals(mMatchedJournals); 267 listView->addJournals(mMatchedJournals);
266} 268}
267 269
268void SearchDialog::search(const QRegExp &re) 270void SearchDialog::search(const QRegExp &re)
269{ 271{
270 QPtrList<Event> events = mCalendar->events( mStartDate->date(), 272 QPtrList<Event> events = mCalendar->events( mStartDate->date(),
271 mEndDate->date(), 273 mEndDate->date(),
272 false /*mInclusiveCheck->isChecked()*/ ); 274 false /*mInclusiveCheck->isChecked()*/ );
273 275
274 mMatchedEvents.clear(); 276 mMatchedEvents.clear();
275 if ( mSearchEvent->isChecked() ) { 277 if ( mSearchEvent->isChecked() ) {
276 Event *ev; 278 Event *ev;
277 for(ev=events.first();ev;ev=events.next()) { 279 for(ev=events.first();ev;ev=events.next()) {
278 if (mSummaryCheck->isChecked()) { 280 if (mSummaryCheck->isChecked()) {
279#if QT_VERSION >= 0x030000 281#if QT_VERSION >= 0x030000
280 if (re.search(ev->summary()) != -1) 282 if (re.search(ev->summary()) != -1)
281#else 283#else
282 if (re.match(ev->summary()) != -1) 284 if (re.match(ev->summary()) != -1)
283#endif 285#endif
284 { 286 {
285 mMatchedEvents.append(ev); 287 mMatchedEvents.append(ev);
286 continue; 288 continue;
287 } 289 }
288#if QT_VERSION >= 0x030000 290#if QT_VERSION >= 0x030000
289 if (re.search(ev->location()) != -1) 291 if (re.search(ev->location()) != -1)
290#else 292#else
291 if (re.match(ev->location()) != -1) 293 if (re.match(ev->location()) != -1)
292#endif 294#endif
293 { 295 {
294 mMatchedEvents.append(ev); 296 mMatchedEvents.append(ev);
295 continue; 297 continue;
296 } 298 }
297 } 299 }
298 if (mDescriptionCheck->isChecked()) { 300 if (mDescriptionCheck->isChecked()) {
299#if QT_VERSION >= 0x030000 301#if QT_VERSION >= 0x030000
300 if (re.search(ev->description()) != -1) 302 if (re.search(ev->description()) != -1)
301#else 303#else
302 if (re.match(ev->description()) != -1) 304 if (re.match(ev->description()) != -1)
303#endif 305#endif
304 { 306 {
305 mMatchedEvents.append(ev); 307 mMatchedEvents.append(ev);
306 continue; 308 continue;
307 } 309 }
308 } 310 }
309 if (mCategoryCheck->isChecked()) { 311 if (mCategoryCheck->isChecked()) {
310#if QT_VERSION >= 0x030000 312#if QT_VERSION >= 0x030000
311 if (re.search(ev->categoriesStr()) != -1) 313 if (re.search(ev->categoriesStr()) != -1)
312#else 314#else
313 if (re.match(ev->categoriesStr()) != -1) 315 if (re.match(ev->categoriesStr()) != -1)
314#endif 316#endif
315 { 317 {
316 mMatchedEvents.append(ev); 318 mMatchedEvents.append(ev);
317 continue; 319 continue;
318 } 320 }
319 } 321 }
320 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 322 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
321 QPtrList<Attendee> tmpAList = ev->attendees(); 323 QPtrList<Attendee> tmpAList = ev->attendees();
322 Attendee *a; 324 Attendee *a;
323 for (a = tmpAList.first(); a; a = tmpAList.next()) { 325 for (a = tmpAList.first(); a; a = tmpAList.next()) {
324 if (mSearchAName->isChecked()) { 326 if (mSearchAName->isChecked()) {
325#if QT_VERSION >= 0x030000 327#if QT_VERSION >= 0x030000
326 if (re.search(a->name()) != -1) 328 if (re.search(a->name()) != -1)
327#else 329#else
328 if (re.match(a->name()) != -1) 330 if (re.match(a->name()) != -1)
329#endif 331#endif
330 { 332 {
331 mMatchedEvents.append(ev); 333 mMatchedEvents.append(ev);
332 break; 334 break;
333 } 335 }
334 } 336 }
335 if (mSearchAEmail->isChecked()) { 337 if (mSearchAEmail->isChecked()) {
336#if QT_VERSION >= 0x030000 338#if QT_VERSION >= 0x030000
337 if (re.search(a->email()) != -1) 339 if (re.search(a->email()) != -1)
338#else 340#else
339 if (re.match(a->email()) != -1) 341 if (re.match(a->email()) != -1)
340#endif 342#endif
341 { 343 {
342 mMatchedEvents.append(ev); 344 mMatchedEvents.append(ev);
343 break; 345 break;
344 } 346 }
345 } 347 }
346 } 348 }
347 } 349 }
348 } 350 }
349 } 351 }
350 QPtrList<Todo> todos = mCalendar->todos( ); 352 QPtrList<Todo> todos = mCalendar->todos( );
351 mMatchedTodos.clear(); 353 mMatchedTodos.clear();
352 if ( mSearchTodo->isChecked() ) { 354 if ( mSearchTodo->isChecked() ) {
353 Todo *tod; 355 Todo *tod;
354 for(tod=todos.first();tod;tod=todos.next()) { 356 for(tod=todos.first();tod;tod=todos.next()) {
355 if (mSummaryCheck->isChecked()) { 357 if (mSummaryCheck->isChecked()) {
356#if QT_VERSION >= 0x030000 358#if QT_VERSION >= 0x030000
357 if (re.search(tod->summary()) != -1) 359 if (re.search(tod->summary()) != -1)
358#else 360#else
359 if (re.match(tod->summary()) != -1) 361 if (re.match(tod->summary()) != -1)
360#endif 362#endif
361 { 363 {
362 mMatchedTodos.append(tod); 364 mMatchedTodos.append(tod);
363 continue; 365 continue;
364 } 366 }
365 } 367 }
366 if (mDescriptionCheck->isChecked()) { 368 if (mDescriptionCheck->isChecked()) {
367#if QT_VERSION >= 0x030000 369#if QT_VERSION >= 0x030000
368 if (re.search(tod->description()) != -1) 370 if (re.search(tod->description()) != -1)
369#else 371#else
370 if (re.match(tod->description()) != -1) 372 if (re.match(tod->description()) != -1)
371#endif 373#endif
372 { 374 {
373 mMatchedTodos.append(tod); 375 mMatchedTodos.append(tod);
374 continue; 376 continue;
375 } 377 }
376 } 378 }
377 if (mCategoryCheck->isChecked()) { 379 if (mCategoryCheck->isChecked()) {
378#if QT_VERSION >= 0x030000 380#if QT_VERSION >= 0x030000
379 if (re.search(tod->categoriesStr()) != -1) 381 if (re.search(tod->categoriesStr()) != -1)
380#else 382#else
381 if (re.match(tod->categoriesStr()) != -1) 383 if (re.match(tod->categoriesStr()) != -1)
382#endif 384#endif
383 { 385 {
384 mMatchedTodos.append(tod); 386 mMatchedTodos.append(tod);
385 continue; 387 continue;
386 } 388 }
387 } 389 }
388 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) { 390 if ( mSearchAName->isChecked() || mSearchAEmail->isChecked() ) {
389 QPtrList<Attendee> tmpAList = tod->attendees(); 391 QPtrList<Attendee> tmpAList = tod->attendees();
390 Attendee *a; 392 Attendee *a;
391 for (a = tmpAList.first(); a; a = tmpAList.next()) { 393 for (a = tmpAList.first(); a; a = tmpAList.next()) {
392 if (mSearchAName->isChecked()) { 394 if (mSearchAName->isChecked()) {
393#if QT_VERSION >= 0x030000 395#if QT_VERSION >= 0x030000
394 if (re.search(a->name()) != -1) 396 if (re.search(a->name()) != -1)
395#else 397#else
396 if (re.match(a->name()) != -1) 398 if (re.match(a->name()) != -1)
397#endif 399#endif
398 { 400 {
399 mMatchedTodos.append(tod); 401 mMatchedTodos.append(tod);
400 break; 402 break;
401 } 403 }
402 } 404 }
403 if (mSearchAEmail->isChecked()) { 405 if (mSearchAEmail->isChecked()) {
404#if QT_VERSION >= 0x030000 406#if QT_VERSION >= 0x030000
405 if (re.search(a->email()) != -1) 407 if (re.search(a->email()) != -1)
406#else 408#else
407 if (re.match(a->email()) != -1) 409 if (re.match(a->email()) != -1)
408#endif 410#endif
409 { 411 {
410 mMatchedTodos.append(tod); 412 mMatchedTodos.append(tod);
411 break; 413 break;
412 } 414 }
413 } 415 }
414 } 416 }
415 } 417 }
416 } 418 }
417 } 419 }
418 mMatchedJournals.clear(); 420 mMatchedJournals.clear();
419 if (mSearchJournal->isChecked() ) { 421 if (mSearchJournal->isChecked() ) {
420 QPtrList<Journal> journals = mCalendar->journals( ); 422 QPtrList<Journal> journals = mCalendar->journals( );
421 Journal* journ; 423 Journal* journ;
422 424
423 for(journ=journals.first();journ;journ=journals.next()) { 425 for(journ=journals.first();journ;journ=journals.next()) {
424 if ( journ->dtStart().date() <= mEndDate->date() 426 if ( journ->dtStart().date() <= mEndDate->date()
425 &&journ->dtStart().date() >= mStartDate->date()) { 427 &&journ->dtStart().date() >= mStartDate->date()) {
426#if QT_VERSION >= 0x030000 428#if QT_VERSION >= 0x030000
427 if (re.search(journ->description()) != -1) 429 if (re.search(journ->description()) != -1)
428#else 430#else
429 if (re.match(journ->description()) != -1) 431 if (re.match(journ->description()) != -1)
430#endif 432#endif
431 { 433 {
432 mMatchedJournals.append(journ); 434 mMatchedJournals.append(journ);
433 continue; 435 continue;
434 } 436 }
435 } 437 }
436 } 438 }
437 } 439 }
438 440
439} 441}
440 442
441void SearchDialog::keyPressEvent ( QKeyEvent *e) 443void SearchDialog::keyPressEvent ( QKeyEvent *e)
442{ 444{
443 switch ( e->key() ) { 445 switch ( e->key() ) {
444 case Qt::Key_Escape: 446 case Qt::Key_Escape:
445 close(); 447 close();
446 break; 448 break;
447 case Qt::Key_F: 449 case Qt::Key_F:
448 if ( e->state() == Qt::ControlButton ) { 450 if ( e->state() == Qt::ControlButton ) {
449 451
450 } 452 }
451 break; 453 break;
452 case Qt::Key_Return: 454 case Qt::Key_Return:
453 case Qt::Key_Enter: 455 case Qt::Key_Enter:
454 doSearch(); 456 doSearch();
455 break; 457 break;
456 458
457 default: 459 default:
458 e->ignore(); 460 e->ignore();
459 } 461 }
460} 462}
461 463
462//mMatchedJournals; 464//mMatchedJournals;
diff --git a/libkcal/todo.cpp b/libkcal/todo.cpp
index f7e38a7..d7431c7 100644
--- a/libkcal/todo.cpp
+++ b/libkcal/todo.cpp
@@ -1,573 +1,577 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <kglobalsettings.h> 22#include <kglobalsettings.h>
23#include <klocale.h> 23#include <klocale.h>
24#include <kdebug.h> 24#include <kdebug.h>
25#include <qregexp.h> 25#include <qregexp.h>
26#include <qfileinfo.h> 26#include <qfileinfo.h>
27 27
28#include "calendarlocal.h" 28#include "calendarlocal.h"
29#include "icalformat.h" 29#include "icalformat.h"
30#include "todo.h" 30#include "todo.h"
31 31
32using namespace KCal; 32using namespace KCal;
33 33
34Todo::Todo(): QObject(), Incidence() 34Todo::Todo(): QObject(), Incidence()
35{ 35{
36// mStatus = TENTATIVE; 36// mStatus = TENTATIVE;
37 37
38 mHasDueDate = false; 38 mHasDueDate = false;
39 setHasStartDate( false ); 39 setHasStartDate( false );
40 mCompleted = getEvenTime(QDateTime::currentDateTime()); 40 mCompleted = getEvenTime(QDateTime::currentDateTime());
41 mHasCompletedDate = false; 41 mHasCompletedDate = false;
42 mPercentComplete = 0; 42 mPercentComplete = 0;
43 mRunning = false; 43 mRunning = false;
44 mRunSaveTimer = 0; 44 mRunSaveTimer = 0;
45} 45}
46 46
47Todo::Todo(const Todo &t) : QObject(),Incidence(t) 47Todo::Todo(const Todo &t) : QObject(),Incidence(t)
48{ 48{
49 mDtDue = t.mDtDue; 49 mDtDue = t.mDtDue;
50 mHasDueDate = t.mHasDueDate; 50 mHasDueDate = t.mHasDueDate;
51 mCompleted = t.mCompleted; 51 mCompleted = t.mCompleted;
52 mHasCompletedDate = t.mHasCompletedDate; 52 mHasCompletedDate = t.mHasCompletedDate;
53 mPercentComplete = t.mPercentComplete; 53 mPercentComplete = t.mPercentComplete;
54 mRunning = false; 54 mRunning = false;
55 mRunSaveTimer = 0; 55 mRunSaveTimer = 0;
56} 56}
57 57
58Todo::~Todo() 58Todo::~Todo()
59{ 59{
60 setRunning( false ); 60 setRunning( false );
61 //qDebug("Todo::~Todo() "); 61 //qDebug("Todo::~Todo() ");
62} 62}
63 63
64void Todo::setRunningFalse( QString s ) 64void Todo::setRunningFalse( QString s )
65{ 65{
66 if ( ! mRunning ) 66 if ( ! mRunning )
67 return; 67 return;
68 mRunning = false; 68 mRunning = false;
69 mRunSaveTimer->stop(); 69 mRunSaveTimer->stop();
70 saveRunningInfoToFile( s ); 70 saveRunningInfoToFile( s );
71} 71}
72void Todo::setRunning( bool run ) 72void Todo::setRunning( bool run )
73{ 73{
74 if ( run == mRunning ) 74 if ( run == mRunning )
75 return; 75 return;
76 //qDebug("Todo::setRunning %d ", run); 76 //qDebug("Todo::setRunning %d ", run);
77 if ( !mRunSaveTimer ) { 77 if ( !mRunSaveTimer ) {
78 mRunSaveTimer = new QTimer ( this ); 78 mRunSaveTimer = new QTimer ( this );
79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) ); 79 connect ( mRunSaveTimer, SIGNAL( timeout() ), this , SLOT ( saveRunningInfoToFile() ) );
80 } 80 }
81 mRunning = run; 81 mRunning = run;
82 if ( mRunning ) { 82 if ( mRunning ) {
83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min 83 mRunSaveTimer->start( 1000 * 60 * 5 ); // 5 min
84 mRunStart = QDateTime::currentDateTime(); 84 mRunStart = QDateTime::currentDateTime();
85 } else { 85 } else {
86 mRunSaveTimer->stop(); 86 mRunSaveTimer->stop();
87 saveRunningInfoToFile(); 87 saveRunningInfoToFile();
88 } 88 }
89} 89}
90 90
91void Todo::saveRunningInfoToFile( QString comment ) 91void Todo::saveRunningInfoToFile( QString comment )
92{ 92{
93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1()); 93 //qDebug("Todo::saveRunningInfoToFile() %s", summary().latin1());
94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) { 94 if ( mRunStart.secsTo ( QDateTime::currentDateTime() ) < 30 ) {
95 qDebug("Running time < 30 seconds. Skipped. "); 95 qDebug("Running time < 30 seconds. Skipped. ");
96 return; 96 return;
97 } 97 }
98 QString dir = KGlobalSettings::timeTrackerDir(); 98 QString dir = KGlobalSettings::timeTrackerDir();
99 //qDebug("%s ", dir.latin1()); 99 //qDebug("%s ", dir.latin1());
100 QString file = "%1%2%3-%4%5%6-"; 100 QString file = "%1%2%3-%4%5%6-";
101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 101 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
102 file.replace ( QRegExp (" "), "0" ); 102 file.replace ( QRegExp (" "), "0" );
103 file += uid(); 103 file += uid();
104 //qDebug("File %s ",file.latin1() ); 104 //qDebug("File %s ",file.latin1() );
105 CalendarLocal cal; 105 CalendarLocal cal;
106 cal.setLocalTime(); 106 cal.setLocalTime();
107 Todo * to = (Todo*) clone(); 107 Todo * to = (Todo*) clone();
108 to->setFloats( false ); 108 to->setFloats( false );
109 to->setDtStart( mRunStart ); 109 to->setDtStart( mRunStart );
110 to->setHasStartDate( true ); 110 to->setHasStartDate( true );
111 to->setDtDue( QDateTime::currentDateTime() ); 111 to->setDtDue( QDateTime::currentDateTime() );
112 to->setHasDueDate( true ); 112 to->setHasDueDate( true );
113 to->setUid( file ); 113 to->setUid( file );
114 if ( !comment.isEmpty() ) { 114 if ( !comment.isEmpty() ) {
115 to->setDescription( comment ); 115 QString des = to->description();
116 if ( des.isEmpty () )
117 to->setDescription( "TT-Note: " + comment );
118 else
119 to->setDescription( "TT-Note: " + comment +"\n" + des );
116 } 120 }
117 cal.addIncidence( to ); 121 cal.addIncidence( to );
118 ICalFormat format; 122 ICalFormat format;
119 file = dir +"/" +file +".ics"; 123 file = dir +"/" +file +".ics";
120 format.save( &cal, file ); 124 format.save( &cal, file );
121 saveParents(); 125 saveParents();
122 126
123} 127}
124void Todo::saveParents() 128void Todo::saveParents()
125{ 129{
126 if (!relatedTo() ) 130 if (!relatedTo() )
127 return; 131 return;
128 Incidence * inc = relatedTo(); 132 Incidence * inc = relatedTo();
129 if ( inc->type() != "Todo" ) 133 if ( inc->type() != "Todo" )
130 return; 134 return;
131 Todo* to = (Todo*)inc; 135 Todo* to = (Todo*)inc;
132 bool saveTodo = false; 136 bool saveTodo = false;
133 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics"; 137 QString file = KGlobalSettings::timeTrackerDir() + "/"+ to->uid() + ".ics";
134 QFileInfo fi ( file ); 138 QFileInfo fi ( file );
135 if ( fi.exists() ) { 139 if ( fi.exists() ) {
136 if ( fi.lastModified () < to->lastModified ()) 140 if ( fi.lastModified () < to->lastModified ())
137 saveTodo = true; 141 saveTodo = true;
138 } else { 142 } else {
139 saveTodo = true; 143 saveTodo = true;
140 } 144 }
141 if ( saveTodo ) { 145 if ( saveTodo ) {
142 CalendarLocal cal; 146 CalendarLocal cal;
143 cal.setLocalTime(); 147 cal.setLocalTime();
144 Todo * par = (Todo *) to->clone(); 148 Todo * par = (Todo *) to->clone();
145 cal.addIncidence( par ); 149 cal.addIncidence( par );
146 ICalFormat format; 150 ICalFormat format;
147 format.save( &cal, file ); 151 format.save( &cal, file );
148 } 152 }
149 to->saveParents(); 153 to->saveParents();
150} 154}
151 155
152int Todo::runTime() 156int Todo::runTime()
153{ 157{
154 if ( !mRunning ) 158 if ( !mRunning )
155 return 0; 159 return 0;
156 return mRunStart.secsTo( QDateTime::currentDateTime() ); 160 return mRunStart.secsTo( QDateTime::currentDateTime() );
157} 161}
158bool Todo::hasRunningSub() 162bool Todo::hasRunningSub()
159{ 163{
160 if ( mRunning ) 164 if ( mRunning )
161 return true; 165 return true;
162 Incidence *aTodo; 166 Incidence *aTodo;
163 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 167 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
164 if ( ((Todo*)aTodo)->hasRunningSub() ) 168 if ( ((Todo*)aTodo)->hasRunningSub() )
165 return true; 169 return true;
166 } 170 }
167 return false; 171 return false;
168} 172}
169Incidence *Todo::clone() 173Incidence *Todo::clone()
170{ 174{
171 return new Todo(*this); 175 return new Todo(*this);
172} 176}
173 177
174bool Todo::contains ( Todo* from ) 178bool Todo::contains ( Todo* from )
175{ 179{
176 180
177 if ( !from->summary().isEmpty() ) 181 if ( !from->summary().isEmpty() )
178 if ( !summary().startsWith( from->summary() )) 182 if ( !summary().startsWith( from->summary() ))
179 return false; 183 return false;
180 if ( from->hasStartDate() ) { 184 if ( from->hasStartDate() ) {
181 if ( !hasStartDate() ) 185 if ( !hasStartDate() )
182 return false; 186 return false;
183 if ( from->dtStart() != dtStart()) 187 if ( from->dtStart() != dtStart())
184 return false; 188 return false;
185 } 189 }
186 if ( from->hasDueDate() ){ 190 if ( from->hasDueDate() ){
187 if ( !hasDueDate() ) 191 if ( !hasDueDate() )
188 return false; 192 return false;
189 if ( from->dtDue() != dtDue()) 193 if ( from->dtDue() != dtDue())
190 return false; 194 return false;
191 } 195 }
192 if ( !from->location().isEmpty() ) 196 if ( !from->location().isEmpty() )
193 if ( !location().startsWith( from->location() ) ) 197 if ( !location().startsWith( from->location() ) )
194 return false; 198 return false;
195 if ( !from->description().isEmpty() ) 199 if ( !from->description().isEmpty() )
196 if ( !description().startsWith( from->description() )) 200 if ( !description().startsWith( from->description() ))
197 return false; 201 return false;
198 if ( from->alarms().count() ) { 202 if ( from->alarms().count() ) {
199 Alarm *a = from->alarms().first(); 203 Alarm *a = from->alarms().first();
200 if ( a->enabled() ){ 204 if ( a->enabled() ){
201 if ( !alarms().count() ) 205 if ( !alarms().count() )
202 return false; 206 return false;
203 Alarm *b = alarms().first(); 207 Alarm *b = alarms().first();
204 if( ! b->enabled() ) 208 if( ! b->enabled() )
205 return false; 209 return false;
206 if ( ! (a->offset() == b->offset() )) 210 if ( ! (a->offset() == b->offset() ))
207 return false; 211 return false;
208 } 212 }
209 } 213 }
210 214
211 QStringList cat = categories(); 215 QStringList cat = categories();
212 QStringList catFrom = from->categories(); 216 QStringList catFrom = from->categories();
213 QString nCat; 217 QString nCat;
214 unsigned int iii; 218 unsigned int iii;
215 for ( iii = 0; iii < catFrom.count();++iii ) { 219 for ( iii = 0; iii < catFrom.count();++iii ) {
216 nCat = catFrom[iii]; 220 nCat = catFrom[iii];
217 if ( !nCat.isEmpty() ) 221 if ( !nCat.isEmpty() )
218 if ( !cat.contains( nCat )) { 222 if ( !cat.contains( nCat )) {
219 return false; 223 return false;
220 } 224 }
221 } 225 }
222 if ( from->isCompleted() ) { 226 if ( from->isCompleted() ) {
223 if ( !isCompleted() ) 227 if ( !isCompleted() )
224 return false; 228 return false;
225 } 229 }
226 if( priority() != from->priority() ) 230 if( priority() != from->priority() )
227 return false; 231 return false;
228 232
229 233
230 return true; 234 return true;
231 235
232} 236}
233bool KCal::operator==( const Todo& t1, const Todo& t2 ) 237bool KCal::operator==( const Todo& t1, const Todo& t2 )
234{ 238{
235 239
236 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 ); 240 bool ret = operator==( (const Incidence&)t1, (const Incidence&)t2 );
237 if ( ! ret ) 241 if ( ! ret )
238 return false; 242 return false;
239 if ( t1.hasDueDate() == t2.hasDueDate() ) { 243 if ( t1.hasDueDate() == t2.hasDueDate() ) {
240 if ( t1.hasDueDate() ) { 244 if ( t1.hasDueDate() ) {
241 if ( t1.doesFloat() == t2.doesFloat() ) { 245 if ( t1.doesFloat() == t2.doesFloat() ) {
242 if ( t1.doesFloat() ) { 246 if ( t1.doesFloat() ) {
243 if ( t1.dtDue().date() != t2.dtDue().date() ) 247 if ( t1.dtDue().date() != t2.dtDue().date() )
244 return false; 248 return false;
245 } else 249 } else
246 if ( t1.dtDue() != t2.dtDue() ) 250 if ( t1.dtDue() != t2.dtDue() )
247 return false; 251 return false;
248 } else 252 } else
249 return false;// float != 253 return false;// float !=
250 } 254 }
251 255
252 } else 256 } else
253 return false; 257 return false;
254 if ( t1.percentComplete() != t2.percentComplete() ) 258 if ( t1.percentComplete() != t2.percentComplete() )
255 return false; 259 return false;
256 if ( t1.isCompleted() ) { 260 if ( t1.isCompleted() ) {
257 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) { 261 if ( t1.hasCompletedDate() == t2.hasCompletedDate() ) {
258 if ( t1.hasCompletedDate() ) { 262 if ( t1.hasCompletedDate() ) {
259 if ( t1.completed() != t2.completed() ) 263 if ( t1.completed() != t2.completed() )
260 return false; 264 return false;
261 } 265 }
262 266
263 } else 267 } else
264 return false; 268 return false;
265 } 269 }
266 return true; 270 return true;
267 271
268} 272}
269 273
270void Todo::setDtDue(const QDateTime &dtDue) 274void Todo::setDtDue(const QDateTime &dtDue)
271{ 275{
272 //int diffsecs = mDtDue.secsTo(dtDue); 276 //int diffsecs = mDtDue.secsTo(dtDue);
273 277
274 /*if (mReadOnly) return; 278 /*if (mReadOnly) return;
275 const QPtrList<Alarm>& alarms = alarms(); 279 const QPtrList<Alarm>& alarms = alarms();
276 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) { 280 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) {
277 if (alarm->enabled()) { 281 if (alarm->enabled()) {
278 alarm->setTime(alarm->time().addSecs(diffsecs)); 282 alarm->setTime(alarm->time().addSecs(diffsecs));
279 } 283 }
280 }*/ 284 }*/
281 mDtDue = getEvenTime(dtDue); 285 mDtDue = getEvenTime(dtDue);
282 286
283 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl; 287 //kdDebug(5800) << "setDtDue says date is " << mDtDue.toString() << endl;
284 288
285 /*const QPtrList<Alarm>& alarms = alarms(); 289 /*const QPtrList<Alarm>& alarms = alarms();
286 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next()) 290 for (Alarm* alarm = alarms.first(); alarm; alarm = alarms.next())
287 alarm->setAlarmStart(mDtDue);*/ 291 alarm->setAlarmStart(mDtDue);*/
288 updated(); 292 updated();
289} 293}
290 294
291QDateTime Todo::dtDue() const 295QDateTime Todo::dtDue() const
292{ 296{
293 return mDtDue; 297 return mDtDue;
294} 298}
295 299
296QString Todo::dtDueTimeStr() const 300QString Todo::dtDueTimeStr() const
297{ 301{
298 return KGlobal::locale()->formatTime(mDtDue.time()); 302 return KGlobal::locale()->formatTime(mDtDue.time());
299} 303}
300 304
301QString Todo::dtDueDateStr(bool shortfmt) const 305QString Todo::dtDueDateStr(bool shortfmt) const
302{ 306{
303 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 307 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
304} 308}
305 309
306QString Todo::dtDueStr(bool shortfmt) const 310QString Todo::dtDueStr(bool shortfmt) const
307{ 311{
308 if ( doesFloat() ) 312 if ( doesFloat() )
309 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt); 313 return KGlobal::locale()->formatDate(mDtDue.date(),shortfmt);
310 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt); 314 return KGlobal::locale()->formatDateTime(mDtDue, shortfmt);
311} 315}
312// retval 0 : no found 316// retval 0 : no found
313// 1 : due for date found 317// 1 : due for date found
314// 2 : overdue for date found 318// 2 : overdue for date found
315int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos ) 319int Todo::hasDueSubTodoForDate( const QDate & date, bool checkSubtodos )
316{ 320{
317 int retval = 0; 321 int retval = 0;
318 if ( isCompleted() ) 322 if ( isCompleted() )
319 return 0; 323 return 0;
320 if ( hasDueDate() ) { 324 if ( hasDueDate() ) {
321 if ( dtDue().date() < date ) 325 if ( dtDue().date() < date )
322 return 2; 326 return 2;
323 // we do not return, because we may find an overdue sub todo 327 // we do not return, because we may find an overdue sub todo
324 if ( dtDue().date() == date ) 328 if ( dtDue().date() == date )
325 retval = 1; 329 retval = 1;
326 } 330 }
327 if ( checkSubtodos ) { 331 if ( checkSubtodos ) {
328 Incidence *aTodo; 332 Incidence *aTodo;
329 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) { 333 for (aTodo = mRelations.first(); aTodo; aTodo = mRelations.next()) {
330 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos ); 334 int ret = ((Todo*)aTodo)->hasDueSubTodoForDate( date ,checkSubtodos );
331 if ( ret == 2 ) 335 if ( ret == 2 )
332 return 2; 336 return 2;
333 if ( ret == 1) 337 if ( ret == 1)
334 retval = 1; 338 retval = 1;
335 } 339 }
336 } 340 }
337 return retval; 341 return retval;
338} 342}
339int Todo::hasDueSubTodo( bool checkSubtodos ) //= true 343int Todo::hasDueSubTodo( bool checkSubtodos ) //= true
340{ 344{
341 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos ); 345 return hasDueSubTodoForDate(QDate::currentDate(), checkSubtodos );
342} 346}
343bool Todo::hasDueDate() const 347bool Todo::hasDueDate() const
344{ 348{
345 return mHasDueDate; 349 return mHasDueDate;
346} 350}
347 351
348void Todo::setHasDueDate(bool f) 352void Todo::setHasDueDate(bool f)
349{ 353{
350 if (mReadOnly) return; 354 if (mReadOnly) return;
351 mHasDueDate = f; 355 mHasDueDate = f;
352 updated(); 356 updated();
353} 357}
354 358
355 359
356#if 0 360#if 0
357void Todo::setStatus(const QString &statStr) 361void Todo::setStatus(const QString &statStr)
358{ 362{
359 if (mReadOnly) return; 363 if (mReadOnly) return;
360 QString ss(statStr.upper()); 364 QString ss(statStr.upper());
361 365
362 if (ss == "X-ACTION") 366 if (ss == "X-ACTION")
363 mStatus = NEEDS_ACTION; 367 mStatus = NEEDS_ACTION;
364 else if (ss == "NEEDS ACTION") 368 else if (ss == "NEEDS ACTION")
365 mStatus = NEEDS_ACTION; 369 mStatus = NEEDS_ACTION;
366 else if (ss == "ACCEPTED") 370 else if (ss == "ACCEPTED")
367 mStatus = ACCEPTED; 371 mStatus = ACCEPTED;
368 else if (ss == "SENT") 372 else if (ss == "SENT")
369 mStatus = SENT; 373 mStatus = SENT;
370 else if (ss == "TENTATIVE") 374 else if (ss == "TENTATIVE")
371 mStatus = TENTATIVE; 375 mStatus = TENTATIVE;
372 else if (ss == "CONFIRMED") 376 else if (ss == "CONFIRMED")
373 mStatus = CONFIRMED; 377 mStatus = CONFIRMED;
374 else if (ss == "DECLINED") 378 else if (ss == "DECLINED")
375 mStatus = DECLINED; 379 mStatus = DECLINED;
376 else if (ss == "COMPLETED") 380 else if (ss == "COMPLETED")
377 mStatus = COMPLETED; 381 mStatus = COMPLETED;
378 else if (ss == "DELEGATED") 382 else if (ss == "DELEGATED")
379 mStatus = DELEGATED; 383 mStatus = DELEGATED;
380 384
381 updated(); 385 updated();
382} 386}
383 387
384void Todo::setStatus(int status) 388void Todo::setStatus(int status)
385{ 389{
386 if (mReadOnly) return; 390 if (mReadOnly) return;
387 mStatus = status; 391 mStatus = status;
388 updated(); 392 updated();
389} 393}
390 394
391int Todo::status() const 395int Todo::status() const
392{ 396{
393 return mStatus; 397 return mStatus;
394} 398}
395 399
396QString Todo::statusStr() const 400QString Todo::statusStr() const
397{ 401{
398 switch(mStatus) { 402 switch(mStatus) {
399 case NEEDS_ACTION: 403 case NEEDS_ACTION:
400 return QString("NEEDS ACTION"); 404 return QString("NEEDS ACTION");
401 break; 405 break;
402 case ACCEPTED: 406 case ACCEPTED:
403 return QString("ACCEPTED"); 407 return QString("ACCEPTED");
404 break; 408 break;
405 case SENT: 409 case SENT:
406 return QString("SENT"); 410 return QString("SENT");
407 break; 411 break;
408 case TENTATIVE: 412 case TENTATIVE:
409 return QString("TENTATIVE"); 413 return QString("TENTATIVE");
410 break; 414 break;
411 case CONFIRMED: 415 case CONFIRMED:
412 return QString("CONFIRMED"); 416 return QString("CONFIRMED");
413 break; 417 break;
414 case DECLINED: 418 case DECLINED:
415 return QString("DECLINED"); 419 return QString("DECLINED");
416 break; 420 break;
417 case COMPLETED: 421 case COMPLETED:
418 return QString("COMPLETED"); 422 return QString("COMPLETED");
419 break; 423 break;
420 case DELEGATED: 424 case DELEGATED:
421 return QString("DELEGATED"); 425 return QString("DELEGATED");
422 break; 426 break;
423 } 427 }
424 return QString(""); 428 return QString("");
425} 429}
426#endif 430#endif
427 431
428bool Todo::isCompleted() const 432bool Todo::isCompleted() const
429{ 433{
430 if (mPercentComplete == 100) { 434 if (mPercentComplete == 100) {
431 return true; 435 return true;
432 } 436 }
433 else return false; 437 else return false;
434} 438}
435 439
436void Todo::setCompleted(bool completed) 440void Todo::setCompleted(bool completed)
437{ 441{
438 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) { 442 if ( mHasRecurrenceID && completed && mPercentComplete != 100 ) {
439 if ( !setRecurDates() ) 443 if ( !setRecurDates() )
440 completed = false; 444 completed = false;
441 } 445 }
442 if (completed) mPercentComplete = 100; 446 if (completed) mPercentComplete = 100;
443 else { 447 else {
444 mPercentComplete = 0; 448 mPercentComplete = 0;
445 mHasCompletedDate = false; 449 mHasCompletedDate = false;
446 } 450 }
447 updated(); 451 updated();
448} 452}
449 453
450QDateTime Todo::completed() const 454QDateTime Todo::completed() const
451{ 455{
452 return mCompleted; 456 return mCompleted;
453} 457}
454 458
455QString Todo::completedStr( bool shortF ) const 459QString Todo::completedStr( bool shortF ) const
456{ 460{
457 return KGlobal::locale()->formatDateTime(mCompleted, shortF); 461 return KGlobal::locale()->formatDateTime(mCompleted, shortF);
458} 462}
459 463
460void Todo::setCompleted(const QDateTime &completed) 464void Todo::setCompleted(const QDateTime &completed)
461{ 465{
462 //qDebug("Todo::setCompleted "); 466 //qDebug("Todo::setCompleted ");
463 if ( mHasCompletedDate ) { 467 if ( mHasCompletedDate ) {
464 // qDebug("has completed data - return "); 468 // qDebug("has completed data - return ");
465 return; 469 return;
466 } 470 }
467 mHasCompletedDate = true; 471 mHasCompletedDate = true;
468 mPercentComplete = 100; 472 mPercentComplete = 100;
469 mCompleted = getEvenTime(completed); 473 mCompleted = getEvenTime(completed);
470 updated(); 474 updated();
471} 475}
472 476
473bool Todo::hasCompletedDate() const 477bool Todo::hasCompletedDate() const
474{ 478{
475 return mHasCompletedDate; 479 return mHasCompletedDate;
476} 480}
477 481
478int Todo::percentComplete() const 482int Todo::percentComplete() const
479{ 483{
480 return mPercentComplete; 484 return mPercentComplete;
481} 485}
482bool Todo::setRecurDates() 486bool Todo::setRecurDates()
483{ 487{
484 if ( !mHasRecurrenceID ) 488 if ( !mHasRecurrenceID )
485 return true; 489 return true;
486 int secs = mDtStart.secsTo( dtDue() ); 490 int secs = mDtStart.secsTo( dtDue() );
487 bool ok; 491 bool ok;
488 qDebug("T:setRecurDates() "); 492 qDebug("T:setRecurDates() ");
489 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 493 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
490 QDateTime next = getNextOccurence( mRecurrenceID, &ok ); 494 QDateTime next = getNextOccurence( mRecurrenceID, &ok );
491 if ( ok ) { 495 if ( ok ) {
492 mRecurrenceID = next; 496 mRecurrenceID = next;
493 mDtStart = next; 497 mDtStart = next;
494 setDtDue( next.addSecs( secs ) ); 498 setDtDue( next.addSecs( secs ) );
495 if ( QDateTime::currentDateTime() > next) 499 if ( QDateTime::currentDateTime() > next)
496 return false; 500 return false;
497 } else { 501 } else {
498 setHasRecurrenceID( false ); 502 setHasRecurrenceID( false );
499 recurrence()->unsetRecurs(); 503 recurrence()->unsetRecurs();
500 } 504 }
501 return true; 505 return true;
502} 506}
503void Todo::setPercentComplete(int v) 507void Todo::setPercentComplete(int v)
504{ 508{
505 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) { 509 if ( mHasRecurrenceID && v == 100 && mPercentComplete != 100 ) {
506 if ( !setRecurDates() ) 510 if ( !setRecurDates() )
507 v = 0; 511 v = 0;
508 } 512 }
509 mPercentComplete = v; 513 mPercentComplete = v;
510 if ( v != 100 ) 514 if ( v != 100 )
511 mHasCompletedDate = false; 515 mHasCompletedDate = false;
512 updated(); 516 updated();
513} 517}
514QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const 518QDateTime Todo::getNextAlarmDateTime( bool * ok, int * offset ) const
515{ 519{
516 if ( isCompleted() || ! hasDueDate() || cancelled() ) { 520 if ( isCompleted() || ! hasDueDate() || cancelled() ) {
517 *ok = false; 521 *ok = false;
518 return QDateTime (); 522 return QDateTime ();
519 } 523 }
520 QDateTime incidenceStart; 524 QDateTime incidenceStart;
521 incidenceStart = dtDue(); 525 incidenceStart = dtDue();
522 bool enabled = false; 526 bool enabled = false;
523 Alarm* alarm; 527 Alarm* alarm;
524 int off = 0; 528 int off = 0;
525 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );; 529 QDateTime alarmStart = QDateTime::currentDateTime().addDays( 3650 );;
526 // if ( QDateTime::currentDateTime() > incidenceStart ){ 530 // if ( QDateTime::currentDateTime() > incidenceStart ){
527// *ok = false; 531// *ok = false;
528// return incidenceStart; 532// return incidenceStart;
529// } 533// }
530 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) { 534 for (QPtrListIterator<Alarm> it(mAlarms); (alarm = it.current()) != 0; ++it) {
531 if (alarm->enabled()) { 535 if (alarm->enabled()) {
532 if ( alarm->hasTime () ) { 536 if ( alarm->hasTime () ) {
533 if ( alarm->time() < alarmStart ) { 537 if ( alarm->time() < alarmStart ) {
534 alarmStart = alarm->time(); 538 alarmStart = alarm->time();
535 enabled = true; 539 enabled = true;
536 off = alarmStart.secsTo( incidenceStart ); 540 off = alarmStart.secsTo( incidenceStart );
537 } 541 }
538 542
539 } else { 543 } else {
540 int secs = alarm->startOffset().asSeconds(); 544 int secs = alarm->startOffset().asSeconds();
541 if ( incidenceStart.addSecs( secs ) < alarmStart ) { 545 if ( incidenceStart.addSecs( secs ) < alarmStart ) {
542 alarmStart = incidenceStart.addSecs( secs ); 546 alarmStart = incidenceStart.addSecs( secs );
543 enabled = true; 547 enabled = true;
544 off = -secs; 548 off = -secs;
545 } 549 }
546 } 550 }
547 } 551 }
548 } 552 }
549 if ( enabled ) { 553 if ( enabled ) {
550 if ( alarmStart > QDateTime::currentDateTime() ) { 554 if ( alarmStart > QDateTime::currentDateTime() ) {
551 *ok = true; 555 *ok = true;
552 * offset = off; 556 * offset = off;
553 return alarmStart; 557 return alarmStart;
554 } 558 }
555 } 559 }
556 *ok = false; 560 *ok = false;
557 return QDateTime (); 561 return QDateTime ();
558 562
559} 563}
560 564
561void Todo::checkSetCompletedFalse() 565void Todo::checkSetCompletedFalse()
562{ 566{
563 if ( !hasRecurrenceID() ) { 567 if ( !hasRecurrenceID() ) {
564 qDebug("ERROR 1 in Todo::checkSetCompletedFalse"); 568 qDebug("ERROR 1 in Todo::checkSetCompletedFalse");
565 } 569 }
566 // qDebug("Todo::checkSetCompletedFalse()"); 570 // qDebug("Todo::checkSetCompletedFalse()");
567 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 571 //qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
568 if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) { 572 if ( mPercentComplete == 100 && mDtStart == mRecurrenceID && QDateTime::currentDateTime() > mDtStart) {
569 qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() ); 573 qDebug("%s %s %s ",mDtStart.toString().latin1(), dtDue().toString().latin1(),mRecurrenceID.toString().latin1() );
570 setCompleted( false ); 574 setCompleted( false );
571 qDebug("Todo::checkSetCompletedFalse "); 575 qDebug("Todo::checkSetCompletedFalse ");
572 } 576 }
573} 577}
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 2d97c8c..4271b55 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -1,939 +1,944 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/////////////////// KDateTable widget class ////////////////////// 21/////////////////// KDateTable widget class //////////////////////
22// 22//
23// Copyright (C) 1997 Tim D. Gilman 23// Copyright (C) 1997 Tim D. Gilman
24// (C) 1998-2001 Mirko Boehm 24// (C) 1998-2001 Mirko Boehm
25// Written using Qt (http://www.troll.no) for the 25// Written using Qt (http://www.troll.no) for the
26// KDE project (http://www.kde.org) 26// KDE project (http://www.kde.org)
27// 27//
28// This is a support class for the KDatePicker class. It just 28// This is a support class for the KDatePicker class. It just
29// draws the calender table without titles, but could theoretically 29// draws the calender table without titles, but could theoretically
30// be used as a standalone. 30// be used as a standalone.
31// 31//
32// When a date is selected by the user, it emits a signal: 32// When a date is selected by the user, it emits a signal:
33// dateSelected(QDate) 33// dateSelected(QDate)
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kglobalsettings.h> 36#include <kglobalsettings.h>
37#include <kapplication.h> 37#include <kapplication.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <knotifyclient.h> 40#include <knotifyclient.h>
41#include "kdatetbl.h" 41#include "kdatetbl.h"
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qstring.h> 43#include <qstring.h>
44#include <qpen.h> 44#include <qpen.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <assert.h> 47#include <assert.h>
48#include <qapplication.h> 48#include <qapplication.h>
49 49
50KDateValidator::KDateValidator(QWidget* parent, const char* name) 50KDateValidator::KDateValidator(QWidget* parent, const char* name)
51 : QValidator(parent, name) 51 : QValidator(parent, name)
52{ 52{
53} 53}
54 54
55QValidator::State 55QValidator::State
56KDateValidator::validate(QString& text, int&) const 56KDateValidator::validate(QString& text, int&) const
57{ 57{
58 QDate temp; 58 QDate temp;
59 // ----- everything is tested in date(): 59 // ----- everything is tested in date():
60 return date(text, temp); 60 return date(text, temp);
61} 61}
62 62
63QValidator::State 63QValidator::State
64KDateValidator::date(const QString& text, QDate& d) const 64KDateValidator::date(const QString& text, QDate& d) const
65{ 65{
66 QDate tmp = KGlobal::locale()->readDate(text); 66 QDate tmp = KGlobal::locale()->readDate(text);
67 if (!tmp.isNull()) 67 if (!tmp.isNull())
68 { 68 {
69 d = tmp; 69 d = tmp;
70 return Acceptable; 70 return Acceptable;
71 } else 71 } else
72 return Valid; 72 return Valid;
73} 73}
74 74
75void 75void
76KDateValidator::fixup( QString& ) const 76KDateValidator::fixup( QString& ) const
77{ 77{
78 78
79} 79}
80 80
81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) 81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f)
82 : QGridView(parent, name, f) 82 : QGridView(parent, name, f)
83{ 83{
84 setFont( KGlobalSettings::generalFont() ); 84 setFont( KGlobalSettings::generalFont() );
85 if(!date_.isValid()) 85 if(!date_.isValid())
86 { 86 {
87 date_=QDate::currentDate(); 87 date_=QDate::currentDate();
88 } 88 }
89 setFocusPolicy( QWidget::StrongFocus ); 89 setFocusPolicy( QWidget::StrongFocus );
90 setNumRows(7); // 6 weeks max + headline 90 setNumRows(7); // 6 weeks max + headline
91 setNumCols(7); // 7 days a week 91 setNumCols(7); // 7 days a week
92 setHScrollBarMode(AlwaysOff); 92 setHScrollBarMode(AlwaysOff);
93 setVScrollBarMode(AlwaysOff); 93 setVScrollBarMode(AlwaysOff);
94 viewport()->setBackgroundColor(QColor(220,245,255)); 94 viewport()->setBackgroundColor(QColor(220,245,255));
95#if 0 95#if 0
96 viewport()->setEraseColor(lightGray); 96 viewport()->setEraseColor(lightGray);
97#endif 97#endif
98 mMarkCurrent = false; 98 mMarkCurrent = false;
99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth 99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
100} 100}
101 101
102void 102void
103KDateTable::paintCell(QPainter *painter, int row, int col) 103KDateTable::paintCell(QPainter *painter, int row, int col)
104{ 104{
105 QRect rect; 105 QRect rect;
106 QString text; 106 QString text;
107 QPen pen; 107 QPen pen;
108 int w=cellWidth(); 108 int w=cellWidth();
109 int h=cellHeight(); 109 int h=cellHeight();
110 int pos; 110 int pos;
111 QBrush brushBlue(blue); 111 QBrush brushBlue(blue);
112 QBrush brushLightblue(QColor(220,245,255)); 112 QBrush brushLightblue(QColor(220,245,255));
113 QFont _font=font(); 113 QFont _font=font();
114 // ----- 114 // -----
115 if(row==0) 115 if(row==0)
116 { // we are drawing the headline 116 { // we are drawing the headline
117 _font.setBold(true); 117 _font.setBold(true);
118 painter->setFont(_font); 118 painter->setFont(_font);
119 bool normalday = true; 119 bool normalday = true;
120 QString daystr; 120 QString daystr;
121 if (KGlobal::locale()->weekStartsMonday()) 121 if (KGlobal::locale()->weekStartsMonday())
122 { 122 {
123 daystr = KGlobal::locale()->weekDayName(col+1, true); 123 daystr = KGlobal::locale()->weekDayName(col+1, true);
124 if (col == 5 || col == 6) 124 if (col == 5 || col == 6)
125 normalday = false; 125 normalday = false;
126 } else { 126 } else {
127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); 127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
128 if (col == 0 || col == 6) 128 if (col == 0 || col == 6)
129 normalday = false; 129 normalday = false;
130 } 130 }
131 if (!normalday) 131 if (!normalday)
132 { 132 {
133 painter->setPen(QColor(220,245,255)); 133 painter->setPen(QColor(220,245,255));
134 painter->setBrush(brushLightblue); 134 painter->setBrush(brushLightblue);
135 painter->drawRect(0, 0, w, h); 135 painter->drawRect(0, 0, w, h);
136 painter->setPen(blue); 136 painter->setPen(blue);
137 } else { 137 } else {
138 painter->setPen(blue); 138 painter->setPen(blue);
139 painter->setBrush(brushBlue); 139 painter->setBrush(brushBlue);
140 painter->drawRect(0, 0, w, h); 140 painter->drawRect(0, 0, w, h);
141 painter->setPen(white); 141 painter->setPen(white);
142 } 142 }
143 painter->drawText(0, 0, w, h-1, AlignCenter, 143 painter->drawText(0, 0, w, h-1, AlignCenter,
144 daystr, -1, &rect); 144 daystr, -1, &rect);
145 painter->setPen(black); 145 painter->setPen(black);
146 painter->moveTo(0, h-1); 146 painter->moveTo(0, h-1);
147 painter->lineTo(w-1, h-1); 147 painter->lineTo(w-1, h-1);
148 // ----- draw the weekday: 148 // ----- draw the weekday:
149 } else { 149 } else {
150 painter->setFont(_font); 150 painter->setFont(_font);
151 pos=7*(row-1)+col; 151 pos=7*(row-1)+col;
152 if (KGlobal::locale()->weekStartsMonday()) 152 if (KGlobal::locale()->weekStartsMonday())
153 pos++; 153 pos++;
154 if(pos<firstday || (firstday+numdays<=pos)) 154 if(pos<firstday || (firstday+numdays<=pos))
155 { // we are either 155 { // we are either
156 // ° painting a day of the previous month or 156 // ° painting a day of the previous month or
157 // ° painting a day of the following month 157 // ° painting a day of the following month
158 if(pos<firstday) 158 if(pos<firstday)
159 { // previous month 159 { // previous month
160 text.setNum(numDaysPrevMonth+pos-firstday+1); 160 text.setNum(numDaysPrevMonth+pos-firstday+1);
161 } else { // following month 161 } else { // following month
162 text.setNum(pos-firstday-numdays+1); 162 text.setNum(pos-firstday-numdays+1);
163 } 163 }
164 painter->setPen(gray); 164 painter->setPen(gray);
165 } else { // paint a day of the current month 165 } else { // paint a day of the current month
166 text.setNum(pos-firstday+1); 166 text.setNum(pos-firstday+1);
167 painter->setPen(black); 167 painter->setPen(black);
168 } 168 }
169 169
170 pen=painter->pen(); 170 pen=painter->pen();
171 if(firstday+date.day()-1==pos) 171 if(firstday+date.day()-1==pos)
172 { 172 {
173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
174 painter->setPen(green); 174 painter->setPen(green);
175 else 175 else
176 painter->setPen(red); 176 painter->setPen(red);
177 if(hasFocus()) 177 if(hasFocus())
178 { 178 {
179 painter->setBrush(darkRed); 179 painter->setBrush(darkRed);
180 pen=white; 180 pen=white;
181 } else { 181 } else {
182 painter->setBrush(darkGray); 182 painter->setBrush(darkGray);
183 pen=white; 183 pen=white;
184 } 184 }
185 } else { 185 } else {
186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
187 { 187 {
188 painter->setPen(green); 188 painter->setPen(green);
189 painter->setBrush(darkGreen); 189 painter->setBrush(darkGreen);
190 pen=white; 190 pen=white;
191 } else { 191 } else {
192 painter->setBrush(QColor(220,245,255)); 192 painter->setBrush(QColor(220,245,255));
193 painter->setPen(QColor(220,245,255)); 193 painter->setPen(QColor(220,245,255));
194 } 194 }
195 } 195 }
196 painter->drawRect(0, 0, w, h); 196 painter->drawRect(0, 0, w, h);
197 painter->setPen(pen); 197 painter->setPen(pen);
198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); 198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect);
199 } 199 }
200 /* 200 /*
201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); 201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
202 if(rect.height()>maxCell.height()) { 202 if(rect.height()>maxCell.height()) {
203 maxCell.setHeight(rect.height()); 203 maxCell.setHeight(rect.height());
204 } 204 }
205 */ 205 */
206} 206}
207 207
208void 208void
209KDateTable::keyPressEvent( QKeyEvent *e ) 209KDateTable::keyPressEvent( QKeyEvent *e )
210{ 210{
211 /* 211 /*
212 // not working properly 212 // not working properly
213 if ( e->key() == Qt::Key_Prior ) { 213 if ( e->key() == Qt::Key_Prior ) {
214 if ( date.month() == 1 ) { 214 if ( date.month() == 1 ) {
215 KNotifyClient::beep(); 215 KNotifyClient::beep();
216 return; 216 return;
217 } 217 }
218 int day = date.day(); 218 int day = date.day();
219 if ( day > 27 ) 219 if ( day > 27 )
220 while ( !QDate::isValid( date.year(), date.month()-1, day ) ) 220 while ( !QDate::isValid( date.year(), date.month()-1, day ) )
221 day--; 221 day--;
222 setDate(QDate(date.year(), date.month()-1, day)); 222 setDate(QDate(date.year(), date.month()-1, day));
223 return; 223 return;
224 } 224 }
225 if ( e->key() == Qt::Key_Next ) { 225 if ( e->key() == Qt::Key_Next ) {
226 if ( date.month() == 12 ) { 226 if ( date.month() == 12 ) {
227 KNotifyClient::beep(); 227 KNotifyClient::beep();
228 return; 228 return;
229 } 229 }
230 int day = date.day(); 230 int day = date.day();
231 if ( day > 27 ) 231 if ( day > 27 )
232 while ( !QDate::isValid( date.year(), date.month()+1, day ) ) 232 while ( !QDate::isValid( date.year(), date.month()+1, day ) )
233 day--; 233 day--;
234 setDate(QDate(date.year(), date.month()+1, day)); 234 setDate(QDate(date.year(), date.month()+1, day));
235 return; 235 return;
236 } 236 }
237 */ 237 */
238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
239 239
240 int temp=firstday+date.day()-dayoff; 240 int temp=firstday+date.day()-dayoff;
241 int pos = temp; 241 int pos = temp;
242 bool irgnore = true; 242 bool irgnore = true;
243 if ( e->state() != Qt::ControlButton ) { 243 if ( e->state() != Qt::ControlButton ) {
244 if ( e->key() == Qt::Key_Up ) { 244 if ( e->key() == Qt::Key_Up ) {
245 pos -= 7; 245 pos -= 7;
246 irgnore = false; 246 irgnore = false;
247 } 247 }
248 if ( e->key() == Qt::Key_Down ) { 248 if ( e->key() == Qt::Key_Down ) {
249 pos += 7; 249 pos += 7;
250 irgnore = false; 250 irgnore = false;
251 } 251 }
252 if ( e->key() == Qt::Key_Left ) { 252 if ( e->key() == Qt::Key_Left ) {
253 pos--; 253 pos--;
254 irgnore = false; 254 irgnore = false;
255 } 255 }
256 if ( e->key() == Qt::Key_Right ) { 256 if ( e->key() == Qt::Key_Right ) {
257 pos++; 257 pos++;
258 irgnore = false; 258 irgnore = false;
259 } 259 }
260 } 260 }
261 if ( irgnore ) 261 if ( irgnore )
262 e->ignore(); 262 e->ignore();
263 263
264 if(pos+dayoff<=firstday) 264 if(pos+dayoff<=firstday)
265 { // this day is in the previous month 265 { // this day is in the previous month
266 KNotifyClient::beep(); 266 KNotifyClient::beep();
267 return; 267 return;
268 } 268 }
269 if(firstday+numdays<pos+dayoff) 269 if(firstday+numdays<pos+dayoff)
270 { // this date is in the next month 270 { // this date is in the next month
271 KNotifyClient::beep(i18n( "Month not long enough" )); 271 KNotifyClient::beep(i18n( "Month not long enough" ));
272 return; 272 return;
273 } 273 }
274 274
275 if ( pos == temp ) 275 if ( pos == temp )
276 return; 276 return;
277 277
278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff)); 278 setDate(QDate(date.year(), date.month(), pos-firstday+dayoff));
279 updateCell(temp/7+1, temp%7); // Update the previously selected cell 279 updateCell(temp/7+1, temp%7); // Update the previously selected cell
280 updateCell(pos/7+1, pos%7); // Update the selected cell 280 updateCell(pos/7+1, pos%7); // Update the selected cell
281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 281 assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
282 282
283 283
284} 284}
285 285
286void 286void
287KDateTable::viewportResizeEvent(QResizeEvent * e) 287KDateTable::viewportResizeEvent(QResizeEvent * e)
288{ 288{
289 QGridView::viewportResizeEvent(e); 289 QGridView::viewportResizeEvent(e);
290 290
291 setCellWidth(viewport()->width()/7); 291 setCellWidth(viewport()->width()/7);
292 setCellHeight(viewport()->height()/7); 292 setCellHeight(viewport()->height()/7);
293} 293}
294 294
295void 295void
296KDateTable::setFontSize(int size) 296KDateTable::setFontSize(int size)
297{ 297{
298 int count; 298 int count;
299 QRect rect; 299 QRect rect;
300 // ----- store rectangles: 300 // ----- store rectangles:
301 fontsize=size; 301 fontsize=size;
302 QFont _font = font(); 302 QFont _font = font();
303 _font.setPointSize(fontsize); 303 _font.setPointSize(fontsize);
304 setFont( _font ); 304 setFont( _font );
305 _font.setBold( true ); 305 _font.setBold( true );
306 QFontMetrics metrics(_font); 306 QFontMetrics metrics(_font);
307 307
308 // ----- find largest day name: 308 // ----- find largest day name:
309 maxCell.setWidth(0); 309 maxCell.setWidth(0);
310 maxCell.setHeight(0); 310 maxCell.setHeight(0);
311 for(count=0; count<7; ++count) 311 for(count=0; count<7; ++count)
312 { 312 {
313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 313 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
314 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 314 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
315 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 315 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
316 } 316 }
317 // ----- compare with a real wide number and add some space: 317 // ----- compare with a real wide number and add some space:
318 rect=metrics.boundingRect(QString::fromLatin1("88")); 318 rect=metrics.boundingRect(QString::fromLatin1("88"));
319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 319 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
320#ifdef DESKTOP_VERSION 320#ifdef DESKTOP_VERSION
321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 321 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
322#else 322#else
323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 323 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
324#endif 324#endif
325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 325 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
326 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 326 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
327 //qDebug("setmax "); 327 //qDebug("setmax ");
328 } 328 }
329} 329}
330 330
331void 331void
332KDateTable::contentsMousePressEvent(QMouseEvent *e) 332KDateTable::contentsMousePressEvent(QMouseEvent *e)
333{ 333{
334 if(e->type()!=QEvent::MouseButtonPress) 334 if(e->type()!=QEvent::MouseButtonPress)
335 { // the KDatePicker only reacts on mouse press events: 335 { // the KDatePicker only reacts on mouse press events:
336 return; 336 return;
337 } 337 }
338 if(!isEnabled()) 338 if(!isEnabled())
339 { 339 {
340 KNotifyClient::beep(); 340 KNotifyClient::beep();
341 return; 341 return;
342 } 342 }
343 343
344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 344 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
345 // ----- 345 // -----
346 int row, col, pos, temp; 346 int row, col, pos, temp;
347 QPoint mouseCoord; 347 QPoint mouseCoord;
348 // ----- 348 // -----
349 mouseCoord = e->pos(); 349 mouseCoord = e->pos();
350 row=rowAt(mouseCoord.y()); 350 row=rowAt(mouseCoord.y());
351 col=columnAt(mouseCoord.x()); 351 col=columnAt(mouseCoord.x());
352 if(row<0 || col<0) 352 if(row<0 || col<0)
353 { // the user clicked on the frame of the table 353 { // the user clicked on the frame of the table
354 return; 354 return;
355 } 355 }
356 pos=7*(row-1)+col+1; 356 pos=7*(row-1)+col+1;
357#if 0 357#if 0
358 if(pos+dayoff<=firstday) 358 if(pos+dayoff<=firstday)
359 { // this day is in the previous month 359 { // this day is in the previous month
360 KNotifyClient::beep(); 360 KNotifyClient::beep();
361 return; 361 return;
362 } 362 }
363 if(firstday+numdays<pos+dayoff) 363 if(firstday+numdays<pos+dayoff)
364 { // this date is in the next month 364 { // this date is in the next month
365 KNotifyClient::beep(); 365 KNotifyClient::beep();
366 return; 366 return;
367 } 367 }
368#endif 368#endif
369 temp=firstday+date.day()-dayoff-1; 369 temp=firstday+date.day()-dayoff-1;
370 QDate da = QDate(date.year(), date.month(),1); 370 QDate da = QDate(date.year(), date.month(),1);
371 setDate(da.addDays( pos-firstday+dayoff-1)); 371 setDate(da.addDays( pos-firstday+dayoff-1));
372 updateCell(temp/7+1, temp%7); // Update the previously selected cell 372 updateCell(temp/7+1, temp%7); // Update the previously selected cell
373 updateCell(row, col); // Update the selected cell 373 updateCell(row, col); // Update the selected cell
374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 374 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
375 emit(tableClicked()); 375 emit(tableClicked());
376} 376}
377 377
378bool 378bool
379KDateTable::setDate(const QDate& date_) 379KDateTable::setDate(const QDate& date_)
380{ 380{
381 bool changed=false; 381 bool changed=false;
382 QDate temp; 382 QDate temp;
383 mMarkCurrent = false; 383 mMarkCurrent = false;
384 // ----- 384 // -----
385 if(!date_.isValid()) 385 if(!date_.isValid())
386 { 386 {
387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 387 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
388 return false; 388 return false;
389 } 389 }
390 if(date!=date_) 390 if(date!=date_)
391 { 391 {
392 date=date_; 392 date=date_;
393 changed=true; 393 changed=true;
394 } 394 }
395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 395 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
396 temp.setYMD(date.year(), date.month(), 1); 396 temp.setYMD(date.year(), date.month(), 1);
397 firstday=temp.dayOfWeek(); 397 firstday=temp.dayOfWeek();
398 if(firstday==1) firstday=8; 398 if(firstday==1) firstday=8;
399 numdays=date.daysInMonth(); 399 numdays=date.daysInMonth();
400 if(date.month()==1) 400 if(date.month()==1)
401 { // set to december of previous year 401 { // set to december of previous year
402 temp.setYMD(date.year()-1, 12, 1); 402 temp.setYMD(date.year()-1, 12, 1);
403 } else { // set to previous month 403 } else { // set to previous month
404 temp.setYMD(date.year(), date.month()-1, 1); 404 temp.setYMD(date.year(), date.month()-1, 1);
405 } 405 }
406 numDaysPrevMonth=temp.daysInMonth(); 406 numDaysPrevMonth=temp.daysInMonth();
407 if(changed) 407 if(changed)
408 { 408 {
409 repaintContents(false); 409 repaintContents(false);
410 } 410 }
411 emit(dateChanged(date)); 411 emit(dateChanged(date));
412 return true; 412 return true;
413} 413}
414 414
415const QDate& 415const QDate&
416KDateTable::getDate() const 416KDateTable::getDate() const
417{ 417{
418 return date; 418 return date;
419} 419}
420 420
421void KDateTable::focusInEvent( QFocusEvent *e ) 421void KDateTable::focusInEvent( QFocusEvent *e )
422{ 422{
423 repaintContents(false); 423 repaintContents(false);
424 QGridView::focusInEvent( e ); 424 QGridView::focusInEvent( e );
425} 425}
426 426
427void KDateTable::focusOutEvent( QFocusEvent *e ) 427void KDateTable::focusOutEvent( QFocusEvent *e )
428{ 428{
429 repaintContents(false); 429 repaintContents(false);
430 QGridView::focusOutEvent( e ); 430 QGridView::focusOutEvent( e );
431} 431}
432 432
433QSize 433QSize
434KDateTable::sizeHint() const 434KDateTable::sizeHint() const
435{ 435{
436 if(maxCell.height()>0 && maxCell.width()>0) 436 if(maxCell.height()>0 && maxCell.width()>0)
437 { 437 {
438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 438 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
439 (maxCell.height()+4)*numRows()+2*frameWidth()); 439 (maxCell.height()+4)*numRows()+2*frameWidth());
440 } else { 440 } else {
441 return QSize(-1, -1); 441 return QSize(-1, -1);
442 } 442 }
443} 443}
444 444
445KDateInternalMonthPicker::KDateInternalMonthPicker 445KDateInternalMonthPicker::KDateInternalMonthPicker
446(QWidget* parent, const char* name) 446(QWidget* parent, const char* name)
447 : QGridView(parent, name), 447 : QGridView(parent, name),
448 result(0) // invalid 448 result(0) // invalid
449{ 449{
450 QRect rect; 450 QRect rect;
451 QFont font; 451 QFont font;
452 // ----- 452 // -----
453 activeCol = -1; 453 activeCol = -1;
454 activeRow = -1; 454 activeRow = -1;
455 font=KGlobalSettings::generalFont(); 455 font=KGlobalSettings::generalFont();
456 int fontsize = 10; 456 int fontsize = 10;
457 int add = 2; 457 int add = 2;
458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 458 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
459 add += 8; 459 add += 8;
460 if ( QApplication::desktop()->width() > 640 ) 460 if ( QApplication::desktop()->width() > 640 )
461 add += 6; 461 add += 6;
462 font.setPointSize(fontsize+add); 462 font.setPointSize(fontsize+add);
463 setFont(font); 463 setFont(font);
464 setHScrollBarMode(AlwaysOff); 464 setHScrollBarMode(AlwaysOff);
465 setVScrollBarMode(AlwaysOff); 465 setVScrollBarMode(AlwaysOff);
466 setFrameStyle(QFrame::NoFrame); 466 setFrameStyle(QFrame::NoFrame);
467 setNumRows(4); 467 setNumRows(4);
468 setNumCols(3); 468 setNumCols(3);
469 // enable to find drawing failures: 469 // enable to find drawing failures:
470 // setTableFlags(Tbl_clipCellPainting); 470 // setTableFlags(Tbl_clipCellPainting);
471#if 0 471#if 0
472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 472 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
473#endif 473#endif
474 // ----- find the preferred size 474 // ----- find the preferred size
475 // (this is slow, possibly, but unfortunatly it is needed here): 475 // (this is slow, possibly, but unfortunatly it is needed here):
476 QFontMetrics metrics(font); 476 QFontMetrics metrics(font);
477 for(int i=1; i <= 12; ++i) 477 for(int i=1; i <= 12; ++i)
478 { 478 {
479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 479 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
480 if(max.width()<rect.width()) max.setWidth(rect.width()); 480 if(max.width()<rect.width()) max.setWidth(rect.width());
481 if(max.height()<rect.height()) max.setHeight(rect.height()); 481 if(max.height()<rect.height()) max.setHeight(rect.height());
482 } 482 }
483 483
484} 484}
485 485
486QSize 486QSize
487KDateInternalMonthPicker::sizeHint() const 487KDateInternalMonthPicker::sizeHint() const
488{ 488{
489 return QSize((max.width()+6)*numCols()+2*frameWidth(), 489 return QSize((max.width()+6)*numCols()+2*frameWidth(),
490 (max.height()+6)*numRows()+2*frameWidth()); 490 (max.height()+6)*numRows()+2*frameWidth());
491} 491}
492 492
493int 493int
494KDateInternalMonthPicker::getResult() const 494KDateInternalMonthPicker::getResult() const
495{ 495{
496 return result; 496 return result;
497} 497}
498 498
499void 499void
500KDateInternalMonthPicker::setupPainter(QPainter *p) 500KDateInternalMonthPicker::setupPainter(QPainter *p)
501{ 501{
502 p->setPen(black); 502 p->setPen(black);
503} 503}
504 504
505void 505void
506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 506KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
507{ 507{
508 setCellWidth(width()/3); 508 setCellWidth(width()/3);
509 setCellHeight(height()/4); 509 setCellHeight(height()/4);
510} 510}
511 511
512void 512void
513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 513KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
514{ 514{
515 int index; 515 int index;
516 QString text; 516 QString text;
517 // ----- find the number of the cell: 517 // ----- find the number of the cell:
518 index=3*row+col+1; 518 index=3*row+col+1;
519 text=KGlobal::locale()->monthName(index, false); 519 text=KGlobal::locale()->monthName(index, false);
520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 520 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
521 if ( activeCol == col && activeRow == row ) 521 if ( activeCol == col && activeRow == row )
522 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 522 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
523} 523}
524 524
525void 525void
526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 526KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
527{ 527{
528 if(!isEnabled() || e->button() != LeftButton) 528 if(!isEnabled() || e->button() != LeftButton)
529 { 529 {
530 KNotifyClient::beep(); 530 KNotifyClient::beep();
531 return; 531 return;
532 } 532 }
533 // ----- 533 // -----
534 int row, col; 534 int row, col;
535 QPoint mouseCoord; 535 QPoint mouseCoord;
536 // ----- 536 // -----
537 mouseCoord = e->pos(); 537 mouseCoord = e->pos();
538 row=rowAt(mouseCoord.y()); 538 row=rowAt(mouseCoord.y());
539 col=columnAt(mouseCoord.x()); 539 col=columnAt(mouseCoord.x());
540 540
541 if(row<0 || col<0) 541 if(row<0 || col<0)
542 { // the user clicked on the frame of the table 542 { // the user clicked on the frame of the table
543 activeCol = -1; 543 activeCol = -1;
544 activeRow = -1; 544 activeRow = -1;
545 } else { 545 } else {
546 activeCol = col; 546 activeCol = col;
547 activeRow = row; 547 activeRow = row;
548 updateCell( row, col /*, false */ ); 548 updateCell( row, col /*, false */ );
549 } 549 }
550} 550}
551 551
552void 552void
553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 553KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
554{ 554{
555 if (e->state() & LeftButton) 555 if (e->state() & LeftButton)
556 { 556 {
557 int row, col; 557 int row, col;
558 QPoint mouseCoord; 558 QPoint mouseCoord;
559 // ----- 559 // -----
560 mouseCoord = e->pos(); 560 mouseCoord = e->pos();
561 row=rowAt(mouseCoord.y()); 561 row=rowAt(mouseCoord.y());
562 col=columnAt(mouseCoord.x()); 562 col=columnAt(mouseCoord.x());
563 int tmpRow = -1, tmpCol = -1; 563 int tmpRow = -1, tmpCol = -1;
564 if(row<0 || col<0) 564 if(row<0 || col<0)
565 { // the user clicked on the frame of the table 565 { // the user clicked on the frame of the table
566 if ( activeCol > -1 ) 566 if ( activeCol > -1 )
567 { 567 {
568 tmpRow = activeRow; 568 tmpRow = activeRow;
569 tmpCol = activeCol; 569 tmpCol = activeCol;
570 } 570 }
571 activeCol = -1; 571 activeCol = -1;
572 activeRow = -1; 572 activeRow = -1;
573 } else { 573 } else {
574 bool differentCell = (activeRow != row || activeCol != col); 574 bool differentCell = (activeRow != row || activeCol != col);
575 if ( activeCol > -1 && differentCell) 575 if ( activeCol > -1 && differentCell)
576 { 576 {
577 tmpRow = activeRow; 577 tmpRow = activeRow;
578 tmpCol = activeCol; 578 tmpCol = activeCol;
579 } 579 }
580 if ( differentCell) 580 if ( differentCell)
581 { 581 {
582 activeRow = row; 582 activeRow = row;
583 activeCol = col; 583 activeCol = col;
584 updateCell( row, col /*, false */ ); // mark the new active cell 584 updateCell( row, col /*, false */ ); // mark the new active cell
585 } 585 }
586 } 586 }
587 if ( tmpRow > -1 ) // repaint the former active cell 587 if ( tmpRow > -1 ) // repaint the former active cell
588 updateCell( tmpRow, tmpCol /*, true */ ); 588 updateCell( tmpRow, tmpCol /*, true */ );
589 } 589 }
590} 590}
591 591
592void 592void
593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) 593KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e)
594{ 594{
595 if(!isEnabled()) 595 if(!isEnabled())
596 { 596 {
597 return; 597 return;
598 } 598 }
599 // ----- 599 // -----
600 int row, col, pos; 600 int row, col, pos;
601 QPoint mouseCoord; 601 QPoint mouseCoord;
602 // ----- 602 // -----
603 mouseCoord = e->pos(); 603 mouseCoord = e->pos();
604 row=rowAt(mouseCoord.y()); 604 row=rowAt(mouseCoord.y());
605 col=columnAt(mouseCoord.x()); 605 col=columnAt(mouseCoord.x());
606 if(row<0 || col<0) 606 if(row<0 || col<0)
607 { // the user clicked on the frame of the table 607 { // the user clicked on the frame of the table
608 emit(closeMe(0)); 608 emit(closeMe(0));
609 } 609 }
610 pos=3*row+col+1; 610 pos=3*row+col+1;
611 result=pos; 611 result=pos;
612 emit(closeMe(1)); 612 emit(closeMe(1));
613} 613}
614 614
615 615
616 616
617KDateInternalYearSelector::KDateInternalYearSelector 617KDateInternalYearSelector::KDateInternalYearSelector
618(int fontsize, QWidget* parent, const char* name) 618(int fontsize, QWidget* parent, const char* name)
619 : QLineEdit(parent, name), 619 : QLineEdit(parent, name),
620 val(new QIntValidator(this)), 620 val(new QIntValidator(this)),
621 result(0) 621 result(0)
622{ 622{
623 QFont font; 623 QFont font;
624 // ----- 624 // -----
625 font=KGlobalSettings::generalFont(); 625 font=KGlobalSettings::generalFont();
626 font.setPointSize(fontsize); 626 font.setPointSize(fontsize);
627 setFont(font); 627 setFont(font);
628#if 0 628#if 0
629 setFrameStyle(QFrame::NoFrame); 629 setFrameStyle(QFrame::NoFrame);
630#endif 630#endif
631 // we have to respect the limits of QDate here, I fear: 631 // we have to respect the limits of QDate here, I fear:
632 val->setRange(0, 8000); 632 val->setRange(0, 8000);
633 setValidator(val); 633 setValidator(val);
634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); 634 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()));
635} 635}
636 636
637void 637void
638KDateInternalYearSelector::yearEnteredSlot() 638KDateInternalYearSelector::yearEnteredSlot()
639{ 639{
640 bool ok; 640 bool ok;
641 int year; 641 int year;
642 QDate date; 642 QDate date;
643 // ----- check if this is a valid year: 643 // ----- check if this is a valid year:
644 year=text().toInt(&ok); 644 year=text().toInt(&ok);
645 if(!ok) 645 if(!ok)
646 { 646 {
647 KNotifyClient::beep(); 647 KNotifyClient::beep();
648 return; 648 return;
649 } 649 }
650 date.setYMD(year, 1, 1); 650 date.setYMD(year, 1, 1);
651 if(!date.isValid()) 651 if(!date.isValid())
652 { 652 {
653 KNotifyClient::beep(); 653 KNotifyClient::beep();
654 return; 654 return;
655 } 655 }
656 result=year; 656 result=year;
657 emit(closeMe(1)); 657 emit(closeMe(1));
658} 658}
659 659
660int 660int
661KDateInternalYearSelector::getYear() 661KDateInternalYearSelector::getYear()
662{ 662{
663 return result; 663 return result;
664} 664}
665 665
666void 666void
667KDateInternalYearSelector::setYear(int year) 667KDateInternalYearSelector::setYear(int year)
668{ 668{
669 QString temp; 669 QString temp;
670 // ----- 670 // -----
671 temp.setNum(year); 671 temp.setNum(year);
672 setText(temp); 672 setText(temp);
673} 673}
674 674
675KPopupFrame::KPopupFrame(QWidget* parent, const char* name) 675KPopupFrame::KPopupFrame(QWidget* parent, const char* name)
676 : QFrame(parent, name, WType_Popup), 676 : QFrame(parent, name, WType_Popup),
677 result(0), // rejected 677 result(0), // rejected
678 main(0) 678 main(0)
679{ 679{
680 setFrameStyle(QFrame::Box|QFrame::Raised); 680 setFrameStyle(QFrame::Box|QFrame::Raised);
681 setMidLineWidth(2); 681 setMidLineWidth(2);
682} 682}
683 683
684void 684void
685KPopupFrame::keyPressEvent(QKeyEvent* e) 685KPopupFrame::keyPressEvent(QKeyEvent* e)
686{ 686{
687 if(e->key()==Key_Escape) 687 if(e->key()==Key_Escape)
688 { 688 {
689 result=0; // rejected 689 result=0; // rejected
690 qApp->exit_loop(); 690 qApp->exit_loop();
691 } 691 }
692} 692}
693 693
694void 694void
695KPopupFrame::close(int r) 695KPopupFrame::close(int r)
696{ 696{
697 result=r; 697 result=r;
698 qApp->exit_loop(); 698 qApp->exit_loop();
699} 699}
700 700
701void 701void
702KPopupFrame::setMainWidget(QWidget* m) 702KPopupFrame::setMainWidget(QWidget* m)
703{ 703{
704 main=m; 704 main=m;
705 if(main!=0) 705 if(main!=0)
706 { 706 {
707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 707 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
708 } 708 }
709} 709}
710 710
711void 711void
712KPopupFrame::resizeEvent(QResizeEvent*) 712KPopupFrame::resizeEvent(QResizeEvent*)
713{ 713{
714 if(main!=0) 714 if(main!=0)
715 { 715 {
716 main->setGeometry(frameWidth(), frameWidth(), 716 main->setGeometry(frameWidth(), frameWidth(),
717 width()-2*frameWidth(), height()-2*frameWidth()); 717 width()-2*frameWidth(), height()-2*frameWidth());
718 } 718 }
719} 719}
720 720
721void 721void
722KPopupFrame::popup(const QPoint &pos) 722KPopupFrame::popup(const QPoint &pos)
723{ 723{
724 // Make sure the whole popup is visible. 724 // Make sure the whole popup is visible.
725 QRect d = QApplication::desktop()->frameGeometry(); 725 QRect d = QApplication::desktop()->frameGeometry();
726 int x = pos.x(); 726 int x = pos.x();
727 int y = pos.y(); 727 int y = pos.y();
728 int w = width(); 728 int w = width();
729 int h = height(); 729 int h = height();
730 if (x+w > d.x()+d.width()) 730 if (x+w > d.x()+d.width())
731 x = d.width() - w; 731 x = d.width() - w;
732 if (y+h > d.y()+d.height()) 732 if (y+h > d.y()+d.height())
733 y = d.height() - h; 733 y = d.height() - h;
734 if (x < d.x()) 734 if (x < d.x())
735 x = 0; 735 x = 0;
736 if (y < d.y()) 736 if (y < d.y())
737 y = 0; 737 y = 0;
738 738
739 // Pop the thingy up. 739 // Pop the thingy up.
740 move(x, y); 740 move(x, y);
741 show(); 741 show();
742} 742}
743 743
744int 744int
745KPopupFrame::exec(QPoint pos) 745KPopupFrame::exec(QPoint pos)
746{ 746{
747 popup(pos); 747 popup(pos);
748 repaint(); 748 repaint();
749 qApp->enter_loop(); 749 qApp->enter_loop();
750 hide(); 750 hide();
751 return result; 751 return result;
752} 752}
753 753
754int 754int
755KPopupFrame::exec(int x, int y) 755KPopupFrame::exec(int x, int y)
756{ 756{
757 return exec(QPoint(x, y)); 757 return exec(QPoint(x, y));
758} 758}
759 759
760void KPopupFrame::virtual_hook( int, void* ) 760void KPopupFrame::virtual_hook( int, void* )
761{ /*BASE::virtual_hook( id, data );*/ } 761{ /*BASE::virtual_hook( id, data );*/ }
762 762
763void KDateTable::virtual_hook( int, void* ) 763void KDateTable::virtual_hook( int, void* )
764{ /*BASE::virtual_hook( id, data );*/ } 764{ /*BASE::virtual_hook( id, data );*/ }
765 765
766//#include "kdatetbl.moc" 766//#include "kdatetbl.moc"
767 767
768 768
769KDateInternalWeekPicker::KDateInternalWeekPicker 769KDateInternalWeekPicker::KDateInternalWeekPicker
770(QWidget* parent, const char* name) 770(QWidget* parent, const char* name)
771 : QGridView(parent, name), 771 : QGridView(parent, name),
772 result(0) // invalid 772 result(0) // invalid
773{ 773{
774 QRect rect; 774 QRect rect;
775 QFont font; 775 QFont font;
776 // ----- 776 // -----
777 activeCol = -1; 777 activeCol = -1;
778 activeRow = -1; 778 activeRow = -1;
779 font=KGlobalSettings::generalFont(); 779 font=KGlobalSettings::generalFont();
780 int fontsize = 10; 780 int fontsize = 10;
781 int add = 2; 781 int add = 2;
782 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 782 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
783 add += 6; 783 add += 6;
784 font.setPointSize(fontsize+add); 784 font.setPointSize(fontsize+add);
785 setFont(font); 785 setFont(font);
786 setHScrollBarMode(AlwaysOff); 786 setHScrollBarMode(AlwaysOff);
787 setVScrollBarMode(AlwaysOff); 787 setVScrollBarMode(AlwaysOff);
788 setFrameStyle(QFrame::NoFrame); 788 setFrameStyle(QFrame::NoFrame);
789 setNumRows(13); 789 if ( QApplication::desktop()->height() > 240 ) {
790 setNumCols(4); 790 setNumRows(13);
791 setNumCols(4);
792 } else {
793 setNumRows(4);
794 setNumCols(13);
795 }
791 // enable to find drawing failures: 796 // enable to find drawing failures:
792 // setTableFlags(Tbl_clipCellPainting); 797 // setTableFlags(Tbl_clipCellPainting);
793#if 0 798#if 0
794 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 799 viewport()->setEraseColor(lightGray); // for consistency with the datepicker
795#endif 800#endif
796 // ----- find the preferred size 801 // ----- find the preferred size
797 // (this is slow, possibly, but unfortunatly it is needed here): 802 // (this is slow, possibly, but unfortunatly it is needed here):
798 QFontMetrics metrics(font); 803 QFontMetrics metrics(font);
799 for(int i=1; i <= 52; ++i) 804 for(int i=1; i <= 52; ++i)
800 { 805 {
801 rect=metrics.boundingRect(QString::number( i )); 806 rect=metrics.boundingRect(QString::number( i ));
802 if(max.width()<rect.width()) max.setWidth(rect.width()); 807 if(max.width()<rect.width()) max.setWidth(rect.width());
803 if(max.height()<rect.height()) max.setHeight(rect.height()); 808 if(max.height()<rect.height()) max.setHeight(rect.height());
804 } 809 }
805 if ( QApplication::desktop()->width() > 640 ) { 810 if ( QApplication::desktop()->width() > 640 ) {
806 811
807 max.setWidth(max.width()+6); 812 max.setWidth(max.width()+6);
808 max.setHeight(max.height()+8); 813 max.setHeight(max.height()+8);
809 } 814 }
810} 815}
811 816
812QSize 817QSize
813KDateInternalWeekPicker::sizeHint() const 818KDateInternalWeekPicker::sizeHint() const
814{ 819{
815 return QSize((max.width()+6)*numCols()+2*frameWidth(), 820 return QSize((max.width()+6)*numCols()+2*frameWidth(),
816 (max.height()+6)*numRows()+2*frameWidth()); 821 (max.height()+6)*numRows()+2*frameWidth());
817} 822}
818 823
819int 824int
820KDateInternalWeekPicker::getResult() const 825KDateInternalWeekPicker::getResult() const
821{ 826{
822 return result; 827 return result;
823} 828}
824 829
825void 830void
826KDateInternalWeekPicker::setupPainter(QPainter *p) 831KDateInternalWeekPicker::setupPainter(QPainter *p)
827{ 832{
828 p->setPen(black); 833 p->setPen(black);
829} 834}
830 835
831void 836void
832KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) 837KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
833{ 838{
834 setCellWidth(width()/4); 839 setCellWidth(width()/ numCols());
835 setCellHeight(height()/13); 840 setCellHeight(height()/ numRows());
836} 841}
837 842
838void 843void
839KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) 844KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
840{ 845{
841 int index; 846 int index;
842 QString text; 847 QString text;
843 // ----- find the number of the cell: 848 // ----- find the number of the cell:
844 index=4*row+col+1; 849 index=numCols()*row+col+1;
845 text=QString::number( index ); 850 text=QString::number( index );
846 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 851 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text);
847 if ( activeCol == col && activeRow == row ) 852 if ( activeCol == col && activeRow == row )
848 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 853 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
849} 854}
850 855
851void 856void
852KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) 857KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
853{ 858{
854 if(!isEnabled() || e->button() != LeftButton) 859 if(!isEnabled() || e->button() != LeftButton)
855 { 860 {
856 KNotifyClient::beep(); 861 KNotifyClient::beep();
857 return; 862 return;
858 } 863 }
859 // ----- 864 // -----
860 int row, col; 865 int row, col;
861 QPoint mouseCoord; 866 QPoint mouseCoord;
862 // ----- 867 // -----
863 mouseCoord = e->pos(); 868 mouseCoord = e->pos();
864 row=rowAt(mouseCoord.y()); 869 row=rowAt(mouseCoord.y());
865 col=columnAt(mouseCoord.x()); 870 col=columnAt(mouseCoord.x());
866 871
867 if(row<0 || col<0) 872 if(row<0 || col<0)
868 { // the user clicked on the frame of the table 873 { // the user clicked on the frame of the table
869 activeCol = -1; 874 activeCol = -1;
870 activeRow = -1; 875 activeRow = -1;
871 } else { 876 } else {
872 activeCol = col; 877 activeCol = col;
873 activeRow = row; 878 activeRow = row;
874 updateCell( row, col /*, false */ ); 879 updateCell( row, col /*, false */ );
875 } 880 }
876} 881}
877 882
878void 883void
879KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) 884KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
880{ 885{
881 if (e->state() & LeftButton) 886 if (e->state() & LeftButton)
882 { 887 {
883 int row, col; 888 int row, col;
884 QPoint mouseCoord; 889 QPoint mouseCoord;
885 // ----- 890 // -----
886 mouseCoord = e->pos(); 891 mouseCoord = e->pos();
887 row=rowAt(mouseCoord.y()); 892 row=rowAt(mouseCoord.y());
888 col=columnAt(mouseCoord.x()); 893 col=columnAt(mouseCoord.x());
889 int tmpRow = -1, tmpCol = -1; 894 int tmpRow = -1, tmpCol = -1;
890 if(row<0 || col<0) 895 if(row<0 || col<0)
891 { // the user clicked on the frame of the table 896 { // the user clicked on the frame of the table
892 if ( activeCol > -1 ) 897 if ( activeCol > -1 )
893 { 898 {
894 tmpRow = activeRow; 899 tmpRow = activeRow;
895 tmpCol = activeCol; 900 tmpCol = activeCol;
896 } 901 }
897 activeCol = -1; 902 activeCol = -1;
898 activeRow = -1; 903 activeRow = -1;
899 } else { 904 } else {
900 bool differentCell = (activeRow != row || activeCol != col); 905 bool differentCell = (activeRow != row || activeCol != col);
901 if ( activeCol > -1 && differentCell) 906 if ( activeCol > -1 && differentCell)
902 { 907 {
903 tmpRow = activeRow; 908 tmpRow = activeRow;
904 tmpCol = activeCol; 909 tmpCol = activeCol;
905 } 910 }
906 if ( differentCell) 911 if ( differentCell)
907 { 912 {
908 activeRow = row; 913 activeRow = row;
909 activeCol = col; 914 activeCol = col;
910 updateCell( row, col /*, false */ ); // mark the new active cell 915 updateCell( row, col /*, false */ ); // mark the new active cell
911 } 916 }
912 } 917 }
913 if ( tmpRow > -1 ) // repaint the former active cell 918 if ( tmpRow > -1 ) // repaint the former active cell
914 updateCell( tmpRow, tmpCol /*, true */ ); 919 updateCell( tmpRow, tmpCol /*, true */ );
915 } 920 }
916} 921}
917 922
918void 923void
919KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) 924KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
920{ 925{
921 if(!isEnabled()) 926 if(!isEnabled())
922 { 927 {
923 return; 928 return;
924 } 929 }
925 // ----- 930 // -----
926 int row, col, pos; 931 int row, col, pos;
927 QPoint mouseCoord; 932 QPoint mouseCoord;
928 // ----- 933 // -----
929 mouseCoord = e->pos(); 934 mouseCoord = e->pos();
930 row=rowAt(mouseCoord.y()); 935 row=rowAt(mouseCoord.y());
931 col=columnAt(mouseCoord.x()); 936 col=columnAt(mouseCoord.x());
932 if(row<0 || col<0) 937 if(row<0 || col<0)
933 { // the user clicked on the frame of the table 938 { // the user clicked on the frame of the table
934 emit(closeMe(0)); 939 emit(closeMe(0));
935 } 940 }
936 pos=4*row+col+1; 941 pos=numCols()*row+col+1;
937 result=pos; 942 result=pos;
938 emit(closeMe(1)); 943 emit(closeMe(1));
939} 944}