-rw-r--r-- | korganizer/journalentry.cpp | 1 | ||||
-rw-r--r-- | korganizer/koeditorgeneraltodo.cpp | 1 | ||||
-rw-r--r-- | korganizer/komonthview.cpp | 1 |
3 files changed, 3 insertions, 0 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index dca42e0..c19a5ca 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,249 +1,250 @@ | |||
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 | // | 24 | // |
25 | // Journal Entry | 25 | // Journal Entry |
26 | 26 | ||
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qlayout.h> | 28 | #include <qlayout.h> |
29 | #include <qvbox.h> | 29 | #include <qvbox.h> |
30 | #include <qfile.h> | 30 | #include <qfile.h> |
31 | #include <qdir.h> | 31 | #include <qdir.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qtextcodec.h> | 33 | #include <qtextcodec.h> |
34 | #include <qpixmap.h> | 34 | #include <qpixmap.h> |
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qapplication.h> | ||
36 | 37 | ||
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <kglobal.h> | 39 | #include <kglobal.h> |
39 | #include <klocale.h> | 40 | #include <klocale.h> |
40 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
41 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
42 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
43 | #include "koprefs.h" | 44 | #include "koprefs.h" |
44 | 45 | ||
45 | #include <libkcal/journal.h> | 46 | #include <libkcal/journal.h> |
46 | #include <libkcal/calendarresources.h> | 47 | #include <libkcal/calendarresources.h> |
47 | #include <libkcal/resourcecalendar.h> | 48 | #include <libkcal/resourcecalendar.h> |
48 | #include <kresources/resourceselectdialog.h> | 49 | #include <kresources/resourceselectdialog.h> |
49 | 50 | ||
50 | #include "journalentry.h" | 51 | #include "journalentry.h" |
51 | //#include "journalentry.moc" | 52 | //#include "journalentry.moc" |
52 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
53 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
54 | #endif | 55 | #endif |
55 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 56 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
56 | QFrame(parent) | 57 | QFrame(parent) |
57 | { | 58 | { |
58 | mCalendar = calendar; | 59 | mCalendar = calendar; |
59 | mJournal = 0; | 60 | mJournal = 0; |
60 | mDirty = false; | 61 | mDirty = false; |
61 | 62 | ||
62 | QHBox * vb = new QHBox ( this ); | 63 | QHBox * vb = new QHBox ( this ); |
63 | QPushButton * loadTemplate = new QPushButton( vb ); | 64 | QPushButton * loadTemplate = new QPushButton( vb ); |
64 | QPushButton * saveTemplate = new QPushButton( vb ); | 65 | QPushButton * saveTemplate = new QPushButton( vb ); |
65 | QIconSet icon; | 66 | QIconSet icon; |
66 | if ( QApplication::desktop()->width() < 321 ) | 67 | if ( QApplication::desktop()->width() < 321 ) |
67 | icon = SmallIcon("fileexport16"); | 68 | icon = SmallIcon("fileexport16"); |
68 | else | 69 | else |
69 | icon = SmallIcon("fileexport"); | 70 | icon = SmallIcon("fileexport"); |
70 | saveTemplate->setIconSet (icon ) ; | 71 | saveTemplate->setIconSet (icon ) ; |
71 | int size = saveTemplate->sizeHint().height(); | 72 | int size = saveTemplate->sizeHint().height(); |
72 | saveTemplate->setFixedSize( size, size ); | 73 | saveTemplate->setFixedSize( size, size ); |
73 | if ( QApplication::desktop()->width() < 321 ) | 74 | if ( QApplication::desktop()->width() < 321 ) |
74 | icon = SmallIcon("fileimport16"); | 75 | icon = SmallIcon("fileimport16"); |
75 | else | 76 | else |
76 | icon = SmallIcon("fileimport"); | 77 | icon = SmallIcon("fileimport"); |
77 | loadTemplate->setIconSet (icon ) ; | 78 | loadTemplate->setIconSet (icon ) ; |
78 | loadTemplate->setFixedSize( size, size ); | 79 | loadTemplate->setFixedSize( size, size ); |
79 | 80 | ||
80 | mTitleLabel = new QLabel(i18n("Title"),vb); | 81 | mTitleLabel = new QLabel(i18n("Title"),vb); |
81 | mTitleLabel->setMargin(2); | 82 | mTitleLabel->setMargin(2); |
82 | mTitleLabel->setAlignment(AlignCenter); | 83 | mTitleLabel->setAlignment(AlignCenter); |
83 | 84 | ||
84 | mEditor = new KTextEdit(this); | 85 | mEditor = new KTextEdit(this); |
85 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); | 86 | connect(mEditor,SIGNAL(textChanged()),SLOT(setDirty())); |
86 | #ifndef DESKTOP_VERSION | 87 | #ifndef DESKTOP_VERSION |
87 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 88 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
88 | #endif | 89 | #endif |
89 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 90 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
90 | QBoxLayout *topLayout = new QVBoxLayout(this); | 91 | QBoxLayout *topLayout = new QVBoxLayout(this); |
91 | topLayout->addWidget(vb); | 92 | topLayout->addWidget(vb); |
92 | topLayout->addWidget(mEditor); | 93 | topLayout->addWidget(mEditor); |
93 | mEditor->installEventFilter(this); | 94 | mEditor->installEventFilter(this); |
94 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 95 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
95 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 96 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
96 | } | 97 | } |
97 | 98 | ||
98 | JournalEntry::~JournalEntry() | 99 | JournalEntry::~JournalEntry() |
99 | { | 100 | { |
100 | } | 101 | } |
101 | 102 | ||
102 | void JournalEntry::slotSaveTemplate() | 103 | void JournalEntry::slotSaveTemplate() |
103 | { | 104 | { |
104 | QString fileName =locateLocal( "templates", "journals" ); | 105 | QString fileName =locateLocal( "templates", "journals" ); |
105 | QDir t_dir; | 106 | QDir t_dir; |
106 | if ( !t_dir.exists(fileName) ) | 107 | if ( !t_dir.exists(fileName) ) |
107 | t_dir.mkdir ( fileName ); | 108 | t_dir.mkdir ( fileName ); |
108 | fileName += "/journal"; | 109 | fileName += "/journal"; |
109 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 110 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
110 | if ( fileName.length() == 0 ) | 111 | if ( fileName.length() == 0 ) |
111 | return; | 112 | return; |
112 | 113 | ||
113 | QFile fileIn( fileName ); | 114 | QFile fileIn( fileName ); |
114 | if (!fileIn.open( IO_WriteOnly ) ) { | 115 | if (!fileIn.open( IO_WriteOnly ) ) { |
115 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 116 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
116 | .arg( fileName ) ); | 117 | .arg( fileName ) ); |
117 | return; | 118 | return; |
118 | } | 119 | } |
119 | // QString text; | 120 | // QString text; |
120 | QTextStream tsIn( &fileIn ); | 121 | QTextStream tsIn( &fileIn ); |
121 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 122 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
122 | tsIn << mEditor->text(); | 123 | tsIn << mEditor->text(); |
123 | fileIn.close(); | 124 | fileIn.close(); |
124 | } | 125 | } |
125 | void JournalEntry::slotLoadTemplate() | 126 | void JournalEntry::slotLoadTemplate() |
126 | { | 127 | { |
127 | QString fileName =locateLocal( "templates", "journals" ); | 128 | QString fileName =locateLocal( "templates", "journals" ); |
128 | QDir t_dir; | 129 | QDir t_dir; |
129 | if ( !t_dir.exists(fileName) ) | 130 | if ( !t_dir.exists(fileName) ) |
130 | t_dir.mkdir ( fileName ); | 131 | t_dir.mkdir ( fileName ); |
131 | fileName += "/journal"; | 132 | fileName += "/journal"; |
132 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 133 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
133 | if ( fileName.length() == 0 ) | 134 | if ( fileName.length() == 0 ) |
134 | return; | 135 | return; |
135 | QFile fileIn( fileName ); | 136 | QFile fileIn( fileName ); |
136 | if (!fileIn.open( IO_ReadOnly ) ) { | 137 | if (!fileIn.open( IO_ReadOnly ) ) { |
137 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 138 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
138 | .arg( fileName ) ); | 139 | .arg( fileName ) ); |
139 | return; | 140 | return; |
140 | } | 141 | } |
141 | QTextStream tsIn( &fileIn ); | 142 | QTextStream tsIn( &fileIn ); |
142 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 143 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
143 | QString text = tsIn.read(); | 144 | QString text = tsIn.read(); |
144 | fileIn.close(); | 145 | fileIn.close(); |
145 | int line, col; | 146 | int line, col; |
146 | mEditor->getCursorPosition (& line, & col ); | 147 | mEditor->getCursorPosition (& line, & col ); |
147 | mEditor-> insertAt ( text, line, col, true ); | 148 | mEditor-> insertAt ( text, line, col, true ); |
148 | //mEditor->setIgnoreMark( true ); | 149 | //mEditor->setIgnoreMark( true ); |
149 | setDirty(); | 150 | setDirty(); |
150 | } | 151 | } |
151 | void JournalEntry::setDate(const QDate &date) | 152 | void JournalEntry::setDate(const QDate &date) |
152 | { | 153 | { |
153 | writeJournal(); | 154 | writeJournal(); |
154 | 155 | ||
155 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); | 156 | mTitleLabel->setText(KGlobal::locale()->formatDate(date)); |
156 | 157 | ||
157 | 158 | ||
158 | mDate = date; | 159 | mDate = date; |
159 | } | 160 | } |
160 | 161 | ||
161 | void JournalEntry::setJournal(Journal *journal) | 162 | void JournalEntry::setJournal(Journal *journal) |
162 | { | 163 | { |
163 | writeJournal(); | 164 | writeJournal(); |
164 | 165 | ||
165 | mJournal = journal; | 166 | mJournal = journal; |
166 | 167 | ||
167 | mEditor->setText(mJournal->description()); | 168 | mEditor->setText(mJournal->description()); |
168 | 169 | ||
169 | mDirty = false; | 170 | mDirty = false; |
170 | } | 171 | } |
171 | 172 | ||
172 | Journal *JournalEntry::journal() const | 173 | Journal *JournalEntry::journal() const |
173 | { | 174 | { |
174 | return mJournal; | 175 | return mJournal; |
175 | } | 176 | } |
176 | 177 | ||
177 | void JournalEntry::setDirty() | 178 | void JournalEntry::setDirty() |
178 | { | 179 | { |
179 | mDirty = true; | 180 | mDirty = true; |
180 | 181 | ||
181 | // kdDebug() << "JournalEntry::setDirty()" << endl; | 182 | // kdDebug() << "JournalEntry::setDirty()" << endl; |
182 | } | 183 | } |
183 | 184 | ||
184 | void JournalEntry::clear() | 185 | void JournalEntry::clear() |
185 | { | 186 | { |
186 | mJournal = 0; | 187 | mJournal = 0; |
187 | mEditor->setText(""); | 188 | mEditor->setText(""); |
188 | } | 189 | } |
189 | 190 | ||
190 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 191 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
191 | { | 192 | { |
192 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 193 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
193 | 194 | ||
194 | if ( e->type() == QEvent::FocusOut ) { | 195 | if ( e->type() == QEvent::FocusOut ) { |
195 | writeJournal(); | 196 | writeJournal(); |
196 | } | 197 | } |
197 | if ( e->type() == QEvent::KeyPress ) { | 198 | if ( e->type() == QEvent::KeyPress ) { |
198 | QKeyEvent * k = (QKeyEvent *) e; | 199 | QKeyEvent * k = (QKeyEvent *) e; |
199 | if ( k->state() == Qt::ControlButton ) { | 200 | if ( k->state() == Qt::ControlButton ) { |
200 | k->ignore(); | 201 | k->ignore(); |
201 | //return true; | 202 | //return true; |
202 | } | 203 | } |
203 | } | 204 | } |
204 | 205 | ||
205 | return QFrame::eventFilter( o, e ); // standard event processing | 206 | return QFrame::eventFilter( o, e ); // standard event processing |
206 | } | 207 | } |
207 | 208 | ||
208 | void JournalEntry::writeJournal() | 209 | void JournalEntry::writeJournal() |
209 | { | 210 | { |
210 | // kdDebug() << "JournalEntry::writeJournal()" << endl; | 211 | // kdDebug() << "JournalEntry::writeJournal()" << endl; |
211 | if (!mDirty) return; | 212 | if (!mDirty) return; |
212 | 213 | ||
213 | if (mEditor->text().isEmpty()) { | 214 | if (mEditor->text().isEmpty()) { |
214 | if ( mJournal ) { | 215 | if ( mJournal ) { |
215 | mDirty = false; | 216 | mDirty = false; |
216 | bool conf = KOPrefs::instance()->mConfirm; | 217 | bool conf = KOPrefs::instance()->mConfirm; |
217 | KOPrefs::instance()->mConfirm = false; | 218 | KOPrefs::instance()->mConfirm = false; |
218 | emit deleteJournal(mJournal); | 219 | emit deleteJournal(mJournal); |
219 | KOPrefs::instance()->mConfirm = conf; | 220 | KOPrefs::instance()->mConfirm = conf; |
220 | mJournal = 0; | 221 | mJournal = 0; |
221 | } | 222 | } |
222 | return; | 223 | return; |
223 | } | 224 | } |
224 | 225 | ||
225 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 226 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
226 | 227 | ||
227 | if (!mJournal) { | 228 | if (!mJournal) { |
228 | mJournal = new Journal; | 229 | mJournal = new Journal; |
229 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 230 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
230 | mCalendar->addJournal(mJournal); | 231 | mCalendar->addJournal(mJournal); |
231 | } | 232 | } |
232 | 233 | ||
233 | mJournal->setDescription(mEditor->text()); | 234 | mJournal->setDescription(mEditor->text()); |
234 | //qDebug("tttt%s ", mEditor->text().latin1()); | 235 | //qDebug("tttt%s ", mEditor->text().latin1()); |
235 | 236 | ||
236 | mDirty = false; | 237 | mDirty = false; |
237 | } | 238 | } |
238 | 239 | ||
239 | void JournalEntry::flushEntry() | 240 | void JournalEntry::flushEntry() |
240 | { | 241 | { |
241 | if (!mDirty) return; | 242 | if (!mDirty) return; |
242 | 243 | ||
243 | writeJournal(); | 244 | writeJournal(); |
244 | } | 245 | } |
245 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 246 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
246 | { | 247 | { |
247 | e->ignore(); | 248 | e->ignore(); |
248 | 249 | ||
249 | } | 250 | } |
diff --git a/korganizer/koeditorgeneraltodo.cpp b/korganizer/koeditorgeneraltodo.cpp index ce0d7a9..cd78f54 100644 --- a/korganizer/koeditorgeneraltodo.cpp +++ b/korganizer/koeditorgeneraltodo.cpp | |||
@@ -1,491 +1,492 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 <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 <qapplication.h> | ||
32 | 33 | ||
33 | #include <kglobal.h> | 34 | #include <kglobal.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | #include <kiconloader.h> | 36 | #include <kiconloader.h> |
36 | #include <kmessagebox.h> | 37 | #include <kmessagebox.h> |
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <krestrictedline.h> | 39 | #include <krestrictedline.h> |
39 | #include <kstandarddirs.h> | 40 | #include <kstandarddirs.h> |
40 | #include <kfiledialog.h> | 41 | #include <kfiledialog.h> |
41 | 42 | ||
42 | #include <libkcal/todo.h> | 43 | #include <libkcal/todo.h> |
43 | 44 | ||
44 | #include <libkdepim/kdateedit.h> | 45 | #include <libkdepim/kdateedit.h> |
45 | 46 | ||
46 | #include "koprefs.h" | 47 | #include "koprefs.h" |
47 | #include "ktimeedit.h" | 48 | #include "ktimeedit.h" |
48 | 49 | ||
49 | #include "koeditorgeneraltodo.h" | 50 | #include "koeditorgeneraltodo.h" |
50 | #include "kolocationbox.h" | 51 | #include "kolocationbox.h" |
51 | 52 | ||
52 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, | 53 | KOEditorGeneralTodo::KOEditorGeneralTodo(QObject* parent, |
53 | const char* name) | 54 | const char* name) |
54 | : KOEditorGeneral( parent, name) | 55 | : KOEditorGeneral( parent, name) |
55 | { | 56 | { |
56 | } | 57 | } |
57 | 58 | ||
58 | KOEditorGeneralTodo::~KOEditorGeneralTodo() | 59 | KOEditorGeneralTodo::~KOEditorGeneralTodo() |
59 | { | 60 | { |
60 | } | 61 | } |
61 | 62 | ||
62 | void KOEditorGeneralTodo::finishSetup() | 63 | void KOEditorGeneralTodo::finishSetup() |
63 | { | 64 | { |
64 | 65 | ||
65 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); | 66 | // QWidget::setTabOrder(mSummaryEdit, mLocationEdit); |
66 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); | 67 | // QWidget::setTabOrder(mLocationEdit, mDueCheck); |
67 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); | 68 | // QWidget::setTabOrder(mDueCheck, mDueDateEdit); |
68 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); | 69 | // QWidget::setTabOrder(mDueDateEdit, mDueTimeEdit); |
69 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); | 70 | // QWidget::setTabOrder(mDueTimeEdit, mStartCheck); |
70 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); | 71 | // QWidget::setTabOrder(mStartCheck, mStartDateEdit); |
71 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); | 72 | // QWidget::setTabOrder(mStartDateEdit, mStartTimeEdit); |
72 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); | 73 | // QWidget::setTabOrder(mStartTimeEdit, mTimeButton); |
73 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); | 74 | // QWidget::setTabOrder(mTimeButton, mCompletedCombo); |
74 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); | 75 | // QWidget::setTabOrder(mCompletedCombo, mPriorityCombo); |
75 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); | 76 | // QWidget::setTabOrder(mPriorityCombo, mAlarmButton); |
76 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); | 77 | // QWidget::setTabOrder(mAlarmButton, mCategoriesButton); |
77 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); | 78 | // QWidget::setTabOrder(mCategoriesButton, mSecrecyCombo); |
78 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); | 79 | // QWidget::setTabOrder(mSecrecyCombo, mDescriptionEdit); |
79 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 80 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
80 | mSummaryEdit->setFocus(); | 81 | mSummaryEdit->setFocus(); |
81 | } | 82 | } |
82 | 83 | ||
83 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) | 84 | void KOEditorGeneralTodo::initTime(QWidget *parent,QBoxLayout *topLayout) |
84 | { | 85 | { |
85 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); | 86 | QBoxLayout *timeLayout = new QVBoxLayout(topLayout); |
86 | 87 | ||
87 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, | 88 | QGroupBox *timeGroupBox = new QGroupBox(1,QGroupBox::Horizontal, |
88 | i18n("Date && Time"),parent); | 89 | i18n("Date && Time"),parent); |
89 | timeLayout->addWidget(timeGroupBox); | 90 | timeLayout->addWidget(timeGroupBox); |
90 | timeGroupBox->layout()->setSpacing( 0 ); | 91 | timeGroupBox->layout()->setSpacing( 0 ); |
91 | timeGroupBox->layout()->setMargin( 5 ); | 92 | timeGroupBox->layout()->setMargin( 5 ); |
92 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); | 93 | QFrame *timeBoxFrame = new QFrame(timeGroupBox); |
93 | 94 | ||
94 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); | 95 | QGridLayout *layoutTimeBox = new QGridLayout(timeBoxFrame,3,3); |
95 | layoutTimeBox->setSpacing(topLayout->spacing()); | 96 | layoutTimeBox->setSpacing(topLayout->spacing()); |
96 | layoutTimeBox->setColStretch( 1, 1 ); | 97 | layoutTimeBox->setColStretch( 1, 1 ); |
97 | 98 | ||
98 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); | 99 | mDueCheck = new QCheckBox(i18n("Due:"),timeBoxFrame); |
99 | layoutTimeBox->addWidget(mDueCheck,0,0); | 100 | layoutTimeBox->addWidget(mDueCheck,0,0); |
100 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); | 101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(enableDueEdit(bool))); |
101 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); | 102 | connect(mDueCheck,SIGNAL(toggled(bool)),SLOT(showAlarm())); |
102 | 103 | ||
103 | 104 | ||
104 | mDueDateEdit = new KDateEdit(timeBoxFrame); | 105 | mDueDateEdit = new KDateEdit(timeBoxFrame); |
105 | layoutTimeBox->addWidget(mDueDateEdit,0,1); | 106 | layoutTimeBox->addWidget(mDueDateEdit,0,1); |
106 | 107 | ||
107 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); | 108 | mDueTimeEdit = new KOTimeEdit(timeBoxFrame); |
108 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); | 109 | layoutTimeBox->addWidget(mDueTimeEdit,0,2); |
109 | 110 | ||
110 | 111 | ||
111 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); | 112 | mStartCheck = new QCheckBox(i18n("Start:"),timeBoxFrame); |
112 | layoutTimeBox->addWidget(mStartCheck,1,0); | 113 | layoutTimeBox->addWidget(mStartCheck,1,0); |
113 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); | 114 | connect(mStartCheck,SIGNAL(toggled(bool)),SLOT(enableStartEdit(bool))); |
114 | 115 | ||
115 | mStartDateEdit = new KDateEdit(timeBoxFrame); | 116 | mStartDateEdit = new KDateEdit(timeBoxFrame); |
116 | layoutTimeBox->addWidget(mStartDateEdit,1,1); | 117 | layoutTimeBox->addWidget(mStartDateEdit,1,1); |
117 | 118 | ||
118 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); | 119 | mStartTimeEdit = new KOTimeEdit(timeBoxFrame); |
119 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); | 120 | layoutTimeBox->addWidget(mStartTimeEdit,1,2); |
120 | 121 | ||
121 | 122 | ||
122 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); | 123 | mTimeButton = new QCheckBox(i18n("Time associated"),timeBoxFrame); |
123 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); | 124 | layoutTimeBox->addMultiCellWidget(mTimeButton,2,2,0,1); |
124 | 125 | ||
125 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); | 126 | connect(mTimeButton,SIGNAL(toggled(bool)),SLOT(enableTimeEdits(bool))); |
126 | 127 | ||
127 | // some more layouting | 128 | // some more layouting |
128 | //layoutTimeBox->setColStretch(3,1); | 129 | //layoutTimeBox->setColStretch(3,1); |
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
132 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) | 133 | void KOEditorGeneralTodo::initCompletion(QWidget *parent, QBoxLayout *topLayout) |
133 | { | 134 | { |
134 | mCompletedCombo = new QComboBox(parent); | 135 | mCompletedCombo = new QComboBox(parent); |
135 | // xgettext:no-c-format | 136 | // xgettext:no-c-format |
136 | mCompletedCombo->insertItem(i18n(" 0 %")); | 137 | mCompletedCombo->insertItem(i18n(" 0 %")); |
137 | // xgettext:no-c-format | 138 | // xgettext:no-c-format |
138 | mCompletedCombo->insertItem(i18n(" 20 %")); | 139 | mCompletedCombo->insertItem(i18n(" 20 %")); |
139 | // xgettext:no-c-format | 140 | // xgettext:no-c-format |
140 | mCompletedCombo->insertItem(i18n(" 40 %")); | 141 | mCompletedCombo->insertItem(i18n(" 40 %")); |
141 | // xgettext:no-c-format | 142 | // xgettext:no-c-format |
142 | mCompletedCombo->insertItem(i18n(" 60 %")); | 143 | mCompletedCombo->insertItem(i18n(" 60 %")); |
143 | // xgettext:no-c-format | 144 | // xgettext:no-c-format |
144 | mCompletedCombo->insertItem(i18n(" 80 %")); | 145 | mCompletedCombo->insertItem(i18n(" 80 %")); |
145 | // xgettext:no-c-format | 146 | // xgettext:no-c-format |
146 | mCompletedCombo->insertItem(i18n("100 %")); | 147 | mCompletedCombo->insertItem(i18n("100 %")); |
147 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); | 148 | connect(mCompletedCombo,SIGNAL(activated(int)),SLOT(completedChanged(int))); |
148 | topLayout->addWidget(mCompletedCombo); | 149 | topLayout->addWidget(mCompletedCombo); |
149 | 150 | ||
150 | mCompletedLabel = new QLabel(i18n("completed"),parent); | 151 | mCompletedLabel = new QLabel(i18n("completed"),parent); |
151 | topLayout->addWidget(mCompletedLabel); | 152 | topLayout->addWidget(mCompletedLabel); |
152 | 153 | ||
153 | mCompleteDateEdit = new KDateEdit(parent); | 154 | mCompleteDateEdit = new KDateEdit(parent); |
154 | topLayout->addWidget(mCompleteDateEdit ); | 155 | topLayout->addWidget(mCompleteDateEdit ); |
155 | 156 | ||
156 | mCompleteTimeEdit = new KOTimeEdit(parent); | 157 | mCompleteTimeEdit = new KOTimeEdit(parent); |
157 | topLayout->addWidget( mCompleteTimeEdit); | 158 | topLayout->addWidget( mCompleteTimeEdit); |
158 | 159 | ||
159 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); | 160 | mCompletedCombo->setSizePolicy( QSizePolicy( QSizePolicy::Preferred,QSizePolicy::Preferred) ); |
160 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); | 161 | mCompletedLabel->setSizePolicy( QSizePolicy( QSizePolicy::Expanding,QSizePolicy::Preferred) ); |
161 | 162 | ||
162 | if ( QApplication::desktop()->width() < 320 ) { | 163 | if ( QApplication::desktop()->width() < 320 ) { |
163 | mCompleteDateEdit->setMaximumWidth( 85 ); | 164 | mCompleteDateEdit->setMaximumWidth( 85 ); |
164 | topLayout->setSpacing( 0 ); | 165 | topLayout->setSpacing( 0 ); |
165 | } | 166 | } |
166 | } | 167 | } |
167 | 168 | ||
168 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) | 169 | void KOEditorGeneralTodo::initPriority(QWidget *parent, QBoxLayout *topLayout) |
169 | { | 170 | { |
170 | 171 | ||
171 | QHBox* h = new QHBox ( parent ); | 172 | QHBox* h = new QHBox ( parent ); |
172 | topLayout->addWidget( h ); | 173 | topLayout->addWidget( h ); |
173 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); | 174 | QLabel *priorityLabel = new QLabel(i18n("Priority:"), h); |
174 | // topLayout->addWidget(priorityLabel); | 175 | // topLayout->addWidget(priorityLabel); |
175 | mPriorityCombo = new QComboBox( h ); | 176 | mPriorityCombo = new QComboBox( h ); |
176 | mPriorityCombo->insertItem(i18n("1 (high)")); | 177 | mPriorityCombo->insertItem(i18n("1 (high)")); |
177 | mPriorityCombo->insertItem(i18n("2")); | 178 | mPriorityCombo->insertItem(i18n("2")); |
178 | mPriorityCombo->insertItem(i18n("3")); | 179 | mPriorityCombo->insertItem(i18n("3")); |
179 | mPriorityCombo->insertItem(i18n("4")); | 180 | mPriorityCombo->insertItem(i18n("4")); |
180 | mPriorityCombo->insertItem(i18n("5 (low)")); | 181 | mPriorityCombo->insertItem(i18n("5 (low)")); |
181 | //topLayout->addWidget(mPriorityCombo); | 182 | //topLayout->addWidget(mPriorityCombo); |
182 | } | 183 | } |
183 | 184 | ||
184 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) | 185 | void KOEditorGeneralTodo::initStatus(QWidget *parent,QBoxLayout *topLayout) |
185 | { | 186 | { |
186 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); | 187 | QBoxLayout *statusLayout = new QHBoxLayout(topLayout); |
187 | 188 | ||
188 | initCompletion( parent, statusLayout ); | 189 | initCompletion( parent, statusLayout ); |
189 | 190 | ||
190 | statusLayout->addStretch( 1 ); | 191 | statusLayout->addStretch( 1 ); |
191 | 192 | ||
192 | initPriority( parent, statusLayout ); | 193 | initPriority( parent, statusLayout ); |
193 | } | 194 | } |
194 | 195 | ||
195 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) | 196 | void KOEditorGeneralTodo::setDefaults(QDateTime due,bool allDay) |
196 | { | 197 | { |
197 | 198 | ||
198 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 199 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
199 | mLocationEdit->load(KOLocationBox::LOCATION); | 200 | mLocationEdit->load(KOLocationBox::LOCATION); |
200 | KOEditorGeneral::setDefaults(allDay); | 201 | KOEditorGeneral::setDefaults(allDay); |
201 | 202 | ||
202 | mTimeButton->setChecked( !allDay ); | 203 | mTimeButton->setChecked( !allDay ); |
203 | if(mTimeButton->isChecked()) { | 204 | if(mTimeButton->isChecked()) { |
204 | mTimeButton->setEnabled(true); | 205 | mTimeButton->setEnabled(true); |
205 | } | 206 | } |
206 | else { | 207 | else { |
207 | mTimeButton->setEnabled(false); | 208 | mTimeButton->setEnabled(false); |
208 | } | 209 | } |
209 | 210 | ||
210 | enableTimeEdits( !allDay ); | 211 | enableTimeEdits( !allDay ); |
211 | if ( due.isValid() ) { | 212 | if ( due.isValid() ) { |
212 | mDueCheck->setChecked(true); | 213 | mDueCheck->setChecked(true); |
213 | enableDueEdit(true); | 214 | enableDueEdit(true); |
214 | } else { | 215 | } else { |
215 | mDueCheck->setChecked(false); | 216 | mDueCheck->setChecked(false); |
216 | enableDueEdit(false); | 217 | enableDueEdit(false); |
217 | due = QDateTime::currentDateTime().addDays(7); | 218 | due = QDateTime::currentDateTime().addDays(7); |
218 | } | 219 | } |
219 | 220 | ||
220 | alarmDisable(true); | 221 | alarmDisable(true); |
221 | 222 | ||
222 | mStartCheck->setChecked(false); | 223 | mStartCheck->setChecked(false); |
223 | enableStartEdit(false); | 224 | enableStartEdit(false); |
224 | 225 | ||
225 | mDueDateEdit->setDate(due.date()); | 226 | mDueDateEdit->setDate(due.date()); |
226 | mDueTimeEdit->setTime(due.time()); | 227 | mDueTimeEdit->setTime(due.time()); |
227 | due = due.addDays(-7); | 228 | due = due.addDays(-7); |
228 | mStartDateEdit->setDate(due.date()); | 229 | mStartDateEdit->setDate(due.date()); |
229 | mStartTimeEdit->setTime(due.time()); | 230 | mStartTimeEdit->setTime(due.time()); |
230 | 231 | ||
231 | mPriorityCombo->setCurrentItem(2); | 232 | mPriorityCombo->setCurrentItem(2); |
232 | mCompletedLabel->setText(i18n("completed"));; | 233 | mCompletedLabel->setText(i18n("completed"));; |
233 | mCompletedCombo->setCurrentItem(0); | 234 | mCompletedCombo->setCurrentItem(0); |
234 | } | 235 | } |
235 | 236 | ||
236 | void KOEditorGeneralTodo::readTodo(Todo *todo) | 237 | void KOEditorGeneralTodo::readTodo(Todo *todo) |
237 | { | 238 | { |
238 | 239 | ||
239 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); | 240 | mSummaryEdit->load(KOLocationBox::SUMMARYTODO); |
240 | mLocationEdit->load(KOLocationBox::LOCATION); | 241 | mLocationEdit->load(KOLocationBox::LOCATION); |
241 | KOEditorGeneral::readIncidence(todo); | 242 | KOEditorGeneral::readIncidence(todo); |
242 | 243 | ||
243 | QDateTime dueDT; | 244 | QDateTime dueDT; |
244 | 245 | ||
245 | if (todo->hasDueDate()) { | 246 | if (todo->hasDueDate()) { |
246 | enableAlarmEdit(true); | 247 | enableAlarmEdit(true); |
247 | dueDT = todo->dtDue(); | 248 | dueDT = todo->dtDue(); |
248 | mDueDateEdit->setDate(todo->dtDue().date()); | 249 | mDueDateEdit->setDate(todo->dtDue().date()); |
249 | mDueTimeEdit->setTime(todo->dtDue().time()); | 250 | mDueTimeEdit->setTime(todo->dtDue().time()); |
250 | mDueCheck->setChecked(true); | 251 | mDueCheck->setChecked(true); |
251 | } else { | 252 | } else { |
252 | alarmDisable(true); | 253 | alarmDisable(true); |
253 | mDueDateEdit->setEnabled(false); | 254 | mDueDateEdit->setEnabled(false); |
254 | mDueTimeEdit->setEnabled(false); | 255 | mDueTimeEdit->setEnabled(false); |
255 | mDueDateEdit->setDate(QDate::currentDate()); | 256 | mDueDateEdit->setDate(QDate::currentDate()); |
256 | mDueTimeEdit->setTime(QTime::currentTime()); | 257 | mDueTimeEdit->setTime(QTime::currentTime()); |
257 | mDueCheck->setChecked(false); | 258 | mDueCheck->setChecked(false); |
258 | } | 259 | } |
259 | 260 | ||
260 | if (todo->hasStartDate()) { | 261 | if (todo->hasStartDate()) { |
261 | mStartDateEdit->setDate(todo->dtStart().date()); | 262 | mStartDateEdit->setDate(todo->dtStart().date()); |
262 | mStartTimeEdit->setTime(todo->dtStart().time()); | 263 | mStartTimeEdit->setTime(todo->dtStart().time()); |
263 | mStartCheck->setChecked(true); | 264 | mStartCheck->setChecked(true); |
264 | } else { | 265 | } else { |
265 | mStartDateEdit->setEnabled(false); | 266 | mStartDateEdit->setEnabled(false); |
266 | mStartTimeEdit->setEnabled(false); | 267 | mStartTimeEdit->setEnabled(false); |
267 | mStartDateEdit->setDate(QDate::currentDate()); | 268 | mStartDateEdit->setDate(QDate::currentDate()); |
268 | mStartTimeEdit->setTime(QTime::currentTime()); | 269 | mStartTimeEdit->setTime(QTime::currentTime()); |
269 | mStartCheck->setChecked(false); | 270 | mStartCheck->setChecked(false); |
270 | } | 271 | } |
271 | 272 | ||
272 | mTimeButton->setChecked( !todo->doesFloat() ); | 273 | mTimeButton->setChecked( !todo->doesFloat() ); |
273 | 274 | ||
274 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 275 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
275 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 276 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
276 | mCompleted = todo->completed(); | 277 | mCompleted = todo->completed(); |
277 | } | 278 | } |
278 | setCompletedDate(); | 279 | setCompletedDate(); |
279 | 280 | ||
280 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 281 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
281 | } | 282 | } |
282 | 283 | ||
283 | void KOEditorGeneralTodo::writeTodo(Todo *todo) | 284 | void KOEditorGeneralTodo::writeTodo(Todo *todo) |
284 | { | 285 | { |
285 | KOEditorGeneral::writeIncidence(todo); | 286 | KOEditorGeneral::writeIncidence(todo); |
286 | 287 | ||
287 | // temp. until something better happens. | 288 | // temp. until something better happens. |
288 | QString tmpStr; | 289 | QString tmpStr; |
289 | 290 | ||
290 | todo->setHasDueDate(mDueCheck->isChecked()); | 291 | todo->setHasDueDate(mDueCheck->isChecked()); |
291 | todo->setHasStartDate(mStartCheck->isChecked()); | 292 | todo->setHasStartDate(mStartCheck->isChecked()); |
292 | 293 | ||
293 | QDate tmpDate; | 294 | QDate tmpDate; |
294 | QTime tmpTime; | 295 | QTime tmpTime; |
295 | QDateTime tmpDT; | 296 | QDateTime tmpDT; |
296 | if ( mTimeButton->isChecked() ) { | 297 | if ( mTimeButton->isChecked() ) { |
297 | todo->setFloats(false); | 298 | todo->setFloats(false); |
298 | 299 | ||
299 | // set due date/time | 300 | // set due date/time |
300 | tmpDate = mDueDateEdit->date(); | 301 | tmpDate = mDueDateEdit->date(); |
301 | tmpTime = mDueTimeEdit->getTime(); | 302 | tmpTime = mDueTimeEdit->getTime(); |
302 | tmpDT.setDate(tmpDate); | 303 | tmpDT.setDate(tmpDate); |
303 | tmpDT.setTime(tmpTime); | 304 | tmpDT.setTime(tmpTime); |
304 | todo->setDtDue(tmpDT); | 305 | todo->setDtDue(tmpDT); |
305 | 306 | ||
306 | // set start date/time | 307 | // set start date/time |
307 | tmpDate = mStartDateEdit->date(); | 308 | tmpDate = mStartDateEdit->date(); |
308 | tmpTime = mStartTimeEdit->getTime(); | 309 | tmpTime = mStartTimeEdit->getTime(); |
309 | tmpDT.setDate(tmpDate); | 310 | tmpDT.setDate(tmpDate); |
310 | tmpDT.setTime(tmpTime); | 311 | tmpDT.setTime(tmpTime); |
311 | todo->setDtStart(tmpDT); | 312 | todo->setDtStart(tmpDT); |
312 | } else { | 313 | } else { |
313 | todo->setFloats(true); | 314 | todo->setFloats(true); |
314 | 315 | ||
315 | // need to change this. | 316 | // need to change this. |
316 | tmpDate = mDueDateEdit->date(); | 317 | tmpDate = mDueDateEdit->date(); |
317 | tmpTime.setHMS(0,0,0); | 318 | tmpTime.setHMS(0,0,0); |
318 | tmpDT.setDate(tmpDate); | 319 | tmpDT.setDate(tmpDate); |
319 | tmpDT.setTime(tmpTime); | 320 | tmpDT.setTime(tmpTime); |
320 | todo->setDtDue(tmpDT); | 321 | todo->setDtDue(tmpDT); |
321 | 322 | ||
322 | tmpDate = mStartDateEdit->date(); | 323 | tmpDate = mStartDateEdit->date(); |
323 | tmpTime.setHMS(0,0,0); | 324 | tmpTime.setHMS(0,0,0); |
324 | tmpDT.setDate(tmpDate); | 325 | tmpDT.setDate(tmpDate); |
325 | tmpDT.setTime(tmpTime); | 326 | tmpDT.setTime(tmpTime); |
326 | todo->setDtStart(tmpDT); | 327 | todo->setDtStart(tmpDT); |
327 | } | 328 | } |
328 | todo->setPriority(mPriorityCombo->currentItem()+1); | 329 | todo->setPriority(mPriorityCombo->currentItem()+1); |
329 | 330 | ||
330 | // set completion state | 331 | // set completion state |
331 | if ( mCompletedCombo->currentItem() == 5 ) { | 332 | if ( mCompletedCombo->currentItem() == 5 ) { |
332 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); | 333 | QDateTime comp ( mCompleteDateEdit->date(), mCompleteTimeEdit->getTime() ); |
333 | if ( comp.isValid () ) { | 334 | if ( comp.isValid () ) { |
334 | todo->setPercentComplete(0); | 335 | todo->setPercentComplete(0); |
335 | todo->setPercentComplete(100); | 336 | todo->setPercentComplete(100); |
336 | todo->setCompleted(comp); | 337 | todo->setCompleted(comp); |
337 | } else { | 338 | } else { |
338 | todo->setPercentComplete( 100 ); | 339 | todo->setPercentComplete( 100 ); |
339 | if ( mCompleted.isValid() ) | 340 | if ( mCompleted.isValid() ) |
340 | todo->setCompleted(mCompleted); | 341 | todo->setCompleted(mCompleted); |
341 | } | 342 | } |
342 | } else { | 343 | } else { |
343 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); | 344 | todo->setPercentComplete(mCompletedCombo->currentItem() * 20); |
344 | } | 345 | } |
345 | 346 | ||
346 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); | 347 | mSummaryEdit->save(KOLocationBox::SUMMARYTODO); |
347 | } | 348 | } |
348 | 349 | ||
349 | void KOEditorGeneralTodo::enableDueEdit(bool enable) | 350 | void KOEditorGeneralTodo::enableDueEdit(bool enable) |
350 | { | 351 | { |
351 | mDueDateEdit->setEnabled( enable ); | 352 | mDueDateEdit->setEnabled( enable ); |
352 | 353 | ||
353 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 354 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
354 | mTimeButton->setEnabled(true); | 355 | mTimeButton->setEnabled(true); |
355 | } | 356 | } |
356 | else { | 357 | else { |
357 | mTimeButton->setEnabled(false); | 358 | mTimeButton->setEnabled(false); |
358 | mTimeButton->setChecked(false); | 359 | mTimeButton->setChecked(false); |
359 | } | 360 | } |
360 | 361 | ||
361 | if (enable) { | 362 | if (enable) { |
362 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); | 363 | mDueTimeEdit->setEnabled( mTimeButton->isChecked() ); |
363 | } else { | 364 | } else { |
364 | mDueTimeEdit->setEnabled( false ); | 365 | mDueTimeEdit->setEnabled( false ); |
365 | } | 366 | } |
366 | } | 367 | } |
367 | 368 | ||
368 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) | 369 | void KOEditorGeneralTodo::enableStartEdit( bool enable ) |
369 | { | 370 | { |
370 | mStartDateEdit->setEnabled( enable ); | 371 | mStartDateEdit->setEnabled( enable ); |
371 | 372 | ||
372 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { | 373 | if(mDueCheck->isChecked() || mStartCheck->isChecked()) { |
373 | mTimeButton->setEnabled(true); | 374 | mTimeButton->setEnabled(true); |
374 | } | 375 | } |
375 | else { | 376 | else { |
376 | mTimeButton->setEnabled(false); | 377 | mTimeButton->setEnabled(false); |
377 | mTimeButton->setChecked(false); | 378 | mTimeButton->setChecked(false); |
378 | } | 379 | } |
379 | 380 | ||
380 | if (enable) { | 381 | if (enable) { |
381 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); | 382 | mStartTimeEdit->setEnabled( mTimeButton->isChecked() ); |
382 | } else { | 383 | } else { |
383 | mStartTimeEdit->setEnabled( false ); | 384 | mStartTimeEdit->setEnabled( false ); |
384 | } | 385 | } |
385 | } | 386 | } |
386 | 387 | ||
387 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) | 388 | void KOEditorGeneralTodo::enableTimeEdits(bool enable) |
388 | { | 389 | { |
389 | if(mStartCheck->isChecked()) { | 390 | if(mStartCheck->isChecked()) { |
390 | mStartTimeEdit->setEnabled( enable ); | 391 | mStartTimeEdit->setEnabled( enable ); |
391 | } | 392 | } |
392 | if(mDueCheck->isChecked()) { | 393 | if(mDueCheck->isChecked()) { |
393 | mDueTimeEdit->setEnabled( enable ); | 394 | mDueTimeEdit->setEnabled( enable ); |
394 | } | 395 | } |
395 | } | 396 | } |
396 | 397 | ||
397 | void KOEditorGeneralTodo::showAlarm() | 398 | void KOEditorGeneralTodo::showAlarm() |
398 | { | 399 | { |
399 | if ( mDueCheck->isChecked() ) { | 400 | if ( mDueCheck->isChecked() ) { |
400 | alarmDisable(false); | 401 | alarmDisable(false); |
401 | } | 402 | } |
402 | else { | 403 | else { |
403 | alarmDisable(true); | 404 | alarmDisable(true); |
404 | } | 405 | } |
405 | } | 406 | } |
406 | 407 | ||
407 | bool KOEditorGeneralTodo::validateInput() | 408 | bool KOEditorGeneralTodo::validateInput() |
408 | { | 409 | { |
409 | if (mDueCheck->isChecked()) { | 410 | if (mDueCheck->isChecked()) { |
410 | if (!mDueDateEdit->inputIsValid()) { | 411 | if (!mDueDateEdit->inputIsValid()) { |
411 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); | 412 | KMessageBox::sorry(0,i18n("Please specify a valid due date.")); |
412 | return false; | 413 | return false; |
413 | } | 414 | } |
414 | } | 415 | } |
415 | 416 | ||
416 | if (mStartCheck->isChecked()) { | 417 | if (mStartCheck->isChecked()) { |
417 | if (!mStartDateEdit->inputIsValid()) { | 418 | if (!mStartDateEdit->inputIsValid()) { |
418 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); | 419 | KMessageBox::sorry(0,i18n("Please specify a valid start date.")); |
419 | return false; | 420 | return false; |
420 | } | 421 | } |
421 | } | 422 | } |
422 | 423 | ||
423 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { | 424 | if (mStartCheck->isChecked() && mDueCheck->isChecked()) { |
424 | QDateTime startDate; | 425 | QDateTime startDate; |
425 | QDateTime dueDate; | 426 | QDateTime dueDate; |
426 | startDate.setDate(mStartDateEdit->date()); | 427 | startDate.setDate(mStartDateEdit->date()); |
427 | dueDate.setDate(mDueDateEdit->date()); | 428 | dueDate.setDate(mDueDateEdit->date()); |
428 | if (mTimeButton->isChecked()) { | 429 | if (mTimeButton->isChecked()) { |
429 | startDate.setTime(mStartTimeEdit->getTime()); | 430 | startDate.setTime(mStartTimeEdit->getTime()); |
430 | dueDate.setTime(mDueTimeEdit->getTime()); | 431 | dueDate.setTime(mDueTimeEdit->getTime()); |
431 | } | 432 | } |
432 | if (startDate > dueDate) { | 433 | if (startDate > dueDate) { |
433 | KMessageBox::sorry(0, | 434 | KMessageBox::sorry(0, |
434 | i18n("The start date cannot be after the due date.")); | 435 | i18n("The start date cannot be after the due date.")); |
435 | return false; | 436 | return false; |
436 | } | 437 | } |
437 | } | 438 | } |
438 | 439 | ||
439 | return KOEditorGeneral::validateInput(); | 440 | return KOEditorGeneral::validateInput(); |
440 | } | 441 | } |
441 | 442 | ||
442 | void KOEditorGeneralTodo::completedChanged(int index) | 443 | void KOEditorGeneralTodo::completedChanged(int index) |
443 | { | 444 | { |
444 | if (index == 5) { | 445 | if (index == 5) { |
445 | //get rid of milli sec | 446 | //get rid of milli sec |
446 | mCompleted = QDateTime::currentDateTime(); | 447 | mCompleted = QDateTime::currentDateTime(); |
447 | } | 448 | } |
448 | setCompletedDate(); | 449 | setCompletedDate(); |
449 | } | 450 | } |
450 | 451 | ||
451 | void KOEditorGeneralTodo::setCompletedDate() | 452 | void KOEditorGeneralTodo::setCompletedDate() |
452 | { | 453 | { |
453 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { | 454 | if (mCompletedCombo->currentItem() == 5 && mCompleted.isValid()) { |
454 | if ( QApplication::desktop()->width() < 480 ) { | 455 | if ( QApplication::desktop()->width() < 480 ) { |
455 | mCompletedLabel->setText(i18n(" on")); | 456 | mCompletedLabel->setText(i18n(" on")); |
456 | } | 457 | } |
457 | else | 458 | else |
458 | mCompletedLabel->setText(i18n(" completed on ")); | 459 | mCompletedLabel->setText(i18n(" completed on ")); |
459 | mCompleteDateEdit->show(); | 460 | mCompleteDateEdit->show(); |
460 | mCompleteTimeEdit->show(); | 461 | mCompleteTimeEdit->show(); |
461 | mCompleteTimeEdit->setTime( mCompleted.time() ); | 462 | mCompleteTimeEdit->setTime( mCompleted.time() ); |
462 | mCompleteDateEdit->setDate( mCompleted.date() ); | 463 | mCompleteDateEdit->setDate( mCompleted.date() ); |
463 | } else { | 464 | } else { |
464 | mCompletedLabel->setText(i18n("completed")); | 465 | mCompletedLabel->setText(i18n("completed")); |
465 | mCompleteDateEdit->hide(); | 466 | mCompleteDateEdit->hide(); |
466 | mCompleteTimeEdit->hide(); | 467 | mCompleteTimeEdit->hide(); |
467 | } | 468 | } |
468 | } | 469 | } |
469 | 470 | ||
470 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) | 471 | void KOEditorGeneralTodo::modified (Todo* todo, int modification) |
471 | { | 472 | { |
472 | switch (modification) { | 473 | switch (modification) { |
473 | case KOGlobals::PRIORITY_MODIFIED: | 474 | case KOGlobals::PRIORITY_MODIFIED: |
474 | mPriorityCombo->setCurrentItem(todo->priority()-1); | 475 | mPriorityCombo->setCurrentItem(todo->priority()-1); |
475 | break; | 476 | break; |
476 | case KOGlobals::COMPLETION_MODIFIED: | 477 | case KOGlobals::COMPLETION_MODIFIED: |
477 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); | 478 | mCompletedCombo->setCurrentItem(todo->percentComplete() / 20); |
478 | if (todo->isCompleted() && todo->hasCompletedDate()) { | 479 | if (todo->isCompleted() && todo->hasCompletedDate()) { |
479 | mCompleted = todo->completed(); | 480 | mCompleted = todo->completed(); |
480 | } | 481 | } |
481 | setCompletedDate(); | 482 | setCompletedDate(); |
482 | break; | 483 | break; |
483 | case KOGlobals::CATEGORY_MODIFIED: | 484 | case KOGlobals::CATEGORY_MODIFIED: |
484 | setCategories (todo->categoriesStr ()); | 485 | setCategories (todo->categoriesStr ()); |
485 | break; | 486 | break; |
486 | case KOGlobals::UNKNOWN_MODIFIED: // fall through | 487 | case KOGlobals::UNKNOWN_MODIFIED: // fall through |
487 | default: | 488 | default: |
488 | readTodo( todo ); | 489 | readTodo( todo ); |
489 | break; | 490 | break; |
490 | } | 491 | } |
491 | } | 492 | } |
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index cb519b2..65accdc 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -1,1578 +1,1579 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2000,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 | 19 | ||
20 | #include <qpopupmenu.h> | 20 | #include <qpopupmenu.h> |
21 | #include <qfont.h> | 21 | #include <qfont.h> |
22 | #include <qfontmetrics.h> | 22 | #include <qfontmetrics.h> |
23 | #include <qkeycode.h> | 23 | #include <qkeycode.h> |
24 | #include <qhbox.h> | 24 | #include <qhbox.h> |
25 | #include <qtimer.h> | ||
25 | #include <qvbox.h> | 26 | #include <qvbox.h> |
26 | #include <qwidgetstack.h> | 27 | #include <qwidgetstack.h> |
27 | #include <qpushbutton.h> | 28 | #include <qpushbutton.h> |
28 | #include <qtooltip.h> | 29 | #include <qtooltip.h> |
29 | #include <qpainter.h> | 30 | #include <qpainter.h> |
30 | #include <qwhatsthis.h> | 31 | #include <qwhatsthis.h> |
31 | #ifndef DESKTOP_VERSION | 32 | #ifndef DESKTOP_VERSION |
32 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
33 | #else | 34 | #else |
34 | #include <qapplication.h> | 35 | #include <qapplication.h> |
35 | #endif | 36 | #endif |
36 | 37 | ||
37 | #include <kdebug.h> | 38 | #include <kdebug.h> |
38 | #include <klocale.h> | 39 | #include <klocale.h> |
39 | #include <kglobal.h> | 40 | #include <kglobal.h> |
40 | #include <kconfig.h> | 41 | #include <kconfig.h> |
41 | #include <kiconloader.h> | 42 | #include <kiconloader.h> |
42 | 43 | ||
43 | #include <kcalendarsystem.h> | 44 | #include <kcalendarsystem.h> |
44 | 45 | ||
45 | #ifndef KORG_NOPRINTER | 46 | #ifndef KORG_NOPRINTER |
46 | #include "calprinter.h" | 47 | #include "calprinter.h" |
47 | #endif | 48 | #endif |
48 | #include "koprefs.h" | 49 | #include "koprefs.h" |
49 | #ifndef KORG_NOPLUGINS | 50 | #ifndef KORG_NOPLUGINS |
50 | #include "kocore.h" | 51 | #include "kocore.h" |
51 | #endif | 52 | #endif |
52 | #include "koglobals.h" | 53 | #include "koglobals.h" |
53 | #include <libkcal/kincidenceformatter.h> | 54 | #include <libkcal/kincidenceformatter.h> |
54 | 55 | ||
55 | #include "komonthview.h" | 56 | #include "komonthview.h" |
56 | 57 | ||
57 | #define PIXMAP_SIZE 5 | 58 | #define PIXMAP_SIZE 5 |
58 | #ifdef DESKTOP_VERSION | 59 | #ifdef DESKTOP_VERSION |
59 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; | 60 | QToolTipGroup *MonthViewCell::mToolTipGroup = 0; |
60 | #endif | 61 | #endif |
61 | class KNOWhatsThis :public QWhatsThis | 62 | class KNOWhatsThis :public QWhatsThis |
62 | { | 63 | { |
63 | public: | 64 | public: |
64 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; | 65 | KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; |
65 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; | 66 | //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; |
66 | 67 | ||
67 | protected: | 68 | protected: |
68 | virtual QString text( const QPoint& p) | 69 | virtual QString text( const QPoint& p) |
69 | { | 70 | { |
70 | return _wid->getWhatsThisText(p) ; | 71 | return _wid->getWhatsThisText(p) ; |
71 | }; | 72 | }; |
72 | private: | 73 | private: |
73 | KNoScrollListBox* _wid; | 74 | KNoScrollListBox* _wid; |
74 | 75 | ||
75 | }; | 76 | }; |
76 | 77 | ||
77 | 78 | ||
78 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) | 79 | KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) |
79 | : QListBox(parent, name, WRepaintNoErase) | 80 | : QListBox(parent, name, WRepaintNoErase) |
80 | { | 81 | { |
81 | #ifndef DESKTOP_VERSION | 82 | #ifndef DESKTOP_VERSION |
82 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 83 | QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
83 | #endif | 84 | #endif |
84 | mWT = new KNOWhatsThis(this); | 85 | mWT = new KNOWhatsThis(this); |
85 | } | 86 | } |
86 | KNoScrollListBox::~KNoScrollListBox() | 87 | KNoScrollListBox::~KNoScrollListBox() |
87 | { | 88 | { |
88 | 89 | ||
89 | } | 90 | } |
90 | QString KNoScrollListBox::getWhatsThisText(QPoint p) | 91 | QString KNoScrollListBox::getWhatsThisText(QPoint p) |
91 | { | 92 | { |
92 | QListBoxItem* item = itemAt ( p ); | 93 | QListBoxItem* item = itemAt ( p ); |
93 | if ( ! item ) { | 94 | if ( ! item ) { |
94 | return i18n("Click in the cell\nto add an event!"); | 95 | return i18n("Click in the cell\nto add an event!"); |
95 | } | 96 | } |
96 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); | 97 | return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); |
97 | } | 98 | } |
98 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) | 99 | void KNoScrollListBox::keyPressEvent(QKeyEvent *e) |
99 | { | 100 | { |
100 | 101 | ||
101 | switch(e->key()) { | 102 | switch(e->key()) { |
102 | case Key_Right: | 103 | case Key_Right: |
103 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 104 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
104 | { | 105 | { |
105 | e->ignore(); | 106 | e->ignore(); |
106 | return; | 107 | return; |
107 | } | 108 | } |
108 | scrollBy(10,0); | 109 | scrollBy(10,0); |
109 | break; | 110 | break; |
110 | case Key_Left: | 111 | case Key_Left: |
111 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) | 112 | if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) |
112 | { | 113 | { |
113 | e->ignore(); | 114 | e->ignore(); |
114 | return; | 115 | return; |
115 | } | 116 | } |
116 | scrollBy(-10,0); | 117 | scrollBy(-10,0); |
117 | break; | 118 | break; |
118 | case Key_Up: | 119 | case Key_Up: |
119 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 120 | if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
120 | e->ignore(); | 121 | e->ignore(); |
121 | break; | 122 | break; |
122 | } | 123 | } |
123 | setCurrentItem((currentItem()+count()-1)%count()); | 124 | setCurrentItem((currentItem()+count()-1)%count()); |
124 | if(!itemVisible(currentItem())) { | 125 | if(!itemVisible(currentItem())) { |
125 | if((unsigned int) currentItem() == (count()-1)) { | 126 | if((unsigned int) currentItem() == (count()-1)) { |
126 | setTopItem(currentItem()-numItemsVisible()+1); | 127 | setTopItem(currentItem()-numItemsVisible()+1); |
127 | } else { | 128 | } else { |
128 | setTopItem(topItem()-1); | 129 | setTopItem(topItem()-1); |
129 | } | 130 | } |
130 | } | 131 | } |
131 | break; | 132 | break; |
132 | case Key_Down: | 133 | case Key_Down: |
133 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { | 134 | if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) { |
134 | e->ignore(); | 135 | e->ignore(); |
135 | break; | 136 | break; |
136 | } | 137 | } |
137 | setCurrentItem((currentItem()+1)%count()); | 138 | setCurrentItem((currentItem()+1)%count()); |
138 | if(!itemVisible(currentItem())) { | 139 | if(!itemVisible(currentItem())) { |
139 | if(currentItem() == 0) { | 140 | if(currentItem() == 0) { |
140 | setTopItem(0); | 141 | setTopItem(0); |
141 | } else { | 142 | } else { |
142 | setTopItem(topItem()+1); | 143 | setTopItem(topItem()+1); |
143 | } | 144 | } |
144 | } | 145 | } |
145 | break; | 146 | break; |
146 | case Key_I: | 147 | case Key_I: |
147 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); | 148 | QTimer::singleShot( 11, this, SLOT ( oneDown() ) ); |
148 | e->ignore(); | 149 | e->ignore(); |
149 | break; | 150 | break; |
150 | case Key_Shift: | 151 | case Key_Shift: |
151 | emit shiftDown(); | 152 | emit shiftDown(); |
152 | break; | 153 | break; |
153 | default: | 154 | default: |
154 | e->ignore(); | 155 | e->ignore(); |
155 | break; | 156 | break; |
156 | } | 157 | } |
157 | } | 158 | } |
158 | 159 | ||
159 | void KNoScrollListBox::oneDown() | 160 | void KNoScrollListBox::oneDown() |
160 | { | 161 | { |
161 | setCurrentItem((currentItem()+1)%count()); | 162 | setCurrentItem((currentItem()+1)%count()); |
162 | if(!itemVisible(currentItem())) { | 163 | if(!itemVisible(currentItem())) { |
163 | if(currentItem() == 0) { | 164 | if(currentItem() == 0) { |
164 | setTopItem(0); | 165 | setTopItem(0); |
165 | } else { | 166 | } else { |
166 | setTopItem(topItem()+1); | 167 | setTopItem(topItem()+1); |
167 | } | 168 | } |
168 | } | 169 | } |
169 | } | 170 | } |
170 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) | 171 | void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) |
171 | { | 172 | { |
172 | switch(e->key()) { | 173 | switch(e->key()) { |
173 | case Key_Shift: | 174 | case Key_Shift: |
174 | emit shiftUp(); | 175 | emit shiftUp(); |
175 | break; | 176 | break; |
176 | default: | 177 | default: |
177 | break; | 178 | break; |
178 | } | 179 | } |
179 | } | 180 | } |
180 | 181 | ||
181 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) | 182 | void KNoScrollListBox::mousePressEvent(QMouseEvent *e) |
182 | { | 183 | { |
183 | QListBox::mousePressEvent(e); | 184 | QListBox::mousePressEvent(e); |
184 | 185 | ||
185 | if(e->button() == RightButton) { | 186 | if(e->button() == RightButton) { |
186 | emit rightClick(); | 187 | emit rightClick(); |
187 | } | 188 | } |
188 | } | 189 | } |
189 | 190 | ||
190 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) | 191 | MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) |
191 | : QListBoxItem() | 192 | : QListBoxItem() |
192 | { | 193 | { |
193 | setText( s ); | 194 | setText( s ); |
194 | 195 | ||
195 | mIncidence = incidence; | 196 | mIncidence = incidence; |
196 | mDate = qd; | 197 | mDate = qd; |
197 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); | 198 | // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence )); |
198 | mRecur = false; | 199 | mRecur = false; |
199 | mAlarm = false; | 200 | mAlarm = false; |
200 | mReply = false; | 201 | mReply = false; |
201 | mInfo = false; | 202 | mInfo = false; |
202 | } | 203 | } |
203 | 204 | ||
204 | void MonthViewItem::paint(QPainter *p) | 205 | void MonthViewItem::paint(QPainter *p) |
205 | { | 206 | { |
206 | #if QT_VERSION >= 0x030000 | 207 | #if QT_VERSION >= 0x030000 |
207 | bool sel = isSelected(); | 208 | bool sel = isSelected(); |
208 | #else | 209 | #else |
209 | bool sel = selected(); | 210 | bool sel = selected(); |
210 | #endif | 211 | #endif |
211 | 212 | ||
212 | 213 | ||
213 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) | 214 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) |
214 | { | 215 | { |
215 | p->setBackgroundColor( palette().color( QPalette::Normal, \ | 216 | p->setBackgroundColor( palette().color( QPalette::Normal, \ |
216 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); | 217 | sel ? QColorGroup::Highlight : QColorGroup::Background ) ); |
217 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); | 218 | p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) ); |
218 | } | 219 | } |
219 | int x = 1; | 220 | int x = 1; |
220 | int y = 3;//(height() - mRecurPixmap.height()) /2; | 221 | int y = 3;//(height() - mRecurPixmap.height()) /2; |
221 | int size = PIXMAP_SIZE; | 222 | int size = PIXMAP_SIZE; |
222 | if ( QApplication::desktop()->width() < 300 ) | 223 | if ( QApplication::desktop()->width() < 300 ) |
223 | size = 3; | 224 | size = 3; |
224 | if ( KOPrefs::instance()->mMonthShowIcons ) { | 225 | if ( KOPrefs::instance()->mMonthShowIcons ) { |
225 | if ( mInfo ) { | 226 | if ( mInfo ) { |
226 | p->fillRect ( x, y,size,size, Qt::darkGreen ); | 227 | p->fillRect ( x, y,size,size, Qt::darkGreen ); |
227 | x += size + 1; | 228 | x += size + 1; |
228 | } | 229 | } |
229 | if ( mRecur ) { | 230 | if ( mRecur ) { |
230 | p->fillRect ( x, y,size,size, Qt::blue ); | 231 | p->fillRect ( x, y,size,size, Qt::blue ); |
231 | x += size + 1; | 232 | x += size + 1; |
232 | } | 233 | } |
233 | if ( mAlarm ) { | 234 | if ( mAlarm ) { |
234 | p->fillRect ( x, y,size,size, Qt::red ); | 235 | p->fillRect ( x, y,size,size, Qt::red ); |
235 | x += size + 1; | 236 | x += size + 1; |
236 | } | 237 | } |
237 | if ( mReply ) { | 238 | if ( mReply ) { |
238 | p->fillRect ( x, y,size,size, Qt::yellow ); | 239 | p->fillRect ( x, y,size,size, Qt::yellow ); |
239 | x += size + 1; | 240 | x += size + 1; |
240 | } | 241 | } |
241 | } | 242 | } |
242 | QFontMetrics fm = p->fontMetrics(); | 243 | QFontMetrics fm = p->fontMetrics(); |
243 | int yPos; | 244 | int yPos; |
244 | int pmheight = size; | 245 | int pmheight = size; |
245 | if( pmheight < fm.height() ) | 246 | if( pmheight < fm.height() ) |
246 | yPos = fm.ascent() + fm.leading()/2; | 247 | yPos = fm.ascent() + fm.leading()/2; |
247 | else | 248 | else |
248 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); | 249 | yPos = pmheight/2 - fm.height()/2 + fm.ascent(); |
249 | p->setPen( palette().color( QPalette::Normal, sel ? \ | 250 | p->setPen( palette().color( QPalette::Normal, sel ? \ |
250 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); | 251 | QColorGroup::HighlightedText : QColorGroup::Foreground ) ); |
251 | p->drawText( x, yPos, text() ); | 252 | p->drawText( x, yPos, text() ); |
252 | if ( mIncidence->cancelled() ) { | 253 | if ( mIncidence->cancelled() ) { |
253 | int wid = fm.width( text() ); | 254 | int wid = fm.width( text() ); |
254 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); | 255 | p->drawLine( x, yPos- fm.height()/2+3,x+wid, yPos- fm.height()/2 +3); |
255 | } | 256 | } |
256 | 257 | ||
257 | } | 258 | } |
258 | 259 | ||
259 | int MonthViewItem::height(const QListBox *lb) const | 260 | int MonthViewItem::height(const QListBox *lb) const |
260 | { | 261 | { |
261 | return lb->fontMetrics().lineSpacing()+1; | 262 | return lb->fontMetrics().lineSpacing()+1; |
262 | } | 263 | } |
263 | 264 | ||
264 | int MonthViewItem::width(const QListBox *lb) const | 265 | int MonthViewItem::width(const QListBox *lb) const |
265 | { | 266 | { |
266 | int size = PIXMAP_SIZE; | 267 | int size = PIXMAP_SIZE; |
267 | if ( QApplication::desktop()->width() < 300 ) | 268 | if ( QApplication::desktop()->width() < 300 ) |
268 | size = 3; | 269 | size = 3; |
269 | int x = 1; | 270 | int x = 1; |
270 | if ( mInfo ) { | 271 | if ( mInfo ) { |
271 | x += size + 1; | 272 | x += size + 1; |
272 | } | 273 | } |
273 | if( mRecur ) { | 274 | if( mRecur ) { |
274 | x += size+1; | 275 | x += size+1; |
275 | } | 276 | } |
276 | if( mAlarm ) { | 277 | if( mAlarm ) { |
277 | x += size+1; | 278 | x += size+1; |
278 | } | 279 | } |
279 | if( mReply ) { | 280 | if( mReply ) { |
280 | x += size+1; | 281 | x += size+1; |
281 | } | 282 | } |
282 | 283 | ||
283 | return( x + lb->fontMetrics().width( text() ) + 1 ); | 284 | return( x + lb->fontMetrics().width( text() ) + 1 ); |
284 | } | 285 | } |
285 | 286 | ||
286 | 287 | ||
287 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) | 288 | MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) |
288 | : QWidget( par ), | 289 | : QWidget( par ), |
289 | mMonthView( parent ) | 290 | mMonthView( parent ) |
290 | { | 291 | { |
291 | 292 | ||
292 | QVBoxLayout *topLayout = new QVBoxLayout( this ); | 293 | QVBoxLayout *topLayout = new QVBoxLayout( this ); |
293 | 294 | ||
294 | // mLabel = new QLabel( this );QPushButton | 295 | // mLabel = new QLabel( this );QPushButton |
295 | mLabel = new QPushButton( this ); | 296 | mLabel = new QPushButton( this ); |
296 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 297 | //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
297 | //mLabel->setLineWidth( 1 ); | 298 | //mLabel->setLineWidth( 1 ); |
298 | //mLabel->setAlignment( AlignCenter ); | 299 | //mLabel->setAlignment( AlignCenter ); |
299 | mLabel->setFlat( true ); | 300 | mLabel->setFlat( true ); |
300 | mLabel->setFocusPolicy(NoFocus); | 301 | mLabel->setFocusPolicy(NoFocus); |
301 | mItemList = new KNoScrollListBox( this ); | 302 | mItemList = new KNoScrollListBox( this ); |
302 | mItemList->setMinimumSize( 10, 10 ); | 303 | mItemList->setMinimumSize( 10, 10 ); |
303 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); | 304 | mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); |
304 | mItemList->setLineWidth( 1 ); | 305 | mItemList->setLineWidth( 1 ); |
305 | topLayout->addWidget( mItemList ); | 306 | topLayout->addWidget( mItemList ); |
306 | mLabel->raise(); | 307 | mLabel->raise(); |
307 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) | 308 | // QColor( 0,0,255 ) QColor( 160,1600,255 ) |
308 | mStandardPalette = palette(); | 309 | mStandardPalette = palette(); |
309 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); | 310 | mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) ); |
310 | 311 | ||
311 | enableScrollBars( false ); | 312 | enableScrollBars( false ); |
312 | updateConfig(); | 313 | updateConfig(); |
313 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); | 314 | //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); |
314 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); | 315 | connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); |
315 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), | 316 | connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), |
316 | SLOT( defaultAction( QListBoxItem * ) ) ); | 317 | SLOT( defaultAction( QListBoxItem * ) ) ); |
317 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, | 318 | connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, |
318 | const QPoint &) ), | 319 | const QPoint &) ), |
319 | SLOT( contextMenu( QListBoxItem * ) ) ); | 320 | SLOT( contextMenu( QListBoxItem * ) ) ); |
320 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), | 321 | connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), |
321 | SLOT( selection( QListBoxItem * ) ) ); | 322 | SLOT( selection( QListBoxItem * ) ) ); |
322 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 323 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
323 | SLOT( cellClicked( QListBoxItem * ) ) ); | 324 | SLOT( cellClicked( QListBoxItem * ) ) ); |
324 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), | 325 | connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), |
325 | SLOT( selection( QListBoxItem * ) ) ); | 326 | SLOT( selection( QListBoxItem * ) ) ); |
326 | } | 327 | } |
327 | #ifdef DESKTOP_VERSION | 328 | #ifdef DESKTOP_VERSION |
328 | QToolTipGroup *MonthViewCell::toolTipGroup() | 329 | QToolTipGroup *MonthViewCell::toolTipGroup() |
329 | { | 330 | { |
330 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); | 331 | if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); |
331 | return mToolTipGroup; | 332 | return mToolTipGroup; |
332 | } | 333 | } |
333 | #endif | 334 | #endif |
334 | 335 | ||
335 | void MonthViewCell::setDate( const QDate &date ) | 336 | void MonthViewCell::setDate( const QDate &date ) |
336 | { | 337 | { |
337 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; | 338 | // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; |
338 | mDate = date; | 339 | mDate = date; |
339 | 340 | ||
340 | 341 | ||
341 | 342 | ||
342 | //resizeEvent( 0 ); | 343 | //resizeEvent( 0 ); |
343 | } | 344 | } |
344 | 345 | ||
345 | QDate MonthViewCell::date() const | 346 | QDate MonthViewCell::date() const |
346 | { | 347 | { |
347 | return mDate; | 348 | return mDate; |
348 | } | 349 | } |
349 | 350 | ||
350 | void MonthViewCell::setPrimary( bool primary ) | 351 | void MonthViewCell::setPrimary( bool primary ) |
351 | { | 352 | { |
352 | mPrimary = primary; | 353 | mPrimary = primary; |
353 | //setMyPalette(); | 354 | //setMyPalette(); |
354 | } | 355 | } |
355 | void MonthViewCell::setMyPalette() | 356 | void MonthViewCell::setMyPalette() |
356 | { | 357 | { |
357 | 358 | ||
358 | if ( mHoliday) { | 359 | if ( mHoliday) { |
359 | setPalette( mHolidayPalette ); | 360 | setPalette( mHolidayPalette ); |
360 | } else { | 361 | } else { |
361 | if ( mPrimary ) { | 362 | if ( mPrimary ) { |
362 | setPalette( mPrimaryPalette ); | 363 | setPalette( mPrimaryPalette ); |
363 | } else { | 364 | } else { |
364 | setPalette( mNonPrimaryPalette ); | 365 | setPalette( mNonPrimaryPalette ); |
365 | } | 366 | } |
366 | } | 367 | } |
367 | QPalette pal = palette(); | 368 | QPalette pal = palette(); |
368 | 369 | ||
369 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); | 370 | mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) )); |
370 | } | 371 | } |
371 | QPalette MonthViewCell::getPalette () | 372 | QPalette MonthViewCell::getPalette () |
372 | { | 373 | { |
373 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) | 374 | if ( !KOPrefs::instance()->mMonthViewUsesDayColors ) |
374 | return mStandardPalette; | 375 | return mStandardPalette; |
375 | if ( mHoliday) { | 376 | if ( mHoliday) { |
376 | return mHolidayPalette ; | 377 | return mHolidayPalette ; |
377 | } else { | 378 | } else { |
378 | if ( mPrimary ) { | 379 | if ( mPrimary ) { |
379 | return mPrimaryPalette ; | 380 | return mPrimaryPalette ; |
380 | } | 381 | } |
381 | } | 382 | } |
382 | return mNonPrimaryPalette; | 383 | return mNonPrimaryPalette; |
383 | } | 384 | } |
384 | bool MonthViewCell::isPrimary() const | 385 | bool MonthViewCell::isPrimary() const |
385 | { | 386 | { |
386 | return mPrimary; | 387 | return mPrimary; |
387 | } | 388 | } |
388 | 389 | ||
389 | void MonthViewCell::setHoliday( bool holiday ) | 390 | void MonthViewCell::setHoliday( bool holiday ) |
390 | { | 391 | { |
391 | mHoliday = holiday; | 392 | mHoliday = holiday; |
392 | //setMyPalette(); | 393 | //setMyPalette(); |
393 | } | 394 | } |
394 | 395 | ||
395 | void MonthViewCell::setHoliday( const QString &holiday ) | 396 | void MonthViewCell::setHoliday( const QString &holiday ) |
396 | { | 397 | { |
397 | mHolidayString = holiday; | 398 | mHolidayString = holiday; |
398 | 399 | ||
399 | if ( !holiday.isEmpty() ) { | 400 | if ( !holiday.isEmpty() ) { |
400 | setHoliday( true ); | 401 | setHoliday( true ); |
401 | } | 402 | } |
402 | } | 403 | } |
403 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) | 404 | void MonthViewCell::keyPressEvent ( QKeyEvent * e ) |
404 | { | 405 | { |
405 | 406 | ||
406 | e->ignore(); | 407 | e->ignore(); |
407 | 408 | ||
408 | } | 409 | } |
409 | void MonthViewCell::clear() | 410 | void MonthViewCell::clear() |
410 | { | 411 | { |
411 | mItemList->clear(); | 412 | mItemList->clear(); |
412 | QApplication::removePostedEvents ( mItemList ); | 413 | QApplication::removePostedEvents ( mItemList ); |
413 | QApplication::removePostedEvents ( mLabel ); | 414 | QApplication::removePostedEvents ( mLabel ); |
414 | QApplication::removePostedEvents ( this ); | 415 | QApplication::removePostedEvents ( this ); |
415 | } | 416 | } |
416 | 417 | ||
417 | void MonthViewCell::startUpdateCell() | 418 | void MonthViewCell::startUpdateCell() |
418 | { | 419 | { |
419 | 420 | ||
420 | mItemList->setFocusPolicy(NoFocus); | 421 | mItemList->setFocusPolicy(NoFocus); |
421 | if ( !mMonthView->isUpdatePossible() ) | 422 | if ( !mMonthView->isUpdatePossible() ) |
422 | return; | 423 | return; |
423 | 424 | ||
424 | /* | 425 | /* |
425 | if ( !isVisible() ){ | 426 | if ( !isVisible() ){ |
426 | return; | 427 | return; |
427 | } | 428 | } |
428 | */ | 429 | */ |
429 | // qDebug("MonthViewCell::updateCell() "); | 430 | // qDebug("MonthViewCell::updateCell() "); |
430 | setPrimary( mDate.month()%2 ); | 431 | setPrimary( mDate.month()%2 ); |
431 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); | 432 | setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); |
432 | if ( mDate == QDate::currentDate() ) { | 433 | if ( mDate == QDate::currentDate() ) { |
433 | mItemList->setLineWidth( 3 ); | 434 | mItemList->setLineWidth( 3 ); |
434 | } else { | 435 | } else { |
435 | mItemList->setLineWidth( 1 ); | 436 | mItemList->setLineWidth( 1 ); |
436 | } | 437 | } |
437 | mItemList->clear(); | 438 | mItemList->clear(); |
438 | 439 | ||
439 | #ifdef DESKTOP_VERSION | 440 | #ifdef DESKTOP_VERSION |
440 | QToolTip::remove(this); | 441 | QToolTip::remove(this); |
441 | #endif | 442 | #endif |
442 | mToolTip = ""; | 443 | mToolTip = ""; |
443 | //qApp->processEvents(); | 444 | //qApp->processEvents(); |
444 | if ( !mHolidayString.isEmpty() ) { | 445 | if ( !mHolidayString.isEmpty() ) { |
445 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); | 446 | MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); |
446 | item->setPalette( mHolidayPalette ); | 447 | item->setPalette( mHolidayPalette ); |
447 | mItemList->insertItem( item ); | 448 | mItemList->insertItem( item ); |
448 | mToolTip += mHolidayString+"\n"; | 449 | mToolTip += mHolidayString+"\n"; |
449 | } | 450 | } |
450 | } | 451 | } |
451 | 452 | ||
452 | void MonthViewCell::insertEvent(Event *event) | 453 | void MonthViewCell::insertEvent(Event *event) |
453 | { | 454 | { |
454 | 455 | ||
455 | mItemList->setFocusPolicy(WheelFocus); | 456 | mItemList->setFocusPolicy(WheelFocus); |
456 | if ( !(event->doesRecur() == Recurrence::rNone) ) { | 457 | if ( !(event->doesRecur() == Recurrence::rNone) ) { |
457 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) | 458 | if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) |
458 | return; | 459 | return; |
459 | else | 460 | else |
460 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) | 461 | if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) |
461 | return; | 462 | return; |
462 | } | 463 | } |
463 | 464 | ||
464 | if ( event->categories().contains("Holiday") || | 465 | if ( event->categories().contains("Holiday") || |
465 | event->categories().contains(i18n("Holiday"))) { | 466 | event->categories().contains(i18n("Holiday"))) { |
466 | setHoliday( true ); | 467 | setHoliday( true ); |
467 | if ( mDate.dayOfWeek() == 7 ) | 468 | if ( mDate.dayOfWeek() == 7 ) |
468 | mItemList->setLineWidth( 3 ); | 469 | mItemList->setLineWidth( 3 ); |
469 | } | 470 | } |
470 | QString text; | 471 | QString text; |
471 | if (event->isMultiDay()) { | 472 | if (event->isMultiDay()) { |
472 | QString prefix = "<->"; | 473 | QString prefix = "<->"; |
473 | if ( event->doesRecur() ) { | 474 | if ( event->doesRecur() ) { |
474 | if ( event->recursOn( mDate) ) | 475 | if ( event->recursOn( mDate) ) |
475 | prefix ="->" ; | 476 | prefix ="->" ; |
476 | else { | 477 | else { |
477 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 478 | int days = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
478 | if ( event->recursOn( mDate.addDays( -days)) ) | 479 | if ( event->recursOn( mDate.addDays( -days)) ) |
479 | prefix ="<-" ; | 480 | prefix ="<-" ; |
480 | } | 481 | } |
481 | 482 | ||
482 | } else { | 483 | } else { |
483 | if (mDate == event->dtStart().date()) { | 484 | if (mDate == event->dtStart().date()) { |
484 | prefix ="->" ; | 485 | prefix ="->" ; |
485 | } else if (mDate == event->dtEnd().date()) { | 486 | } else if (mDate == event->dtEnd().date()) { |
486 | prefix ="<-" ; | 487 | prefix ="<-" ; |
487 | } | 488 | } |
488 | } | 489 | } |
489 | if ( !event->doesFloat() ) { | 490 | if ( !event->doesFloat() ) { |
490 | if ( mDate == event->dtStart().date () ) | 491 | if ( mDate == event->dtStart().date () ) |
491 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; | 492 | prefix += KGlobal::locale()->formatTime(event->dtStart().time())+" "; |
492 | else if ( mDate == event->dtEnd().date () ) | 493 | else if ( mDate == event->dtEnd().date () ) |
493 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; | 494 | prefix += KGlobal::locale()->formatTime(event->dtEnd().time())+" "; |
494 | 495 | ||
495 | } | 496 | } |
496 | text = prefix + event->summary(); | 497 | text = prefix + event->summary(); |
497 | mToolTip += text; | 498 | mToolTip += text; |
498 | } else { | 499 | } else { |
499 | if (event->doesFloat()) { | 500 | if (event->doesFloat()) { |
500 | text = event->summary(); | 501 | text = event->summary(); |
501 | mToolTip += text; | 502 | mToolTip += text; |
502 | } | 503 | } |
503 | else { | 504 | else { |
504 | text = KGlobal::locale()->formatTime(event->dtStart().time()); | 505 | text = KGlobal::locale()->formatTime(event->dtStart().time()); |
505 | text += " " + event->summary(); | 506 | text += " " + event->summary(); |
506 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); | 507 | mToolTip += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); |
507 | } | 508 | } |
508 | } | 509 | } |
509 | 510 | ||
510 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); | 511 | MonthViewItem *item = new MonthViewItem( event, mDate, text ); |
511 | QPalette pal; | 512 | QPalette pal; |
512 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 513 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
513 | QStringList categories = event->categories(); | 514 | QStringList categories = event->categories(); |
514 | QString cat = categories.first(); | 515 | QString cat = categories.first(); |
515 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 516 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
516 | pal = getPalette(); | 517 | pal = getPalette(); |
517 | if (cat.isEmpty()) { | 518 | if (cat.isEmpty()) { |
518 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 519 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
519 | } else { | 520 | } else { |
520 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 521 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
521 | } | 522 | } |
522 | 523 | ||
523 | } else { | 524 | } else { |
524 | if (cat.isEmpty()) { | 525 | if (cat.isEmpty()) { |
525 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 526 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
526 | } else { | 527 | } else { |
527 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 528 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
528 | } | 529 | } |
529 | } | 530 | } |
530 | 531 | ||
531 | } else { | 532 | } else { |
532 | pal = mStandardPalette ; | 533 | pal = mStandardPalette ; |
533 | } | 534 | } |
534 | item->setPalette( pal ); | 535 | item->setPalette( pal ); |
535 | item->setRecur( event->recurrence()->doesRecur() ); | 536 | item->setRecur( event->recurrence()->doesRecur() ); |
536 | item->setAlarm( event->isAlarmEnabled() ); | 537 | item->setAlarm( event->isAlarmEnabled() ); |
537 | item->setMoreInfo( event->description().length() > 0 ); | 538 | item->setMoreInfo( event->description().length() > 0 ); |
538 | #ifdef DESKTOP_VERSION | 539 | #ifdef DESKTOP_VERSION |
539 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, | 540 | Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, |
540 | KOPrefs::instance()->email()); | 541 | KOPrefs::instance()->email()); |
541 | if ( me != 0 ) { | 542 | if ( me != 0 ) { |
542 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) | 543 | if ( me->status() == Attendee::NeedsAction && me->RSVP()) |
543 | item->setReply(true); | 544 | item->setReply(true); |
544 | else | 545 | else |
545 | item->setReply(false); | 546 | item->setReply(false); |
546 | } else | 547 | } else |
547 | item->setReply(false); | 548 | item->setReply(false); |
548 | #endif | 549 | #endif |
549 | mItemList->insertItem( item ); | 550 | mItemList->insertItem( item ); |
550 | mToolTip += "\n"; | 551 | mToolTip += "\n"; |
551 | } | 552 | } |
552 | void MonthViewCell::insertTodo(Todo *todo) | 553 | void MonthViewCell::insertTodo(Todo *todo) |
553 | { | 554 | { |
554 | QString text; | 555 | QString text; |
555 | if (todo->hasDueDate()) { | 556 | if (todo->hasDueDate()) { |
556 | if (!todo->doesFloat()) { | 557 | if (!todo->doesFloat()) { |
557 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); | 558 | text += KGlobal::locale()->formatTime(todo->dtDue().time()); |
558 | text += " "; | 559 | text += " "; |
559 | } | 560 | } |
560 | } | 561 | } |
561 | text += i18n("Td: %1").arg(todo->summary()); | 562 | text += i18n("Td: %1").arg(todo->summary()); |
562 | 563 | ||
563 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); | 564 | MonthViewItem *item = new MonthViewItem( todo, mDate, text ); |
564 | //item->setPalette( mStandardPalette ); | 565 | //item->setPalette( mStandardPalette ); |
565 | QPalette pal; | 566 | QPalette pal; |
566 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { | 567 | if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { |
567 | QStringList categories = todo->categories(); | 568 | QStringList categories = todo->categories(); |
568 | QString cat = categories.first(); | 569 | QString cat = categories.first(); |
569 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { | 570 | if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { |
570 | pal = getPalette(); | 571 | pal = getPalette(); |
571 | if (cat.isEmpty()) { | 572 | if (cat.isEmpty()) { |
572 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); | 573 | pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); |
573 | } else { | 574 | } else { |
574 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); | 575 | pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); |
575 | } | 576 | } |
576 | 577 | ||
577 | } else { | 578 | } else { |
578 | if (cat.isEmpty()) { | 579 | if (cat.isEmpty()) { |
579 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); | 580 | pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor); |
580 | } else { | 581 | } else { |
581 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); | 582 | pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); |
582 | } | 583 | } |
583 | } | 584 | } |
584 | 585 | ||
585 | } else { | 586 | } else { |
586 | pal = mStandardPalette ; | 587 | pal = mStandardPalette ; |
587 | } | 588 | } |
588 | item->setPalette( pal ); | 589 | item->setPalette( pal ); |
589 | mItemList->insertItem( item ); | 590 | mItemList->insertItem( item ); |
590 | mToolTip += text+"\n"; | 591 | mToolTip += text+"\n"; |
591 | } | 592 | } |
592 | void MonthViewCell::finishUpdateCell() | 593 | void MonthViewCell::finishUpdateCell() |
593 | { | 594 | { |
594 | #ifdef DESKTOP_VERSION | 595 | #ifdef DESKTOP_VERSION |
595 | if (mToolTip != "") | 596 | if (mToolTip != "") |
596 | QToolTip::add(this,mToolTip,toolTipGroup(),""); | 597 | QToolTip::add(this,mToolTip,toolTipGroup(),""); |
597 | #endif | 598 | #endif |
598 | mItemList->sort(); | 599 | mItemList->sort(); |
599 | //setMyPalette(); | 600 | //setMyPalette(); |
600 | setMyPalette(); | 601 | setMyPalette(); |
601 | QString text; | 602 | QString text; |
602 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; | 603 | bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; |
603 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { | 604 | if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { |
604 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; | 605 | text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; |
605 | mLabel->resize( mLabelBigSize ); | 606 | mLabel->resize( mLabelBigSize ); |
606 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 607 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
607 | } else { | 608 | } else { |
608 | mLabel->resize( mLabelSize ); | 609 | mLabel->resize( mLabelSize ); |
609 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); | 610 | text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); |
610 | } | 611 | } |
611 | 612 | ||
612 | mLabel->setText( text ); | 613 | mLabel->setText( text ); |
613 | resizeEvent( 0 ); | 614 | resizeEvent( 0 ); |
614 | } | 615 | } |
615 | void MonthViewCell::updateCell() | 616 | void MonthViewCell::updateCell() |
616 | { | 617 | { |
617 | if ( !mMonthView->isUpdatePossible() ) | 618 | if ( !mMonthView->isUpdatePossible() ) |
618 | return; | 619 | return; |
619 | startUpdateCell(); | 620 | startUpdateCell(); |
620 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 621 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
621 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); | 622 | QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); |
622 | Event *event; | 623 | Event *event; |
623 | for( event = events.first(); event; event = events.next() ) { // for event | 624 | for( event = events.first(); event; event = events.next() ) { // for event |
624 | insertEvent(event); | 625 | insertEvent(event); |
625 | } | 626 | } |
626 | // insert due todos | 627 | // insert due todos |
627 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); | 628 | QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); |
628 | Todo *todo; | 629 | Todo *todo; |
629 | for(todo = todos.first(); todo; todo = todos.next()) { | 630 | for(todo = todos.first(); todo; todo = todos.next()) { |
630 | insertTodo( todo ); | 631 | insertTodo( todo ); |
631 | } | 632 | } |
632 | finishUpdateCell(); | 633 | finishUpdateCell(); |
633 | // if ( isVisible()) | 634 | // if ( isVisible()) |
634 | //qApp->processEvents(); | 635 | //qApp->processEvents(); |
635 | } | 636 | } |
636 | 637 | ||
637 | void MonthViewCell::updateConfig( bool bigFont ) // = false | 638 | void MonthViewCell::updateConfig( bool bigFont ) // = false |
638 | { | 639 | { |
639 | 640 | ||
640 | if ( bigFont ) { | 641 | if ( bigFont ) { |
641 | QFont fo = KOPrefs::instance()->mMonthViewFont; | 642 | QFont fo = KOPrefs::instance()->mMonthViewFont; |
642 | int ps = fo.pointSize() + 2; | 643 | int ps = fo.pointSize() + 2; |
643 | if ( ps < 18 ) | 644 | if ( ps < 18 ) |
644 | ps += 2; | 645 | ps += 2; |
645 | fo.setPointSize( ps ); | 646 | fo.setPointSize( ps ); |
646 | setFont( fo ); | 647 | setFont( fo ); |
647 | } else | 648 | } else |
648 | setFont( KOPrefs::instance()->mMonthViewFont ); | 649 | setFont( KOPrefs::instance()->mMonthViewFont ); |
649 | 650 | ||
650 | QFontMetrics fm( font() ); | 651 | QFontMetrics fm( font() ); |
651 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); | 652 | mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 ); |
652 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); | 653 | mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 ); |
653 | mHolidayPalette = mStandardPalette; | 654 | mHolidayPalette = mStandardPalette; |
654 | mPrimaryPalette = mStandardPalette; | 655 | mPrimaryPalette = mStandardPalette; |
655 | mNonPrimaryPalette = mStandardPalette; | 656 | mNonPrimaryPalette = mStandardPalette; |
656 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { | 657 | if ( KOPrefs::instance()->mMonthViewUsesDayColors ) { |
657 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); | 658 | mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor ); |
658 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); | 659 | mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor ); |
659 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); | 660 | mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark()); |
660 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); | 661 | mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); |
661 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); | 662 | mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); |
662 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); | 663 | mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); |
663 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); | 664 | mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); |
664 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); | 665 | mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); |
665 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); | 666 | mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); |
666 | } | 667 | } |
667 | //updateCell(); | 668 | //updateCell(); |
668 | } | 669 | } |
669 | 670 | ||
670 | void MonthViewCell::enableScrollBars( bool enabled ) | 671 | void MonthViewCell::enableScrollBars( bool enabled ) |
671 | { | 672 | { |
672 | if ( enabled ) { | 673 | if ( enabled ) { |
673 | mItemList->setVScrollBarMode(QScrollView::Auto); | 674 | mItemList->setVScrollBarMode(QScrollView::Auto); |
674 | mItemList->setHScrollBarMode(QScrollView::Auto); | 675 | mItemList->setHScrollBarMode(QScrollView::Auto); |
675 | } else { | 676 | } else { |
676 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); | 677 | mItemList->setVScrollBarMode(QScrollView::AlwaysOff); |
677 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); | 678 | mItemList->setHScrollBarMode(QScrollView::AlwaysOff); |
678 | } | 679 | } |
679 | } | 680 | } |
680 | 681 | ||
681 | Incidence *MonthViewCell::selectedIncidence() | 682 | Incidence *MonthViewCell::selectedIncidence() |
682 | { | 683 | { |
683 | int index = mItemList->currentItem(); | 684 | int index = mItemList->currentItem(); |
684 | if ( index < 0 ) return 0; | 685 | if ( index < 0 ) return 0; |
685 | 686 | ||
686 | MonthViewItem *item = | 687 | MonthViewItem *item = |
687 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 688 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
688 | 689 | ||
689 | if ( !item ) return 0; | 690 | if ( !item ) return 0; |
690 | 691 | ||
691 | return item->incidence(); | 692 | return item->incidence(); |
692 | } | 693 | } |
693 | 694 | ||
694 | QDate MonthViewCell::selectedIncidenceDate() | 695 | QDate MonthViewCell::selectedIncidenceDate() |
695 | { | 696 | { |
696 | QDate qd; | 697 | QDate qd; |
697 | int index = mItemList->currentItem(); | 698 | int index = mItemList->currentItem(); |
698 | if ( index < 0 ) return qd; | 699 | if ( index < 0 ) return qd; |
699 | 700 | ||
700 | MonthViewItem *item = | 701 | MonthViewItem *item = |
701 | static_cast<MonthViewItem *>( mItemList->item( index ) ); | 702 | static_cast<MonthViewItem *>( mItemList->item( index ) ); |
702 | 703 | ||
703 | if ( !item ) return qd; | 704 | if ( !item ) return qd; |
704 | 705 | ||
705 | return item->incidenceDate(); | 706 | return item->incidenceDate(); |
706 | } | 707 | } |
707 | 708 | ||
708 | void MonthViewCell::deselect() | 709 | void MonthViewCell::deselect() |
709 | { | 710 | { |
710 | mItemList->clearSelection(); | 711 | mItemList->clearSelection(); |
711 | enableScrollBars( false ); | 712 | enableScrollBars( false ); |
712 | // updateCell(); | 713 | // updateCell(); |
713 | } | 714 | } |
714 | void MonthViewCell::select() | 715 | void MonthViewCell::select() |
715 | { | 716 | { |
716 | ;// updateCell(); | 717 | ;// updateCell(); |
717 | } | 718 | } |
718 | 719 | ||
719 | void MonthViewCell::resizeEvent ( QResizeEvent * ) | 720 | void MonthViewCell::resizeEvent ( QResizeEvent * ) |
720 | { | 721 | { |
721 | if ( !mMonthView->isUpdatePossible() ) | 722 | if ( !mMonthView->isUpdatePossible() ) |
722 | return; | 723 | return; |
723 | 724 | ||
724 | int size = height() - mLabel->height() - 2; | 725 | int size = height() - mLabel->height() - 2; |
725 | if ( size > 0 ) | 726 | if ( size > 0 ) |
726 | mItemList->verticalScrollBar()->setMaximumHeight( size ); | 727 | mItemList->verticalScrollBar()->setMaximumHeight( size ); |
727 | size = width() - mLabel->width() -2; | 728 | size = width() - mLabel->width() -2; |
728 | if ( size > 0 ) | 729 | if ( size > 0 ) |
729 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); | 730 | mItemList->horizontalScrollBar()->setMaximumWidth( size ); |
730 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); | 731 | mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); |
731 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); | 732 | //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); |
732 | } | 733 | } |
733 | 734 | ||
734 | void MonthViewCell::defaultAction( QListBoxItem *item ) | 735 | void MonthViewCell::defaultAction( QListBoxItem *item ) |
735 | { | 736 | { |
736 | if ( !item ) return; | 737 | if ( !item ) return; |
737 | 738 | ||
738 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 739 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
739 | Incidence *incidence = eventItem->incidence(); | 740 | Incidence *incidence = eventItem->incidence(); |
740 | if ( incidence ) mMonthView->defaultAction( incidence ); | 741 | if ( incidence ) mMonthView->defaultAction( incidence ); |
741 | } | 742 | } |
742 | void MonthViewCell::showDay() | 743 | void MonthViewCell::showDay() |
743 | { | 744 | { |
744 | emit showDaySignal( date() ); | 745 | emit showDaySignal( date() ); |
745 | } | 746 | } |
746 | void MonthViewCell::newEvent() | 747 | void MonthViewCell::newEvent() |
747 | { | 748 | { |
748 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 749 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
749 | emit newEventSignal( dt ); | 750 | emit newEventSignal( dt ); |
750 | } | 751 | } |
751 | void MonthViewCell::cellClicked( QListBoxItem *item ) | 752 | void MonthViewCell::cellClicked( QListBoxItem *item ) |
752 | { | 753 | { |
753 | static QListBoxItem * lastClicked = 0; | 754 | static QListBoxItem * lastClicked = 0; |
754 | if ( item == 0 ) { | 755 | if ( item == 0 ) { |
755 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); | 756 | QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); |
756 | emit newEventSignal( dt ); | 757 | emit newEventSignal( dt ); |
757 | return; | 758 | return; |
758 | } | 759 | } |
759 | /* | 760 | /* |
760 | if ( lastClicked ) | 761 | if ( lastClicked ) |
761 | if ( ! item ) { | 762 | if ( ! item ) { |
762 | if ( lastClicked->listBox() != item->listBox() ) | 763 | if ( lastClicked->listBox() != item->listBox() ) |
763 | lastClicked->listBox()->clearSelection(); | 764 | lastClicked->listBox()->clearSelection(); |
764 | } | 765 | } |
765 | */ | 766 | */ |
766 | 767 | ||
767 | mMonthView->setSelectedCell( this ); | 768 | mMonthView->setSelectedCell( this ); |
768 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); | 769 | if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); |
769 | select(); | 770 | select(); |
770 | } | 771 | } |
771 | 772 | ||
772 | void MonthViewCell::contextMenu( QListBoxItem *item ) | 773 | void MonthViewCell::contextMenu( QListBoxItem *item ) |
773 | { | 774 | { |
774 | if ( !item ) return; | 775 | if ( !item ) return; |
775 | 776 | ||
776 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); | 777 | MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); |
777 | Incidence *incidence = eventItem->incidence(); | 778 | Incidence *incidence = eventItem->incidence(); |
778 | if ( incidence ) mMonthView->showContextMenu( incidence ); | 779 | if ( incidence ) mMonthView->showContextMenu( incidence ); |
779 | } | 780 | } |
780 | 781 | ||
781 | void MonthViewCell::selection( QListBoxItem *item ) | 782 | void MonthViewCell::selection( QListBoxItem *item ) |
782 | { | 783 | { |
783 | if ( !item ) return; | 784 | if ( !item ) return; |
784 | 785 | ||
785 | mMonthView->setSelectedCell( this ); | 786 | mMonthView->setSelectedCell( this ); |
786 | } | 787 | } |
787 | 788 | ||
788 | 789 | ||
789 | // ******************************************************************************* | 790 | // ******************************************************************************* |
790 | // ******************************************************************************* | 791 | // ******************************************************************************* |
791 | // ******************************************************************************* | 792 | // ******************************************************************************* |
792 | 793 | ||
793 | 794 | ||
794 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 795 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
795 | : KOEventView( calendar, parent, name ), | 796 | : KOEventView( calendar, parent, name ), |
796 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 797 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
797 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 798 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
798 | { | 799 | { |
799 | 800 | ||
800 | clPending = true; | 801 | clPending = true; |
801 | mWidStack = new QWidgetStack( this ); | 802 | mWidStack = new QWidgetStack( this ); |
802 | QHBoxLayout* hb = new QHBoxLayout( this ); | 803 | QHBoxLayout* hb = new QHBoxLayout( this ); |
803 | mMonthView = new QWidget( mWidStack ); | 804 | mMonthView = new QWidget( mWidStack ); |
804 | mWeekView = new QWidget( mWidStack ); | 805 | mWeekView = new QWidget( mWidStack ); |
805 | #if QT_VERSION >= 0x030000 | 806 | #if QT_VERSION >= 0x030000 |
806 | mWidStack->addWidget(mMonthView ); | 807 | mWidStack->addWidget(mMonthView ); |
807 | mWidStack->addWidget(mWeekView ); | 808 | mWidStack->addWidget(mWeekView ); |
808 | #else | 809 | #else |
809 | mWidStack->addWidget( mMonthView, 1 ); | 810 | mWidStack->addWidget( mMonthView, 1 ); |
810 | mWidStack->addWidget( mWeekView , 1 ); | 811 | mWidStack->addWidget( mWeekView , 1 ); |
811 | #endif | 812 | #endif |
812 | hb->addWidget( mWidStack ); | 813 | hb->addWidget( mWidStack ); |
813 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 814 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
814 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 815 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
815 | if ( mShowWeekView ) | 816 | if ( mShowWeekView ) |
816 | mWeekStartsMonday = true; | 817 | mWeekStartsMonday = true; |
817 | updatePossible = false; | 818 | updatePossible = false; |
818 | mCells.setAutoDelete( true ); | 819 | mCells.setAutoDelete( true ); |
819 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 820 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
820 | mDayLabels.resize( mDaysPerWeek ); | 821 | mDayLabels.resize( mDaysPerWeek ); |
821 | mDayLabelsW.resize( mDaysPerWeek ); | 822 | mDayLabelsW.resize( mDaysPerWeek ); |
822 | QFont bfont = font(); | 823 | QFont bfont = font(); |
823 | if ( QApplication::desktop()->width() < 650 ) { | 824 | if ( QApplication::desktop()->width() < 650 ) { |
824 | bfont.setPointSize( bfont.pointSize() - 2 ); | 825 | bfont.setPointSize( bfont.pointSize() - 2 ); |
825 | } | 826 | } |
826 | bfont.setBold( true ); | 827 | bfont.setBold( true ); |
827 | int i; | 828 | int i; |
828 | 829 | ||
829 | for( i = 0; i < mDaysPerWeek; i++ ) { | 830 | for( i = 0; i < mDaysPerWeek; i++ ) { |
830 | QLabel *label = new QLabel( mMonthView ); | 831 | QLabel *label = new QLabel( mMonthView ); |
831 | label->setFont(bfont); | 832 | label->setFont(bfont); |
832 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 833 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
833 | label->setLineWidth(1); | 834 | label->setLineWidth(1); |
834 | label->setAlignment(AlignCenter); | 835 | label->setAlignment(AlignCenter); |
835 | mDayLabels.insert( i, label ); | 836 | mDayLabels.insert( i, label ); |
836 | label = new QLabel( mWeekView ); | 837 | label = new QLabel( mWeekView ); |
837 | label->setFont(bfont); | 838 | label->setFont(bfont); |
838 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 839 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
839 | label->setLineWidth(1); | 840 | label->setLineWidth(1); |
840 | label->setAlignment(AlignCenter); | 841 | label->setAlignment(AlignCenter); |
841 | mDayLabelsW.insert( i, label ); | 842 | mDayLabelsW.insert( i, label ); |
842 | } | 843 | } |
843 | 844 | ||
844 | bfont.setBold( false ); | 845 | bfont.setBold( false ); |
845 | mWeekLabels.resize( mNumWeeks+1 ); | 846 | mWeekLabels.resize( mNumWeeks+1 ); |
846 | mWeekLabelsW.resize( 2 ); | 847 | mWeekLabelsW.resize( 2 ); |
847 | for( i = 0; i < mNumWeeks+1; i++ ) { | 848 | for( i = 0; i < mNumWeeks+1; i++ ) { |
848 | KOWeekButton *label = new KOWeekButton( mMonthView ); | 849 | KOWeekButton *label = new KOWeekButton( mMonthView ); |
849 | label->setFocusPolicy(NoFocus); | 850 | label->setFocusPolicy(NoFocus); |
850 | label->setFont(bfont); | 851 | label->setFont(bfont); |
851 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 852 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
852 | label->setFlat(true); | 853 | label->setFlat(true); |
853 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 854 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
854 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 855 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
855 | //label->setLineWidth(1); | 856 | //label->setLineWidth(1); |
856 | //label->setAlignment(AlignCenter); | 857 | //label->setAlignment(AlignCenter); |
857 | mWeekLabels.insert( i, label ); | 858 | mWeekLabels.insert( i, label ); |
858 | } | 859 | } |
859 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 860 | mWeekLabels[mNumWeeks]->setText( i18n("W")); |
860 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); | 861 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
861 | 862 | ||
862 | for( i = 0; i < 1+1; i++ ) { | 863 | for( i = 0; i < 1+1; i++ ) { |
863 | KOWeekButton *label = new KOWeekButton( mWeekView ); | 864 | KOWeekButton *label = new KOWeekButton( mWeekView ); |
864 | label->setFocusPolicy(NoFocus); | 865 | label->setFocusPolicy(NoFocus); |
865 | label->setFont(bfont); | 866 | label->setFont(bfont); |
866 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); | 867 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
867 | label->setFlat(true); | 868 | label->setFlat(true); |
868 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); | 869 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
869 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 870 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
870 | //label->setLineWidth(1); | 871 | //label->setLineWidth(1); |
871 | //label->setAlignment(AlignCenter); | 872 | //label->setAlignment(AlignCenter); |
872 | mWeekLabelsW.insert( i, label ); | 873 | mWeekLabelsW.insert( i, label ); |
873 | } | 874 | } |
874 | mWeekLabelsW[1]->setText( i18n("W")); | 875 | mWeekLabelsW[1]->setText( i18n("W")); |
875 | 876 | ||
876 | 877 | ||
877 | int row, col; | 878 | int row, col; |
878 | mCells.resize( mNumCells ); | 879 | mCells.resize( mNumCells ); |
879 | for( row = 0; row < mNumWeeks; ++row ) { | 880 | for( row = 0; row < mNumWeeks; ++row ) { |
880 | for( col = 0; col < mDaysPerWeek; ++col ) { | 881 | for( col = 0; col < mDaysPerWeek; ++col ) { |
881 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); | 882 | MonthViewCell *cell = new MonthViewCell( this, mMonthView ); |
882 | mCells.insert( row * mDaysPerWeek + col, cell ); | 883 | mCells.insert( row * mDaysPerWeek + col, cell ); |
883 | 884 | ||
884 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 885 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
885 | SLOT( defaultAction( Incidence * ) ) ); | 886 | SLOT( defaultAction( Incidence * ) ) ); |
886 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 887 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
887 | SIGNAL( newEventSignal( QDateTime ) ) ); | 888 | SIGNAL( newEventSignal( QDateTime ) ) ); |
888 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 889 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
889 | SIGNAL( showDaySignal( QDate ) ) ); | 890 | SIGNAL( showDaySignal( QDate ) ) ); |
890 | } | 891 | } |
891 | } | 892 | } |
892 | mCellsW.resize( mDaysPerWeek ); | 893 | mCellsW.resize( mDaysPerWeek ); |
893 | for( col = 0; col < mDaysPerWeek; ++col ) { | 894 | for( col = 0; col < mDaysPerWeek; ++col ) { |
894 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); | 895 | MonthViewCell *cell = new MonthViewCell( this, mWeekView ); |
895 | mCellsW.insert( col, cell ); | 896 | mCellsW.insert( col, cell ); |
896 | 897 | ||
897 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 898 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
898 | SLOT( defaultAction( Incidence * ) ) ); | 899 | SLOT( defaultAction( Incidence * ) ) ); |
899 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 900 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
900 | SIGNAL( newEventSignal( QDateTime ) ) ); | 901 | SIGNAL( newEventSignal( QDateTime ) ) ); |
901 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 902 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
902 | SIGNAL( showDaySignal( QDate ) ) ); | 903 | SIGNAL( showDaySignal( QDate ) ) ); |
903 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); | 904 | cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont ); |
904 | } | 905 | } |
905 | 906 | ||
906 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); | 907 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
907 | mContextMenu = eventPopup(); | 908 | mContextMenu = eventPopup(); |
908 | // updateConfig(); //useless here | 909 | // updateConfig(); //useless here |
909 | 910 | ||
910 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 911 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
911 | #if 0 | 912 | #if 0 |
912 | mWidStack = new QWidgetStack( this ); | 913 | mWidStack = new QWidgetStack( this ); |
913 | mMonthView = new QWidget( mWidStack ); | 914 | mMonthView = new QWidget( mWidStack ); |
914 | mWeekView = new QWidget( mWidStack ); | 915 | mWeekView = new QWidget( mWidStack ); |
915 | #endif | 916 | #endif |
916 | if ( mShowWeekView ) | 917 | if ( mShowWeekView ) |
917 | mWidStack->raiseWidget( mWeekView ); | 918 | mWidStack->raiseWidget( mWeekView ); |
918 | else | 919 | else |
919 | mWidStack->raiseWidget( mMonthView ); | 920 | mWidStack->raiseWidget( mMonthView ); |
920 | 921 | ||
921 | emit incidenceSelected( 0 ); | 922 | emit incidenceSelected( 0 ); |
922 | } | 923 | } |
923 | 924 | ||
924 | KOMonthView::~KOMonthView() | 925 | KOMonthView::~KOMonthView() |
925 | { | 926 | { |
926 | delete mContextMenu; | 927 | delete mContextMenu; |
927 | } | 928 | } |
928 | 929 | ||
929 | void KOMonthView::selectInternalWeekNum ( int n ) | 930 | void KOMonthView::selectInternalWeekNum ( int n ) |
930 | { | 931 | { |
931 | switchView(); | 932 | switchView(); |
932 | emit selectWeekNum ( n ); | 933 | emit selectWeekNum ( n ); |
933 | } | 934 | } |
934 | 935 | ||
935 | int KOMonthView::currentWeek() | 936 | int KOMonthView::currentWeek() |
936 | { | 937 | { |
937 | if ( mShowWeekView ) | 938 | if ( mShowWeekView ) |
938 | return mWeekLabelsW[0]->getWeekNum(); | 939 | return mWeekLabelsW[0]->getWeekNum(); |
939 | return mWeekLabels[0]->getWeekNum(); | 940 | return mWeekLabels[0]->getWeekNum(); |
940 | } | 941 | } |
941 | void KOMonthView::switchView() | 942 | void KOMonthView::switchView() |
942 | { | 943 | { |
943 | 944 | ||
944 | if ( selectedCell( ) ) | 945 | if ( selectedCell( ) ) |
945 | selectedCell()->deselect(); | 946 | selectedCell()->deselect(); |
946 | mShowWeekView = !mShowWeekView; | 947 | mShowWeekView = !mShowWeekView; |
947 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 948 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
948 | //emit showNavigator( !mShowWeekView ); | 949 | //emit showNavigator( !mShowWeekView ); |
949 | if ( clPending ) { | 950 | if ( clPending ) { |
950 | computeLayout(); | 951 | computeLayout(); |
951 | updateConfig(); | 952 | updateConfig(); |
952 | } | 953 | } |
953 | if ( mShowWeekView ) | 954 | if ( mShowWeekView ) |
954 | mWidStack->raiseWidget( mWeekView ); | 955 | mWidStack->raiseWidget( mWeekView ); |
955 | else | 956 | else |
956 | mWidStack->raiseWidget( mMonthView ); | 957 | mWidStack->raiseWidget( mMonthView ); |
957 | clPending = false; | 958 | clPending = false; |
958 | } | 959 | } |
959 | 960 | ||
960 | int KOMonthView::maxDatesHint() | 961 | int KOMonthView::maxDatesHint() |
961 | { | 962 | { |
962 | return mNumCells; | 963 | return mNumCells; |
963 | } | 964 | } |
964 | 965 | ||
965 | int KOMonthView::currentDateCount() | 966 | int KOMonthView::currentDateCount() |
966 | { | 967 | { |
967 | return mNumCells; | 968 | return mNumCells; |
968 | } | 969 | } |
969 | 970 | ||
970 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 971 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
971 | { | 972 | { |
972 | QPtrList<Incidence> selected; | 973 | QPtrList<Incidence> selected; |
973 | 974 | ||
974 | if ( mSelectedCell ) { | 975 | if ( mSelectedCell ) { |
975 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 976 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
976 | if ( incidence ) selected.append( incidence ); | 977 | if ( incidence ) selected.append( incidence ); |
977 | } | 978 | } |
978 | 979 | ||
979 | return selected; | 980 | return selected; |
980 | } | 981 | } |
981 | 982 | ||
982 | DateList KOMonthView::selectedDates() | 983 | DateList KOMonthView::selectedDates() |
983 | { | 984 | { |
984 | DateList selected; | 985 | DateList selected; |
985 | 986 | ||
986 | if ( mSelectedCell ) { | 987 | if ( mSelectedCell ) { |
987 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 988 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
988 | if ( qd.isValid() ) selected.append( qd ); | 989 | if ( qd.isValid() ) selected.append( qd ); |
989 | } | 990 | } |
990 | 991 | ||
991 | return selected; | 992 | return selected; |
992 | } | 993 | } |
993 | 994 | ||
994 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 995 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
995 | const QDate &td) | 996 | const QDate &td) |
996 | { | 997 | { |
997 | #ifndef KORG_NOPRINTER | 998 | #ifndef KORG_NOPRINTER |
998 | calPrinter->preview(CalPrinter::Month, fd, td); | 999 | calPrinter->preview(CalPrinter::Month, fd, td); |
999 | #endif | 1000 | #endif |
1000 | } | 1001 | } |
1001 | 1002 | ||
1002 | void KOMonthView::updateConfig() | 1003 | void KOMonthView::updateConfig() |
1003 | { | 1004 | { |
1004 | 1005 | ||
1005 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 1006 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
1006 | 1007 | ||
1007 | if ( mShowWeekView ) { | 1008 | if ( mShowWeekView ) { |
1008 | mWeekStartsMonday = true; | 1009 | mWeekStartsMonday = true; |
1009 | } | 1010 | } |
1010 | QFontMetrics fontmetric(mDayLabels[0]->font()); | 1011 | QFontMetrics fontmetric(mDayLabels[0]->font()); |
1011 | mWidthLongDayLabel = 0; | 1012 | mWidthLongDayLabel = 0; |
1012 | 1013 | ||
1013 | for (int i = 0; i < 7; i++) { | 1014 | for (int i = 0; i < 7; i++) { |
1014 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); | 1015 | int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1)); |
1015 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; | 1016 | if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width; |
1016 | } | 1017 | } |
1017 | bool temp = mShowSatSunComp ; | 1018 | bool temp = mShowSatSunComp ; |
1018 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 1019 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
1019 | if ( ! mShowWeekView ) { | 1020 | if ( ! mShowWeekView ) { |
1020 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) | 1021 | if ( temp != KOPrefs::instance()->mMonthViewSatSunTog ) |
1021 | computeLayout(); | 1022 | computeLayout(); |
1022 | } | 1023 | } |
1023 | updateDayLabels(); | 1024 | updateDayLabels(); |
1024 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); | 1025 | //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); |
1025 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; | 1026 | //int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; |
1026 | //resizeEvent( 0 ); | 1027 | //resizeEvent( 0 ); |
1027 | for (uint i = 0; i < mCells.count(); ++i) { | 1028 | for (uint i = 0; i < mCells.count(); ++i) { |
1028 | mCells[i]->updateConfig(); | 1029 | mCells[i]->updateConfig(); |
1029 | } | 1030 | } |
1030 | 1031 | ||
1031 | for (uint i = 0; i < mCellsW.count(); ++i) { | 1032 | for (uint i = 0; i < mCellsW.count(); ++i) { |
1032 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); | 1033 | mCellsW[i]->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont); |
1033 | } | 1034 | } |
1034 | #ifdef DESKTOP_VERSION | 1035 | #ifdef DESKTOP_VERSION |
1035 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); | 1036 | MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); |
1036 | #endif | 1037 | #endif |
1037 | updateView(); | 1038 | updateView(); |
1038 | } | 1039 | } |
1039 | 1040 | ||
1040 | void KOMonthView::updateDayLabels() | 1041 | void KOMonthView::updateDayLabels() |
1041 | { | 1042 | { |
1042 | 1043 | ||
1043 | QPtrVector<QLabel> *mDayLabelsT; | 1044 | QPtrVector<QLabel> *mDayLabelsT; |
1044 | #if 0 | 1045 | #if 0 |
1045 | if (mShowWeekView ) | 1046 | if (mShowWeekView ) |
1046 | mDayLabelsT = &mDayLabelsW; | 1047 | mDayLabelsT = &mDayLabelsW; |
1047 | else | 1048 | else |
1048 | mDayLabelsT = &mDayLabels; | 1049 | mDayLabelsT = &mDayLabels; |
1049 | #endif | 1050 | #endif |
1050 | 1051 | ||
1051 | mDayLabelsT = &mDayLabelsW; | 1052 | mDayLabelsT = &mDayLabelsW; |
1052 | for (int i = 0; i < 7; i++) { | 1053 | for (int i = 0; i < 7; i++) { |
1053 | if (mWeekStartsMonday) { | 1054 | if (mWeekStartsMonday) { |
1054 | bool show = mShortDayLabels; | 1055 | bool show = mShortDayLabels; |
1055 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1056 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1056 | show = true; | 1057 | show = true; |
1057 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1058 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1058 | } else { | 1059 | } else { |
1059 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1060 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
1060 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1061 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
1061 | 1062 | ||
1062 | } | 1063 | } |
1063 | } | 1064 | } |
1064 | mDayLabelsT = &mDayLabels; | 1065 | mDayLabelsT = &mDayLabels; |
1065 | for (int i = 0; i < 7; i++) { | 1066 | for (int i = 0; i < 7; i++) { |
1066 | if (mWeekStartsMonday) { | 1067 | if (mWeekStartsMonday) { |
1067 | bool show = mShortDayLabels; | 1068 | bool show = mShortDayLabels; |
1068 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) | 1069 | if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) |
1069 | show = true; | 1070 | show = true; |
1070 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); | 1071 | (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); |
1071 | } else { | 1072 | } else { |
1072 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); | 1073 | if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels)); |
1073 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); | 1074 | else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels)); |
1074 | 1075 | ||
1075 | } | 1076 | } |
1076 | } | 1077 | } |
1077 | 1078 | ||
1078 | } | 1079 | } |
1079 | 1080 | ||
1080 | void KOMonthView::showDates(const QDate &start, const QDate &) | 1081 | void KOMonthView::showDates(const QDate &start, const QDate &) |
1081 | { | 1082 | { |
1082 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; | 1083 | // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; |
1083 | 1084 | ||
1084 | QPtrVector<MonthViewCell> *cells; | 1085 | QPtrVector<MonthViewCell> *cells; |
1085 | QPtrVector<QLabel> *dayLabels; | 1086 | QPtrVector<QLabel> *dayLabels; |
1086 | QPtrVector<KOWeekButton> *weekLabels; | 1087 | QPtrVector<KOWeekButton> *weekLabels; |
1087 | int weekNum = 6; | 1088 | int weekNum = 6; |
1088 | if ( mShowWeekView ) { | 1089 | if ( mShowWeekView ) { |
1089 | weekNum = 1; | 1090 | weekNum = 1; |
1090 | cells = &mCellsW; | 1091 | cells = &mCellsW; |
1091 | dayLabels = &mDayLabelsW; | 1092 | dayLabels = &mDayLabelsW; |
1092 | weekLabels = &mWeekLabelsW; | 1093 | weekLabels = &mWeekLabelsW; |
1093 | } else { | 1094 | } else { |
1094 | cells = &mCells; | 1095 | cells = &mCells; |
1095 | dayLabels = &mDayLabels; | 1096 | dayLabels = &mDayLabels; |
1096 | weekLabels = &mWeekLabels; | 1097 | weekLabels = &mWeekLabels; |
1097 | } | 1098 | } |
1098 | 1099 | ||
1099 | mStartDate = start; | 1100 | mStartDate = start; |
1100 | 1101 | ||
1101 | int startWeekDay = mWeekStartsMonday ? 1 : 7; | 1102 | int startWeekDay = mWeekStartsMonday ? 1 : 7; |
1102 | 1103 | ||
1103 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { | 1104 | while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { |
1104 | mStartDate = mStartDate.addDays( -1 ); | 1105 | mStartDate = mStartDate.addDays( -1 ); |
1105 | } | 1106 | } |
1106 | 1107 | ||
1107 | bool primary = false; | 1108 | bool primary = false; |
1108 | uint i; | 1109 | uint i; |
1109 | for( i = 0; i < (*cells).size(); ++i ) { | 1110 | for( i = 0; i < (*cells).size(); ++i ) { |
1110 | QDate date = mStartDate.addDays( i ); | 1111 | QDate date = mStartDate.addDays( i ); |
1111 | (*cells)[i]->setDate( date ); | 1112 | (*cells)[i]->setDate( date ); |
1112 | 1113 | ||
1113 | #ifndef KORG_NOPLUGINS | 1114 | #ifndef KORG_NOPLUGINS |
1114 | // add holiday, if present | 1115 | // add holiday, if present |
1115 | QString hstring(KOCore::self()->holiday(date)); | 1116 | QString hstring(KOCore::self()->holiday(date)); |
1116 | (*cells)[i]->setHoliday( hstring ); | 1117 | (*cells)[i]->setHoliday( hstring ); |
1117 | #endif | 1118 | #endif |
1118 | 1119 | ||
1119 | } | 1120 | } |
1120 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); | 1121 | QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); |
1121 | for( i = 0; i < weekNum; ++i ) { | 1122 | for( i = 0; i < weekNum; ++i ) { |
1122 | int wno; | 1123 | int wno; |
1123 | // remember, according to ISO 8601, the first week of the year is the | 1124 | // remember, according to ISO 8601, the first week of the year is the |
1124 | // first week that contains a thursday. Thus we must subtract off 4, | 1125 | // first week that contains a thursday. Thus we must subtract off 4, |
1125 | // not just 1. | 1126 | // not just 1. |
1126 | int dayOfYear = date.dayOfYear(); | 1127 | int dayOfYear = date.dayOfYear(); |
1127 | if (dayOfYear % 7 != 0) | 1128 | if (dayOfYear % 7 != 0) |
1128 | wno = dayOfYear / 7 + 1; | 1129 | wno = dayOfYear / 7 + 1; |
1129 | else | 1130 | else |
1130 | wno =dayOfYear / 7; | 1131 | wno =dayOfYear / 7; |
1131 | (*weekLabels)[i]->setWeekNum( wno ); | 1132 | (*weekLabels)[i]->setWeekNum( wno ); |
1132 | date = date.addDays( 7 ); | 1133 | date = date.addDays( 7 ); |
1133 | } | 1134 | } |
1134 | updateView(); | 1135 | updateView(); |
1135 | } | 1136 | } |
1136 | 1137 | ||
1137 | void KOMonthView::showEvents(QPtrList<Event>) | 1138 | void KOMonthView::showEvents(QPtrList<Event>) |
1138 | { | 1139 | { |
1139 | qDebug("KOMonthView::selectEvents is not implemented yet. "); | 1140 | qDebug("KOMonthView::selectEvents is not implemented yet. "); |
1140 | } | 1141 | } |
1141 | 1142 | ||
1142 | void KOMonthView::changeEventDisplay(Event *, int) | 1143 | void KOMonthView::changeEventDisplay(Event *, int) |
1143 | { | 1144 | { |
1144 | // this should be re-written to be much more efficient, but this | 1145 | // this should be re-written to be much more efficient, but this |
1145 | // quick-and-dirty-hack gets the job done for right now. | 1146 | // quick-and-dirty-hack gets the job done for right now. |
1146 | updateView(); | 1147 | updateView(); |
1147 | } | 1148 | } |
1148 | 1149 | ||
1149 | void KOMonthView::updateView() | 1150 | void KOMonthView::updateView() |
1150 | { | 1151 | { |
1151 | 1152 | ||
1152 | if ( !updatePossible ) | 1153 | if ( !updatePossible ) |
1153 | return; | 1154 | return; |
1154 | //QTime ti; | 1155 | //QTime ti; |
1155 | //ti.start(); | 1156 | //ti.start(); |
1156 | QPtrVector<MonthViewCell> *cells; | 1157 | QPtrVector<MonthViewCell> *cells; |
1157 | if ( mShowWeekView ) { | 1158 | if ( mShowWeekView ) { |
1158 | cells = &mCellsW; | 1159 | cells = &mCellsW; |
1159 | } else { | 1160 | } else { |
1160 | cells = &mCells; | 1161 | cells = &mCells; |
1161 | } | 1162 | } |
1162 | #if 1 | 1163 | #if 1 |
1163 | int i; | 1164 | int i; |
1164 | int timeSpan = (*cells).size()-1; | 1165 | int timeSpan = (*cells).size()-1; |
1165 | if ( KOPrefs::instance()->mMonthViewWeek ) | 1166 | if ( KOPrefs::instance()->mMonthViewWeek ) |
1166 | timeSpan = 6; | 1167 | timeSpan = 6; |
1167 | for( i = 0; i < timeSpan + 1; ++i ) { | 1168 | for( i = 0; i < timeSpan + 1; ++i ) { |
1168 | (*cells)[i]->startUpdateCell(); | 1169 | (*cells)[i]->startUpdateCell(); |
1169 | } | 1170 | } |
1170 | 1171 | ||
1171 | QPtrList<Event> events = calendar()->events(); | 1172 | QPtrList<Event> events = calendar()->events(); |
1172 | Event *event; | 1173 | Event *event; |
1173 | QDateTime dt; | 1174 | QDateTime dt; |
1174 | bool ok; | 1175 | bool ok; |
1175 | QDate endDate = mStartDate.addDays( timeSpan ); | 1176 | QDate endDate = mStartDate.addDays( timeSpan ); |
1176 | for( event = events.first(); event; event = events.next() ) { // for event | 1177 | for( event = events.first(); event; event = events.next() ) { // for event |
1177 | if ( event->doesRecur() ) { | 1178 | if ( event->doesRecur() ) { |
1178 | bool last; | 1179 | bool last; |
1179 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); | 1180 | QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); |
1180 | QDateTime incidenceEnd; | 1181 | QDateTime incidenceEnd; |
1181 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); | 1182 | int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); |
1182 | bool invalid = false; | 1183 | bool invalid = false; |
1183 | while( true ) { | 1184 | while( true ) { |
1184 | if ( incidenceStart.isValid() ) { | 1185 | if ( incidenceStart.isValid() ) { |
1185 | incidenceEnd = incidenceStart.addDays( eventlen ); | 1186 | incidenceEnd = incidenceStart.addDays( eventlen ); |
1186 | int st = incidenceStart.date().daysTo( endDate ); | 1187 | int st = incidenceStart.date().daysTo( endDate ); |
1187 | if ( st >= 0 ) { // start before timeend | 1188 | if ( st >= 0 ) { // start before timeend |
1188 | int end = mStartDate.daysTo( incidenceEnd.date() ); | 1189 | int end = mStartDate.daysTo( incidenceEnd.date() ); |
1189 | if ( end >= 0 ) { // end after timestart --- got one! | 1190 | if ( end >= 0 ) { // end after timestart --- got one! |
1190 | //normalize | 1191 | //normalize |
1191 | st = timeSpan - st; | 1192 | st = timeSpan - st; |
1192 | if ( st < 0 ) st = 0; | 1193 | if ( st < 0 ) st = 0; |
1193 | if ( end > timeSpan ) end = timeSpan; | 1194 | if ( end > timeSpan ) end = timeSpan; |
1194 | int iii; | 1195 | int iii; |
1195 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); | 1196 | //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); |
1196 | for ( iii = st;iii<= end;++iii) | 1197 | for ( iii = st;iii<= end;++iii) |
1197 | (*cells)[iii]->insertEvent( event ); | 1198 | (*cells)[iii]->insertEvent( event ); |
1198 | } | 1199 | } |
1199 | } | 1200 | } |
1200 | } else { | 1201 | } else { |
1201 | if ( invalid ) | 1202 | if ( invalid ) |
1202 | break; | 1203 | break; |
1203 | invalid = true; | 1204 | invalid = true; |
1204 | //qDebug("invalid %s", event->summary().latin1()); | 1205 | //qDebug("invalid %s", event->summary().latin1()); |
1205 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; | 1206 | incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; |
1206 | } | 1207 | } |
1207 | if ( last ) | 1208 | if ( last ) |
1208 | break; | 1209 | break; |
1209 | bool ok; | 1210 | bool ok; |
1210 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); | 1211 | incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); |
1211 | if ( ! ok ) | 1212 | if ( ! ok ) |
1212 | break; | 1213 | break; |
1213 | if ( incidenceStart.date() > endDate ) | 1214 | if ( incidenceStart.date() > endDate ) |
1214 | break; | 1215 | break; |
1215 | } | 1216 | } |
1216 | } else { // no recur | 1217 | } else { // no recur |
1217 | int st = event->dtStart().date().daysTo( endDate ); | 1218 | int st = event->dtStart().date().daysTo( endDate ); |
1218 | if ( st >= 0 ) { // start before timeend | 1219 | if ( st >= 0 ) { // start before timeend |
1219 | int end = mStartDate.daysTo( event->dtEnd().date() ); | 1220 | int end = mStartDate.daysTo( event->dtEnd().date() ); |
1220 | if ( end >= 0 ) { // end after timestart --- got one! | 1221 | if ( end >= 0 ) { // end after timestart --- got one! |
1221 | //normalize | 1222 | //normalize |
1222 | st = timeSpan - st; | 1223 | st = timeSpan - st; |
1223 | if ( st < 0 ) st = 0; | 1224 | if ( st < 0 ) st = 0; |
1224 | if ( end > timeSpan ) end = timeSpan; | 1225 | if ( end > timeSpan ) end = timeSpan; |
1225 | int iii; | 1226 | int iii; |
1226 | for ( iii = st;iii<= end;++iii) | 1227 | for ( iii = st;iii<= end;++iii) |
1227 | (*cells)[iii]->insertEvent( event ); | 1228 | (*cells)[iii]->insertEvent( event ); |
1228 | } | 1229 | } |
1229 | } | 1230 | } |
1230 | } | 1231 | } |
1231 | } | 1232 | } |
1232 | // insert due todos | 1233 | // insert due todos |
1233 | QPtrList<Todo> todos = calendar()->todos( ); | 1234 | QPtrList<Todo> todos = calendar()->todos( ); |
1234 | Todo *todo; | 1235 | Todo *todo; |
1235 | for(todo = todos.first(); todo; todo = todos.next()) { | 1236 | for(todo = todos.first(); todo; todo = todos.next()) { |
1236 | //insertTodo( todo ); | 1237 | //insertTodo( todo ); |
1237 | if ( todo->hasDueDate() ) { | 1238 | if ( todo->hasDueDate() ) { |
1238 | int day = mStartDate.daysTo( todo->dtDue().date() ); | 1239 | int day = mStartDate.daysTo( todo->dtDue().date() ); |
1239 | if ( day >= 0 && day < timeSpan + 1) { | 1240 | if ( day >= 0 && day < timeSpan + 1) { |
1240 | (*cells)[day]->insertTodo( todo ); | 1241 | (*cells)[day]->insertTodo( todo ); |
1241 | } | 1242 | } |
1242 | } | 1243 | } |
1243 | } | 1244 | } |
1244 | 1245 | ||
1245 | for( i = 0; i < timeSpan+1; ++i ) { | 1246 | for( i = 0; i < timeSpan+1; ++i ) { |
1246 | (*cells)[i]->finishUpdateCell(); | 1247 | (*cells)[i]->finishUpdateCell(); |
1247 | } | 1248 | } |
1248 | processSelectionChange(); | 1249 | processSelectionChange(); |
1249 | (*cells)[0]->setFocus(); | 1250 | (*cells)[0]->setFocus(); |
1250 | 1251 | ||
1251 | 1252 | ||
1252 | #else | 1253 | #else |
1253 | // old code | 1254 | // old code |
1254 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); | 1255 | //qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ "); |
1255 | int i; | 1256 | int i; |
1256 | for( i = 0; i < (*cells).count(); ++i ) { | 1257 | for( i = 0; i < (*cells).count(); ++i ) { |
1257 | (*cells)[i]->updateCell(); | 1258 | (*cells)[i]->updateCell(); |
1258 | } | 1259 | } |
1259 | 1260 | ||
1260 | //qDebug("KOMonthView::updateView() "); | 1261 | //qDebug("KOMonthView::updateView() "); |
1261 | processSelectionChange(); | 1262 | processSelectionChange(); |
1262 | // qDebug("---------------------------------------------------------------------+ "); | 1263 | // qDebug("---------------------------------------------------------------------+ "); |
1263 | (*cells)[0]->setFocus(); | 1264 | (*cells)[0]->setFocus(); |
1264 | #endif | 1265 | #endif |
1265 | 1266 | ||
1266 | //qDebug("update time %d ", ti.elapsed()); | 1267 | //qDebug("update time %d ", ti.elapsed()); |
1267 | } | 1268 | } |
1268 | 1269 | ||
1269 | void KOMonthView::resizeEvent(QResizeEvent * e) | 1270 | void KOMonthView::resizeEvent(QResizeEvent * e) |
1270 | { | 1271 | { |
1271 | computeLayout(); | 1272 | computeLayout(); |
1272 | clPending = true; | 1273 | clPending = true; |
1273 | if ( mShowWeekView ) | 1274 | if ( mShowWeekView ) |
1274 | mCellsW[0]->setFocus(); | 1275 | mCellsW[0]->setFocus(); |
1275 | else | 1276 | else |
1276 | mCells[0]->setFocus(); | 1277 | mCells[0]->setFocus(); |
1277 | } | 1278 | } |
1278 | void KOMonthView::computeLayoutWeek() | 1279 | void KOMonthView::computeLayoutWeek() |
1279 | { | 1280 | { |
1280 | 1281 | ||
1281 | int daysToShow; | 1282 | int daysToShow; |
1282 | bool combinedSatSun = false; | 1283 | bool combinedSatSun = false; |
1283 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1284 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1284 | daysToShow = 6; | 1285 | daysToShow = 6; |
1285 | combinedSatSun = true; | 1286 | combinedSatSun = true; |
1286 | } | 1287 | } |
1287 | int tWid = topLevelWidget()->size().width(); | 1288 | int tWid = topLevelWidget()->size().width(); |
1288 | int tHei = topLevelWidget()->size().height(); | 1289 | int tHei = topLevelWidget()->size().height(); |
1289 | 1290 | ||
1290 | int wid = size().width();//e | 1291 | int wid = size().width();//e |
1291 | int hei = size().height()-1; | 1292 | int hei = size().height()-1; |
1292 | 1293 | ||
1293 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1294 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1294 | return; | 1295 | return; |
1295 | 1296 | ||
1296 | if ( wid < hei ) | 1297 | if ( wid < hei ) |
1297 | daysToShow = 2; | 1298 | daysToShow = 2; |
1298 | else | 1299 | else |
1299 | daysToShow = 3; | 1300 | daysToShow = 3; |
1300 | mShowSatSunComp = true; | 1301 | mShowSatSunComp = true; |
1301 | combinedSatSun = true; | 1302 | combinedSatSun = true; |
1302 | 1303 | ||
1303 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1304 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1304 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1305 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1305 | int weeklabelwid = fm.width( "888" ); | 1306 | int weeklabelwid = fm.width( "888" ); |
1306 | wid -= weeklabelwid; | 1307 | wid -= weeklabelwid; |
1307 | 1308 | ||
1308 | int colWid = wid / daysToShow; | 1309 | int colWid = wid / daysToShow; |
1309 | int lastCol = wid - ( colWid*6 ); | 1310 | int lastCol = wid - ( colWid*6 ); |
1310 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); | 1311 | int dayLabelHei = mDayLabelsW[0]->sizeHint().height(); |
1311 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); | 1312 | int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); |
1312 | int colModulo = wid % daysToShow; | 1313 | int colModulo = wid % daysToShow; |
1313 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; | 1314 | int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; |
1314 | //qDebug("rowmod %d ", rowModulo); | 1315 | //qDebug("rowmod %d ", rowModulo); |
1315 | int i; | 1316 | int i; |
1316 | int x,y,w,h; | 1317 | int x,y,w,h; |
1317 | x= 0; | 1318 | x= 0; |
1318 | y= 0; | 1319 | y= 0; |
1319 | w = colWid; | 1320 | w = colWid; |
1320 | h = dayLabelHei ; | 1321 | h = dayLabelHei ; |
1321 | for ( i = 0; i < 7; i++) { | 1322 | for ( i = 0; i < 7; i++) { |
1322 | if ( i && !( i % daysToShow) && i < 6) { | 1323 | if ( i && !( i % daysToShow) && i < 6) { |
1323 | y += hei/(5-daysToShow); | 1324 | y += hei/(5-daysToShow); |
1324 | x = 0; | 1325 | x = 0; |
1325 | w = colWid; | 1326 | w = colWid; |
1326 | } | 1327 | } |
1327 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1328 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1328 | ++w; | 1329 | ++w; |
1329 | } | 1330 | } |
1330 | if ( i >= 5 ) { | 1331 | if ( i >= 5 ) { |
1331 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); | 1332 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w/2+w%2,h); |
1332 | x -= (w/2 ); | 1333 | x -= (w/2 ); |
1333 | } | 1334 | } |
1334 | else | 1335 | else |
1335 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); | 1336 | mDayLabelsW[i]->setGeometry( x+weeklabelwid,y,w,h); |
1336 | x += w; | 1337 | x += w; |
1337 | } | 1338 | } |
1338 | x= 0; | 1339 | x= 0; |
1339 | y= dayLabelHei; | 1340 | y= dayLabelHei; |
1340 | w = colWid; | 1341 | w = colWid; |
1341 | h = cellHei; | 1342 | h = cellHei; |
1342 | for ( i = 0; i < mCellsW.count(); ++i) { | 1343 | for ( i = 0; i < mCellsW.count(); ++i) { |
1343 | if ( i > 6 ) { | 1344 | if ( i > 6 ) { |
1344 | mCellsW[i]->hide(); | 1345 | mCellsW[i]->hide(); |
1345 | continue; | 1346 | continue; |
1346 | } | 1347 | } |
1347 | 1348 | ||
1348 | w = colWid; | 1349 | w = colWid; |
1349 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1350 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1350 | ++w; | 1351 | ++w; |
1351 | } | 1352 | } |
1352 | if ( i == (daysToShow-1-rowModulo)*7) | 1353 | if ( i == (daysToShow-1-rowModulo)*7) |
1353 | ++h; | 1354 | ++h; |
1354 | 1355 | ||
1355 | if ( i >= 5 ) { | 1356 | if ( i >= 5 ) { |
1356 | if ( i ==5 ) { | 1357 | if ( i ==5 ) { |
1357 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1358 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1358 | x -= w ;y += h/2; | 1359 | x -= w ;y += h/2; |
1359 | } else { | 1360 | } else { |
1360 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1361 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1361 | ++w; | 1362 | ++w; |
1362 | } | 1363 | } |
1363 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1364 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1364 | y -= h/2; | 1365 | y -= h/2; |
1365 | } | 1366 | } |
1366 | } else | 1367 | } else |
1367 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1368 | mCellsW[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1368 | 1369 | ||
1369 | 1370 | ||
1370 | x += w; | 1371 | x += w; |
1371 | if ( x + w/2 > wid ) { | 1372 | if ( x + w/2 > wid ) { |
1372 | x = 0; | 1373 | x = 0; |
1373 | y += h+dayLabelHei ; | 1374 | y += h+dayLabelHei ; |
1374 | } | 1375 | } |
1375 | } | 1376 | } |
1376 | y= dayLabelHei; | 1377 | y= dayLabelHei; |
1377 | h = cellHei ; | 1378 | h = cellHei ; |
1378 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1379 | mWeekLabelsW[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1379 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1380 | mWeekLabelsW[1]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1380 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1381 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1381 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1382 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1382 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; | 1383 | mShortDayLabels = mDayLabelsW[0]->width() < mWidthLongDayLabel ; |
1383 | updateDayLabels(); | 1384 | updateDayLabels(); |
1384 | bool forceUpdate = !updatePossible; | 1385 | bool forceUpdate = !updatePossible; |
1385 | updatePossible = true; | 1386 | updatePossible = true; |
1386 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1387 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1387 | if ( forceUpdate ) | 1388 | if ( forceUpdate ) |
1388 | updateView(); | 1389 | updateView(); |
1389 | } | 1390 | } |
1390 | void KOMonthView::computeLayout() | 1391 | void KOMonthView::computeLayout() |
1391 | { | 1392 | { |
1392 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1393 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1393 | // note this only changes the text if the requested size crosses the | 1394 | // note this only changes the text if the requested size crosses the |
1394 | // threshold between big enough to support the full name and not big | 1395 | // threshold between big enough to support the full name and not big |
1395 | // enough. | 1396 | // enough. |
1396 | if ( mShowWeekView ){ | 1397 | if ( mShowWeekView ){ |
1397 | computeLayoutWeek(); | 1398 | computeLayoutWeek(); |
1398 | return; | 1399 | return; |
1399 | } | 1400 | } |
1400 | int daysToShow = 7; | 1401 | int daysToShow = 7; |
1401 | bool combinedSatSun = false; | 1402 | bool combinedSatSun = false; |
1402 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1403 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1403 | daysToShow = 6; | 1404 | daysToShow = 6; |
1404 | combinedSatSun = true; | 1405 | combinedSatSun = true; |
1405 | } | 1406 | } |
1406 | int tWid = topLevelWidget()->size().width(); | 1407 | int tWid = topLevelWidget()->size().width(); |
1407 | int tHei = topLevelWidget()->size().height(); | 1408 | int tHei = topLevelWidget()->size().height(); |
1408 | 1409 | ||
1409 | int wid = size().width();//e | 1410 | int wid = size().width();//e |
1410 | int hei = size().height()-1; | 1411 | int hei = size().height()-1; |
1411 | 1412 | ||
1412 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1413 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1413 | return; | 1414 | return; |
1414 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1415 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1415 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1416 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1416 | int weeklabelwid = fm.width( "888" ); | 1417 | int weeklabelwid = fm.width( "888" ); |
1417 | wid -= weeklabelwid; | 1418 | wid -= weeklabelwid; |
1418 | 1419 | ||
1419 | int colWid = wid / daysToShow; | 1420 | int colWid = wid / daysToShow; |
1420 | int lastCol = wid - ( colWid*6 ); | 1421 | int lastCol = wid - ( colWid*6 ); |
1421 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1422 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1422 | int cellHei = (hei - dayLabelHei) /6; | 1423 | int cellHei = (hei - dayLabelHei) /6; |
1423 | int colModulo = wid % daysToShow; | 1424 | int colModulo = wid % daysToShow; |
1424 | int rowModulo = (hei- dayLabelHei) % 6; | 1425 | int rowModulo = (hei- dayLabelHei) % 6; |
1425 | //qDebug("rowmod %d ", rowModulo); | 1426 | //qDebug("rowmod %d ", rowModulo); |
1426 | int i; | 1427 | int i; |
1427 | int x,y,w,h; | 1428 | int x,y,w,h; |
1428 | x= 0; | 1429 | x= 0; |
1429 | y= 0; | 1430 | y= 0; |
1430 | w = colWid; | 1431 | w = colWid; |
1431 | h = dayLabelHei ; | 1432 | h = dayLabelHei ; |
1432 | for ( i = 0; i < 7; i++) { | 1433 | for ( i = 0; i < 7; i++) { |
1433 | if ( i == daysToShow-colModulo ) | 1434 | if ( i == daysToShow-colModulo ) |
1434 | ++w; | 1435 | ++w; |
1435 | if ( combinedSatSun ) { | 1436 | if ( combinedSatSun ) { |
1436 | if ( i >= daysToShow-1 ) { | 1437 | if ( i >= daysToShow-1 ) { |
1437 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); | 1438 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); |
1438 | x -= w/2 ; | 1439 | x -= w/2 ; |
1439 | } | 1440 | } |
1440 | else | 1441 | else |
1441 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1442 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1442 | } else | 1443 | } else |
1443 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); | 1444 | mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); |
1444 | x += w; | 1445 | x += w; |
1445 | } | 1446 | } |
1446 | x= 0; | 1447 | x= 0; |
1447 | y= dayLabelHei; | 1448 | y= dayLabelHei; |
1448 | w = colWid; | 1449 | w = colWid; |
1449 | h = cellHei ; | 1450 | h = cellHei ; |
1450 | for ( i = 0; i < mCells.count(); ++i) { | 1451 | for ( i = 0; i < mCells.count(); ++i) { |
1451 | w = colWid; | 1452 | w = colWid; |
1452 | if ( ((i) % 7) >= 7-colModulo ) { | 1453 | if ( ((i) % 7) >= 7-colModulo ) { |
1453 | ++w; | 1454 | ++w; |
1454 | } | 1455 | } |
1455 | if ( i == (6-rowModulo)*7) | 1456 | if ( i == (6-rowModulo)*7) |
1456 | ++h; | 1457 | ++h; |
1457 | if ( combinedSatSun ) { | 1458 | if ( combinedSatSun ) { |
1458 | if ( (i)%7 >= daysToShow-1 ) { | 1459 | if ( (i)%7 >= daysToShow-1 ) { |
1459 | if ( (i)%7 == daysToShow-1 ) { | 1460 | if ( (i)%7 == daysToShow-1 ) { |
1460 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1461 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1461 | x -= w ;y += h/2; | 1462 | x -= w ;y += h/2; |
1462 | } else { | 1463 | } else { |
1463 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1464 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1464 | y -= h/2; | 1465 | y -= h/2; |
1465 | } | 1466 | } |
1466 | } else | 1467 | } else |
1467 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1468 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1468 | 1469 | ||
1469 | } | 1470 | } |
1470 | else | 1471 | else |
1471 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1472 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1472 | x += w; | 1473 | x += w; |
1473 | if ( x + w/2 > wid ) { | 1474 | if ( x + w/2 > wid ) { |
1474 | x = 0; | 1475 | x = 0; |
1475 | y += h; | 1476 | y += h; |
1476 | } | 1477 | } |
1477 | } | 1478 | } |
1478 | y= dayLabelHei; | 1479 | y= dayLabelHei; |
1479 | h = cellHei ; | 1480 | h = cellHei ; |
1480 | for ( i = 0; i < 6; i++) { | 1481 | for ( i = 0; i < 6; i++) { |
1481 | if ( i == (6-rowModulo)) | 1482 | if ( i == (6-rowModulo)) |
1482 | ++h; | 1483 | ++h; |
1483 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1484 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1484 | y += h; | 1485 | y += h; |
1485 | } | 1486 | } |
1486 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1487 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1487 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1488 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1488 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1489 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1489 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1490 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1490 | updateDayLabels(); | 1491 | updateDayLabels(); |
1491 | bool forceUpdate = !updatePossible; | 1492 | bool forceUpdate = !updatePossible; |
1492 | updatePossible = true; | 1493 | updatePossible = true; |
1493 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1494 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1494 | if ( forceUpdate ) | 1495 | if ( forceUpdate ) |
1495 | updateView(); | 1496 | updateView(); |
1496 | } | 1497 | } |
1497 | 1498 | ||
1498 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1499 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1499 | { | 1500 | { |
1500 | mContextMenu->showIncidencePopup(incidence); | 1501 | mContextMenu->showIncidencePopup(incidence); |
1501 | /* | 1502 | /* |
1502 | if( incidence && incidence->type() == "Event" ) { | 1503 | if( incidence && incidence->type() == "Event" ) { |
1503 | Event *event = static_cast<Event *>(incidence); | 1504 | Event *event = static_cast<Event *>(incidence); |
1504 | mContextMenu->showEventPopup(event); | 1505 | mContextMenu->showEventPopup(event); |
1505 | } else { | 1506 | } else { |
1506 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1507 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1507 | } | 1508 | } |
1508 | */ | 1509 | */ |
1509 | } | 1510 | } |
1510 | MonthViewCell * KOMonthView::selectedCell( ) | 1511 | MonthViewCell * KOMonthView::selectedCell( ) |
1511 | { | 1512 | { |
1512 | return mSelectedCell; | 1513 | return mSelectedCell; |
1513 | } | 1514 | } |
1514 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1515 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1515 | { | 1516 | { |
1516 | // qDebug("KOMonthView::setSelectedCell "); | 1517 | // qDebug("KOMonthView::setSelectedCell "); |
1517 | if ( mSelectedCell && mSelectedCell != cell ) { | 1518 | if ( mSelectedCell && mSelectedCell != cell ) { |
1518 | MonthViewCell * mvc = mSelectedCell; | 1519 | MonthViewCell * mvc = mSelectedCell; |
1519 | mSelectedCell = cell; | 1520 | mSelectedCell = cell; |
1520 | mvc->deselect(); | 1521 | mvc->deselect(); |
1521 | } else | 1522 | } else |
1522 | mSelectedCell = cell; | 1523 | mSelectedCell = cell; |
1523 | // if ( mSelectedCell ) | 1524 | // if ( mSelectedCell ) |
1524 | // mSelectedCell->select(); | 1525 | // mSelectedCell->select(); |
1525 | if ( !mSelectedCell ) | 1526 | if ( !mSelectedCell ) |
1526 | emit incidenceSelected( 0 ); | 1527 | emit incidenceSelected( 0 ); |
1527 | else | 1528 | else |
1528 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1529 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1529 | } | 1530 | } |
1530 | 1531 | ||
1531 | void KOMonthView::processSelectionChange() | 1532 | void KOMonthView::processSelectionChange() |
1532 | { | 1533 | { |
1533 | QPtrList<Incidence> incidences = selectedIncidences(); | 1534 | QPtrList<Incidence> incidences = selectedIncidences(); |
1534 | if (incidences.count() > 0) { | 1535 | if (incidences.count() > 0) { |
1535 | emit incidenceSelected( incidences.first() ); | 1536 | emit incidenceSelected( incidences.first() ); |
1536 | } else { | 1537 | } else { |
1537 | emit incidenceSelected( 0 ); | 1538 | emit incidenceSelected( 0 ); |
1538 | } | 1539 | } |
1539 | } | 1540 | } |
1540 | 1541 | ||
1541 | void KOMonthView::clearSelection() | 1542 | void KOMonthView::clearSelection() |
1542 | { | 1543 | { |
1543 | if ( mSelectedCell ) { | 1544 | if ( mSelectedCell ) { |
1544 | mSelectedCell->deselect(); | 1545 | mSelectedCell->deselect(); |
1545 | mSelectedCell = 0; | 1546 | mSelectedCell = 0; |
1546 | } | 1547 | } |
1547 | } | 1548 | } |
1548 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) | 1549 | void KOMonthView::keyPressEvent ( QKeyEvent * e ) |
1549 | { | 1550 | { |
1550 | //qDebug("KOMonthView::keyPressEvent "); | 1551 | //qDebug("KOMonthView::keyPressEvent "); |
1551 | switch(e->key()) { | 1552 | switch(e->key()) { |
1552 | case Key_Up: | 1553 | case Key_Up: |
1553 | { | 1554 | { |
1554 | emit prevMonth(); | 1555 | emit prevMonth(); |
1555 | mCells[0]->setFocus(); | 1556 | mCells[0]->setFocus(); |
1556 | } | 1557 | } |
1557 | e->accept(); | 1558 | e->accept(); |
1558 | break; | 1559 | break; |
1559 | case Key_Down: | 1560 | case Key_Down: |
1560 | { | 1561 | { |
1561 | emit nextMonth(); | 1562 | emit nextMonth(); |
1562 | mCells[0]->setFocus(); | 1563 | mCells[0]->setFocus(); |
1563 | 1564 | ||
1564 | } | 1565 | } |
1565 | e->accept(); | 1566 | e->accept(); |
1566 | break; | 1567 | break; |
1567 | case Key_Return: | 1568 | case Key_Return: |
1568 | case Key_Enter: | 1569 | case Key_Enter: |
1569 | { | 1570 | { |
1570 | selectInternalWeekNum ( currentWeek() ); | 1571 | selectInternalWeekNum ( currentWeek() ); |
1571 | } | 1572 | } |
1572 | e->accept(); | 1573 | e->accept(); |
1573 | break; | 1574 | break; |
1574 | default: | 1575 | default: |
1575 | e->ignore(); | 1576 | e->ignore(); |
1576 | break; | 1577 | break; |
1577 | } | 1578 | } |
1578 | } | 1579 | } |