-rw-r--r-- | korganizer/journalentry.cpp | 4 | ||||
-rw-r--r-- | korganizer/koagenda.cpp | 6 | ||||
-rw-r--r-- | korganizer/koagenda.h | 2 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 4 |
4 files changed, 11 insertions, 5 deletions
diff --git a/korganizer/journalentry.cpp b/korganizer/journalentry.cpp index 5fc3f2f..7f6f221 100644 --- a/korganizer/journalentry.cpp +++ b/korganizer/journalentry.cpp | |||
@@ -1,371 +1,373 @@ | |||
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 | #include <qapplication.h> |
37 | 37 | ||
38 | #include <kdebug.h> | 38 | #include <kdebug.h> |
39 | #include <kglobal.h> | 39 | #include <kglobal.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <ktextedit.h> | 41 | #include <ktextedit.h> |
42 | #include <kfiledialog.h> | 42 | #include <kfiledialog.h> |
43 | #include <kmessagebox.h> | 43 | #include <kmessagebox.h> |
44 | #include "koprefs.h" | 44 | #include "koprefs.h" |
45 | #include <klineedit.h> | 45 | #include <klineedit.h> |
46 | #include <kdialog.h> | 46 | #include <kdialog.h> |
47 | #include "kolocationbox.h" | 47 | #include "kolocationbox.h" |
48 | 48 | ||
49 | #include <libkcal/journal.h> | 49 | #include <libkcal/journal.h> |
50 | #include <libkcal/calendarresources.h> | 50 | #include <libkcal/calendarresources.h> |
51 | #include <libkcal/resourcecalendar.h> | 51 | #include <libkcal/resourcecalendar.h> |
52 | #include <kresources/resourceselectdialog.h> | 52 | #include <kresources/resourceselectdialog.h> |
53 | 53 | ||
54 | #include "journalentry.h" | 54 | #include "journalentry.h" |
55 | //#include "journalentry.moc" | 55 | //#include "journalentry.moc" |
56 | #ifndef DESKTOP_VERSION | 56 | #ifndef DESKTOP_VERSION |
57 | #include <qpe/qpeapplication.h> | 57 | #include <qpe/qpeapplication.h> |
58 | #endif | 58 | #endif |
59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : | 59 | JournalEntry::JournalEntry(Calendar *calendar,QWidget *parent) : |
60 | QFrame(parent) | 60 | QFrame(parent) |
61 | { | 61 | { |
62 | 62 | ||
63 | int fac = 5; | 63 | int fac = 5; |
64 | heiHint = QApplication::desktop()->height(); | 64 | heiHint = QApplication::desktop()->height(); |
65 | if ( heiHint > 800 ) | 65 | if ( heiHint > 800 ) |
66 | fac += 2; | 66 | fac += 2; |
67 | heiHint = heiHint / fac; | 67 | heiHint = heiHint / fac; |
68 | 68 | ||
69 | showOnlyMode = false; | 69 | showOnlyMode = false; |
70 | mCalendar = calendar; | 70 | mCalendar = calendar; |
71 | mJournal = 0; | 71 | mJournal = 0; |
72 | visibleMode = true; | 72 | visibleMode = true; |
73 | QHBox * vb = new QHBox ( this ); | 73 | QHBox * vb = new QHBox ( this ); |
74 | QPixmap iconp; | 74 | QPixmap iconp; |
75 | vb->setMargin ( KDialog::marginHint()-1 ); | 75 | vb->setMargin ( KDialog::marginHint()-1 ); |
76 | QPushButton * toggleJournal = new QPushButton( vb ); | 76 | QPushButton * toggleJournal = new QPushButton( vb ); |
77 | iconp = SmallIcon("1updownarrow"); | 77 | iconp = SmallIcon("1updownarrow"); |
78 | toggleJournal->setPixmap (iconp ) ; | 78 | toggleJournal->setPixmap (iconp ) ; |
79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); | 79 | QLabel* textLabel = new QLabel(" "+i18n("Title: "),vb); |
80 | mTitle = new KOLocationBox(TRUE, vb, 30); | 80 | mTitle = new KOLocationBox(TRUE, vb, 30); |
81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 81 | mTitle->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
82 | mCalendarBox = new QComboBox(vb); | 82 | mCalendarBox = new QComboBox(vb); |
83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); | 83 | mCalendarBox->setSizePolicy( QSizePolicy( QSizePolicy::Preferred ,QSizePolicy::Fixed ,FALSE) ); |
84 | #ifndef DESKTOP_VERSION | 84 | #ifndef DESKTOP_VERSION |
85 | mTitle->setSizeLimit( 8 ); | 85 | mTitle->setSizeLimit( 8 ); |
86 | mCalendarBox->setSizeLimit( 8 ); | 86 | mCalendarBox->setSizeLimit( 8 ); |
87 | #endif | 87 | #endif |
88 | vb->setStretchFactor ( mTitle, 8 ); | 88 | vb->setStretchFactor ( mTitle, 8 ); |
89 | int limit = 3; | 89 | int limit = 3; |
90 | if ( QApplication::desktop()->width() < 640 ) | 90 | if ( QApplication::desktop()->width() < 640 ) |
91 | limit = 6; | 91 | limit = 6; |
92 | vb->setStretchFactor ( mCalendarBox, limit ); | 92 | vb->setStretchFactor ( mCalendarBox, limit ); |
93 | //mTitleLabel->setMargin(0); | 93 | //mTitleLabel->setMargin(0); |
94 | //mTitleLabel->setAlignment(AlignCenter); | 94 | //mTitleLabel->setAlignment(AlignCenter); |
95 | QPushButton * loadTemplate = new QPushButton( vb ); | 95 | QPushButton * loadTemplate = new QPushButton( vb ); |
96 | QPushButton * saveTemplate = new QPushButton( vb ); | 96 | QPushButton * saveTemplate = new QPushButton( vb ); |
97 | if ( QApplication::desktop()->width() < 321 ) | 97 | if ( QApplication::desktop()->width() < 321 ) |
98 | iconp = SmallIcon("fileexport16"); | 98 | iconp = SmallIcon("fileexport16"); |
99 | else | 99 | else |
100 | iconp = SmallIcon("fileexport"); | 100 | iconp = SmallIcon("fileexport"); |
101 | saveTemplate->setPixmap (iconp ) ; | 101 | saveTemplate->setPixmap (iconp ) ; |
102 | int size = saveTemplate->sizeHint().height(); | 102 | int size = saveTemplate->sizeHint().height(); |
103 | if ( QApplication::desktop()->width() < 321 ) | 103 | if ( QApplication::desktop()->width() < 321 ) |
104 | iconp = SmallIcon("fileimport16"); | 104 | iconp = SmallIcon("fileimport16"); |
105 | else | 105 | else |
106 | iconp = SmallIcon("fileimport"); | 106 | iconp = SmallIcon("fileimport"); |
107 | loadTemplate->setPixmap (iconp ) ; | 107 | loadTemplate->setPixmap (iconp ) ; |
108 | loadTemplate->setFixedSize( size, size ); | 108 | loadTemplate->setFixedSize( size, size ); |
109 | saveTemplate->setFixedSize( size, size ); | 109 | saveTemplate->setFixedSize( size, size ); |
110 | int widwid = size; | 110 | int widwid = size; |
111 | if ( QApplication::desktop()->width() < 320 ) | 111 | if ( QApplication::desktop()->width() < 320 ) |
112 | widwid = size/2+1; | 112 | widwid = size/2+1; |
113 | toggleJournal->setFixedSize( widwid , size ); | 113 | toggleJournal->setFixedSize( widwid , size ); |
114 | mTitle->setFixedHeight( size+4); | 114 | mTitle->setFixedHeight( size+4); |
115 | mCalendarBox->setFixedHeight( size+4); | 115 | mCalendarBox->setFixedHeight( size+4); |
116 | mEditor = new KTextEdit(this); | 116 | mEditor = new KTextEdit(this); |
117 | #ifndef DESKTOP_VERSION | 117 | #ifndef DESKTOP_VERSION |
118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); | 118 | QPEApplication::setStylusOperation( mEditor, QPEApplication::RightOnHold ); |
119 | #endif | 119 | #endif |
120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); | 120 | mMaxWidDiff = 3*size - 2*frameWidth() - textLabel->sizeHint().width(); |
121 | mDeskWid = QApplication::desktop()->width(); | 121 | mDeskWid = QApplication::desktop()->width(); |
122 | int maxwid = mDeskWid - mMaxWidDiff; | 122 | int maxwid = mDeskWid - mMaxWidDiff; |
123 | if ( QApplication::desktop()->width() < 640 ) { | 123 | if ( QApplication::desktop()->width() < 640 ) { |
124 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 124 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 125 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
126 | } else { | 126 | } else { |
127 | mTitle->setMaximumWidth( (maxwid/4)*3); | 127 | mTitle->setMaximumWidth( (maxwid/4)*3); |
128 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 128 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
129 | } | 129 | } |
130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 130 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); | 131 | mEditor->setWordWrap( KTextEdit::WidgetWidth ); |
132 | QBoxLayout *topLayout = new QVBoxLayout(this); | 132 | QBoxLayout *topLayout = new QVBoxLayout(this); |
133 | topLayout->addWidget(vb); | 133 | topLayout->addWidget(vb); |
134 | topLayout->addWidget(mEditor); | 134 | topLayout->addWidget(mEditor); |
135 | mEditor->installEventFilter(this); | 135 | mEditor->installEventFilter(this); |
136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); | 136 | connect( saveTemplate, SIGNAL( clicked() ), this , SLOT( slotSaveTemplate() ) ); |
137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); | 137 | connect( loadTemplate, SIGNAL( clicked() ), this , SLOT( slotLoadTemplate() ) ); |
138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); | 138 | connect( toggleJournal, SIGNAL( clicked() ), this , SLOT( toggleShowJournal() ) ); |
139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 139 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
140 | mTitle->lineEdit ()->setText(""); | 140 | mTitle->lineEdit ()->setText(""); |
141 | } | 141 | } |
142 | 142 | ||
143 | JournalEntry::~JournalEntry() | 143 | JournalEntry::~JournalEntry() |
144 | { | 144 | { |
145 | //qDebug("JournalEntry::~JournalEntry() "); | 145 | //qDebug("JournalEntry::~JournalEntry() "); |
146 | } | 146 | } |
147 | void JournalEntry::resizeEvent(QResizeEvent* e ) | 147 | void JournalEntry::resizeEvent(QResizeEvent* e ) |
148 | { | 148 | { |
149 | #ifndef DESKTOP_VERSION | 149 | #ifndef DESKTOP_VERSION |
150 | 150 | ||
151 | if ( mDeskWid != QApplication::desktop()->width() ) { | 151 | if ( mDeskWid != QApplication::desktop()->width() ) { |
152 | mDeskWid == QApplication::desktop()->width(); | 152 | mDeskWid == QApplication::desktop()->width(); |
153 | int maxwid = mDeskWid - mMaxWidDiff; | 153 | int maxwid = mDeskWid - mMaxWidDiff; |
154 | if ( QApplication::desktop()->width() < 640 ) { | 154 | if ( QApplication::desktop()->width() < 640 ) { |
155 | mTitle->setMaximumWidth( maxwid/2 +20 ); | 155 | mTitle->setMaximumWidth( maxwid/2 +20 ); |
156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); | 156 | mCalendarBox->setMaximumWidth( maxwid/2 -20); |
157 | } | 157 | } |
158 | else { | 158 | else { |
159 | mTitle->setMaximumWidth( (maxwid/4)*3); | 159 | mTitle->setMaximumWidth( (maxwid/4)*3); |
160 | mCalendarBox->setMaximumWidth( maxwid/2 ); | 160 | mCalendarBox->setMaximumWidth( maxwid/2 ); |
161 | } | 161 | } |
162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); | 162 | //mCalendarBox->setMaximumWidth( maxwid/2 -20 ); |
163 | } | 163 | } |
164 | //setMaximumWidth( QApplication::desktop()->width() ); | 164 | //setMaximumWidth( QApplication::desktop()->width() ); |
165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); | 165 | //qDebug("MAXXX %d ", QApplication::desktop()->width()); |
166 | #endif | 166 | #endif |
167 | QFrame::resizeEvent( e ); | 167 | QFrame::resizeEvent( e ); |
168 | } | 168 | } |
169 | QSize JournalEntry::sizeHint() const | 169 | QSize JournalEntry::sizeHint() const |
170 | { | 170 | { |
171 | return QSize ( 240, heiHint ); | 171 | return QSize ( 240, heiHint ); |
172 | } | 172 | } |
173 | void JournalEntry::slotSaveTemplate() | 173 | void JournalEntry::slotSaveTemplate() |
174 | { | 174 | { |
175 | QString fileName =locateLocal( "templates", "journals" ); | 175 | QString fileName =locateLocal( "templates", "journals" ); |
176 | QDir t_dir; | 176 | QDir t_dir; |
177 | if ( !t_dir.exists(fileName) ) | 177 | if ( !t_dir.exists(fileName) ) |
178 | t_dir.mkdir ( fileName ); | 178 | t_dir.mkdir ( fileName ); |
179 | fileName += "/journal"; | 179 | fileName += "/journal"; |
180 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); | 180 | fileName = KFileDialog::getSaveFileName( fileName , i18n("Save as Journal template"), this ); |
181 | if ( fileName.length() == 0 ) | 181 | if ( fileName.length() == 0 ) |
182 | return; | 182 | return; |
183 | 183 | ||
184 | QFile fileIn( fileName ); | 184 | QFile fileIn( fileName ); |
185 | if (!fileIn.open( IO_WriteOnly ) ) { | 185 | if (!fileIn.open( IO_WriteOnly ) ) { |
186 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") | 186 | KMessageBox::error( this, i18n("Error saving template file\n '%1'.") |
187 | .arg( fileName ) ); | 187 | .arg( fileName ) ); |
188 | return; | 188 | return; |
189 | } | 189 | } |
190 | // QString text; | 190 | // QString text; |
191 | QTextStream tsIn( &fileIn ); | 191 | QTextStream tsIn( &fileIn ); |
192 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 192 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
193 | tsIn << mEditor->text(); | 193 | tsIn << mEditor->text(); |
194 | fileIn.close(); | 194 | fileIn.close(); |
195 | } | 195 | } |
196 | void JournalEntry::slotLoadTemplate() | 196 | void JournalEntry::slotLoadTemplate() |
197 | { | 197 | { |
198 | QString fileName =locateLocal( "templates", "journals" ); | 198 | QString fileName =locateLocal( "templates", "journals" ); |
199 | QDir t_dir; | 199 | QDir t_dir; |
200 | if ( !t_dir.exists(fileName) ) | 200 | if ( !t_dir.exists(fileName) ) |
201 | t_dir.mkdir ( fileName ); | 201 | t_dir.mkdir ( fileName ); |
202 | fileName += "/journal"; | 202 | fileName += "/journal"; |
203 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); | 203 | fileName = KFileDialog::getOpenFileName( fileName , i18n("Insert Journal template"), this ); |
204 | if ( fileName.length() == 0 ) | 204 | if ( fileName.length() == 0 ) |
205 | return; | 205 | return; |
206 | QFile fileIn( fileName ); | 206 | QFile fileIn( fileName ); |
207 | if (!fileIn.open( IO_ReadOnly ) ) { | 207 | if (!fileIn.open( IO_ReadOnly ) ) { |
208 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") | 208 | KMessageBox::error( this, i18n("Error loading template file\n '%1'.") |
209 | .arg( fileName ) ); | 209 | .arg( fileName ) ); |
210 | return; | 210 | return; |
211 | } | 211 | } |
212 | QTextStream tsIn( &fileIn ); | 212 | QTextStream tsIn( &fileIn ); |
213 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); | 213 | tsIn.setCodec( QTextCodec::codecForName("utf8") ); |
214 | QString text = tsIn.read(); | 214 | QString text = tsIn.read(); |
215 | fileIn.close(); | 215 | fileIn.close(); |
216 | int line, col; | 216 | int line, col; |
217 | mEditor->getCursorPosition (& line, & col ); | 217 | mEditor->getCursorPosition (& line, & col ); |
218 | mEditor-> insertAt ( text, line, col, true ); | 218 | mEditor-> insertAt ( text, line, col, true ); |
219 | //mEditor->setIgnoreMark( true ); | 219 | //mEditor->setIgnoreMark( true ); |
220 | } | 220 | } |
221 | void JournalEntry::setDate(const QDate &date) | 221 | void JournalEntry::setDate(const QDate &date) |
222 | { | 222 | { |
223 | showOnlyMode = false; | 223 | showOnlyMode = false; |
224 | writeJournal(); | 224 | writeJournal(); |
225 | mDate = date; | 225 | mDate = date; |
226 | fillCalendar( mCalendar->defaultCalendar() ); | 226 | fillCalendar( mCalendar->defaultCalendar() ); |
227 | } | 227 | } |
228 | void JournalEntry::fillCalendar( int setToID ) | 228 | void JournalEntry::fillCalendar( int setToID ) |
229 | { | 229 | { |
230 | mCalendarBox->clear(); | 230 | mCalendarBox->clear(); |
231 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 231 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
232 | int std = 0; | 232 | int std = 0; |
233 | int count = 0; | 233 | int count = 0; |
234 | while ( kkf ) { | 234 | while ( kkf ) { |
235 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { | 235 | if ( (!kkf->mErrorOnLoad &&! kkf->isReadOnly) || setToID == kkf->mCalNumber ) { |
236 | if ( setToID ) { | 236 | if ( setToID ) { |
237 | if ( kkf->mCalNumber == setToID ) | 237 | if ( kkf->mCalNumber == setToID ) |
238 | std = count; | 238 | std = count; |
239 | } else { | 239 | } else { |
240 | if ( kkf->isStandard ) { | 240 | if ( kkf->isStandard ) { |
241 | std = count; | 241 | std = count; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | ++count; | 244 | ++count; |
245 | mCalendarBox->insertItem( kkf->mName ); | 245 | mCalendarBox->insertItem( kkf->mName ); |
246 | } | 246 | } |
247 | kkf = KOPrefs::instance()->mCalendars.next(); | 247 | kkf = KOPrefs::instance()->mCalendars.next(); |
248 | } | 248 | } |
249 | mCalendarBox->setCurrentItem( std ); | 249 | mCalendarBox->setCurrentItem( std ); |
250 | } | 250 | } |
251 | 251 | ||
252 | void JournalEntry::toggleShowJournal() | 252 | void JournalEntry::toggleShowJournal() |
253 | { | 253 | { |
254 | if ( mEditor->text().isEmpty() && mTitle->currentText ().isEmpty() ) | ||
255 | return; | ||
254 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) | 256 | if (!mEditor->text().isEmpty() || !mTitle->currentText ().isEmpty()) |
255 | flushEntry(); | 257 | flushEntry(); |
256 | if ( showOnlyMode ) | 258 | if ( showOnlyMode ) |
257 | emit showJournalOnly( 0 ); | 259 | emit showJournalOnly( 0 ); |
258 | else { | 260 | else { |
259 | // we have to protect mJournal from deleting if mJournal has empty text | 261 | // we have to protect mJournal from deleting if mJournal has empty text |
260 | visibleMode = false; // set to true via :setShowOnly() | 262 | visibleMode = false; // set to true via :setShowOnly() |
261 | emit showJournalOnly( mJournal ); | 263 | emit showJournalOnly( mJournal ); |
262 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); | 264 | //QTimer::singleShot( 0, this, SLOT( setVisibleOn() ) ); |
263 | } | 265 | } |
264 | } | 266 | } |
265 | void JournalEntry::setVisibleOn() | 267 | void JournalEntry::setVisibleOn() |
266 | { | 268 | { |
267 | visibleMode = true; | 269 | visibleMode = true; |
268 | } | 270 | } |
269 | void JournalEntry::setShowOnly() | 271 | void JournalEntry::setShowOnly() |
270 | { | 272 | { |
271 | showOnlyMode = true; | 273 | showOnlyMode = true; |
272 | if ( mTitle->currentText().isEmpty() ) | 274 | if ( mTitle->currentText().isEmpty() ) |
273 | mTitle->setFocus(); | 275 | mTitle->setFocus(); |
274 | else | 276 | else |
275 | mEditor->setFocus(); | 277 | mEditor->setFocus(); |
276 | } | 278 | } |
277 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) | 279 | void JournalEntry::setJournal(Journal *journal, bool saveJournal ) |
278 | { | 280 | { |
279 | if ( saveJournal ) | 281 | if ( saveJournal ) |
280 | writeJournal(); | 282 | writeJournal(); |
281 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 283 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
282 | 284 | ||
283 | mJournal = journal; | 285 | mJournal = journal; |
284 | if ( journal->isReadOnly() ) | 286 | if ( journal->isReadOnly() ) |
285 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); | 287 | mTitle->lineEdit ()->setText(mJournal->summary()+" ("+i18n("readonly")+")"); |
286 | else | 288 | else |
287 | mTitle->lineEdit ()->setText(mJournal->summary()); | 289 | mTitle->lineEdit ()->setText(mJournal->summary()); |
288 | mEditor->setText(mJournal->description()); | 290 | mEditor->setText(mJournal->description()); |
289 | mTitle->setEnabled (!journal->isReadOnly() ); | 291 | mTitle->setEnabled (!journal->isReadOnly() ); |
290 | mEditor->setReadOnly ( journal->isReadOnly() ); | 292 | mEditor->setReadOnly ( journal->isReadOnly() ); |
291 | mCalendarBox->setEnabled (!journal->isReadOnly() ); | 293 | mCalendarBox->setEnabled (!journal->isReadOnly() ); |
292 | fillCalendar( mJournal->calID() ); | 294 | fillCalendar( mJournal->calID() ); |
293 | } | 295 | } |
294 | 296 | ||
295 | Journal *JournalEntry::journal() const | 297 | Journal *JournalEntry::journal() const |
296 | { | 298 | { |
297 | return mJournal; | 299 | return mJournal; |
298 | } | 300 | } |
299 | 301 | ||
300 | 302 | ||
301 | void JournalEntry::clear() | 303 | void JournalEntry::clear() |
302 | { | 304 | { |
303 | mJournal = 0; | 305 | mJournal = 0; |
304 | mEditor->setText(""); | 306 | mEditor->setText(""); |
305 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); | 307 | mTitle->load( KOLocationBox::SUMMARYJOURNAL ); |
306 | mTitle->lineEdit ()->setText(""); | 308 | mTitle->lineEdit ()->setText(""); |
307 | } | 309 | } |
308 | 310 | ||
309 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) | 311 | bool JournalEntry::eventFilter( QObject *o, QEvent *e ) |
310 | { | 312 | { |
311 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; | 313 | // kdDebug() << "JournalEntry::event received " << e->type() << endl; |
312 | 314 | ||
313 | if ( e->type() == QEvent::FocusOut ) { | 315 | if ( e->type() == QEvent::FocusOut ) { |
314 | writeJournal(); | 316 | writeJournal(); |
315 | } | 317 | } |
316 | if ( e->type() == QEvent::KeyPress ) { | 318 | if ( e->type() == QEvent::KeyPress ) { |
317 | QKeyEvent * k = (QKeyEvent *) e; | 319 | QKeyEvent * k = (QKeyEvent *) e; |
318 | if ( k->state() == Qt::ControlButton ) { | 320 | if ( k->state() == Qt::ControlButton ) { |
319 | k->ignore(); | 321 | k->ignore(); |
320 | //return true; | 322 | //return true; |
321 | } | 323 | } |
322 | } | 324 | } |
323 | 325 | ||
324 | return QFrame::eventFilter( o, e ); // standard event processing | 326 | return QFrame::eventFilter( o, e ); // standard event processing |
325 | } | 327 | } |
326 | 328 | ||
327 | void JournalEntry::writeJournal() | 329 | void JournalEntry::writeJournal() |
328 | { | 330 | { |
329 | if ( !visibleMode ) return; | 331 | if ( !visibleMode ) return; |
330 | if ( !mTitle->isEnabled() ) return; | 332 | if ( !mTitle->isEnabled() ) return; |
331 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { | 333 | if (mEditor->text().isEmpty() && mTitle->currentText().isEmpty()) { |
332 | if ( mJournal ) { | 334 | if ( mJournal ) { |
333 | Journal* j = mJournal; | 335 | Journal* j = mJournal; |
334 | mJournal = 0; | 336 | mJournal = 0; |
335 | bool conf = KOPrefs::instance()->mConfirm; | 337 | bool conf = KOPrefs::instance()->mConfirm; |
336 | KOPrefs::instance()->mConfirm = false; | 338 | KOPrefs::instance()->mConfirm = false; |
337 | emit deleteJournal(j); | 339 | emit deleteJournal(j); |
338 | KOPrefs::instance()->mConfirm = conf; | 340 | KOPrefs::instance()->mConfirm = conf; |
339 | } | 341 | } |
340 | return; | 342 | return; |
341 | } | 343 | } |
342 | 344 | ||
343 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; | 345 | // kdDebug() << "JournalEntry::writeJournal()..." << endl; |
344 | 346 | ||
345 | if (!mJournal) { | 347 | if (!mJournal) { |
346 | mJournal = new Journal; | 348 | mJournal = new Journal; |
347 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); | 349 | mJournal->setDtStart(QDateTime(mDate,QTime(0,0,0))); |
348 | mCalendar->addJournal(mJournal); | 350 | mCalendar->addJournal(mJournal); |
349 | } | 351 | } |
350 | if ( mJournal->description() != mEditor->text() ) { | 352 | if ( mJournal->description() != mEditor->text() ) { |
351 | mJournal->setDescription(mEditor->text()); | 353 | mJournal->setDescription(mEditor->text()); |
352 | } | 354 | } |
353 | if ( mJournal->summary() != mTitle->currentText() ) { | 355 | if ( mJournal->summary() != mTitle->currentText() ) { |
354 | mJournal->setSummary(mTitle->currentText()); | 356 | mJournal->setSummary(mTitle->currentText()); |
355 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); | 357 | mTitle->save(KOLocationBox::SUMMARYJOURNAL); |
356 | } | 358 | } |
357 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); | 359 | int id = KOPrefs::instance()->getCalendarID( mCalendarBox->currentText() ); |
358 | if ( mJournal->calID() != id ) { | 360 | if ( mJournal->calID() != id ) { |
359 | mJournal->setCalID( id ); | 361 | mJournal->setCalID( id ); |
360 | } | 362 | } |
361 | } | 363 | } |
362 | 364 | ||
363 | void JournalEntry::flushEntry() | 365 | void JournalEntry::flushEntry() |
364 | { | 366 | { |
365 | writeJournal(); | 367 | writeJournal(); |
366 | } | 368 | } |
367 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) | 369 | void JournalEntry::keyPressEvent ( QKeyEvent * e ) |
368 | { | 370 | { |
369 | e->ignore(); | 371 | e->ignore(); |
370 | 372 | ||
371 | } | 373 | } |
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp index c738f7e..7e9fa71 100644 --- a/korganizer/koagenda.cpp +++ b/korganizer/koagenda.cpp | |||
@@ -1,758 +1,762 @@ | |||
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 | Marcus Bains line. | 5 | Marcus Bains line. |
6 | Copyright (c) 2001 Ali Rahimi | 6 | Copyright (c) 2001 Ali Rahimi |
7 | 7 | ||
8 | This program is free software; you can redistribute it and/or modify | 8 | This program is free software; you can redistribute it and/or modify |
9 | it under the terms of the GNU General Public License as published by | 9 | it under the terms of the GNU General Public License as published by |
10 | the Free Software Foundation; either version 2 of the License, or | 10 | the Free Software Foundation; either version 2 of the License, or |
11 | (at your option) any later version. | 11 | (at your option) any later version. |
12 | 12 | ||
13 | This program is distributed in the hope that it will be useful, | 13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. | 16 | GNU General Public License for more details. |
17 | 17 | ||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software | 19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 | 21 | ||
22 | As a special exception, permission is given to link this program | 22 | As a special exception, permission is given to link this program |
23 | with any edition of Qt, and distribute the resulting executable, | 23 | with any edition of Qt, and distribute the resulting executable, |
24 | without including the source code for Qt in the source distribution. | 24 | without including the source code for Qt in the source distribution. |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #ifndef _WIN32_ | 27 | #ifndef _WIN32_ |
28 | #define protected public | 28 | #define protected public |
29 | #include <qwidget.h> | 29 | #include <qwidget.h> |
30 | #undef protected | 30 | #undef protected |
31 | #endif | 31 | #endif |
32 | #include <qintdict.h> | 32 | #include <qintdict.h> |
33 | #include <qdatetime.h> | 33 | #include <qdatetime.h> |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #include <qpopupmenu.h> | 35 | #include <qpopupmenu.h> |
36 | #include <qcursor.h> | 36 | #include <qcursor.h> |
37 | #include <qpainter.h> | 37 | #include <qpainter.h> |
38 | 38 | ||
39 | #include <kdebug.h> | 39 | #include <kdebug.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kiconloader.h> | 41 | #include <kiconloader.h> |
42 | #include <kglobal.h> | 42 | #include <kglobal.h> |
43 | 43 | ||
44 | #include "koagendaitem.h" | 44 | #include "koagendaitem.h" |
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "koglobals.h" | 46 | #include "koglobals.h" |
47 | 47 | ||
48 | #include "koagenda.h" | 48 | #include "koagenda.h" |
49 | 49 | ||
50 | #include <libkcal/event.h> | 50 | #include <libkcal/event.h> |
51 | #include <libkcal/todo.h> | 51 | #include <libkcal/todo.h> |
52 | 52 | ||
53 | #ifndef DESKTOP_VERSION | 53 | #ifndef DESKTOP_VERSION |
54 | #include <qpe/qpeapplication.h> | 54 | #include <qpe/qpeapplication.h> |
55 | #endif | 55 | #endif |
56 | 56 | ||
57 | //extern bool globalFlagBlockPainting; | 57 | //extern bool globalFlagBlockPainting; |
58 | extern int globalFlagBlockAgenda; | 58 | extern int globalFlagBlockAgenda; |
59 | extern int globalFlagBlockAgendaItemPaint; | 59 | extern int globalFlagBlockAgendaItemPaint; |
60 | extern int globalFlagBlockAgendaItemUpdate; | 60 | extern int globalFlagBlockAgendaItemUpdate; |
61 | extern int globalFlagBlockStartup; | 61 | extern int globalFlagBlockStartup; |
62 | 62 | ||
63 | 63 | ||
64 | //////////////////////////////////////////////////////////////////////////// | 64 | //////////////////////////////////////////////////////////////////////////// |
65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) | 65 | MarcusBains::MarcusBains(KOAgenda *_agenda,const char *name) |
66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) | 66 | : QFrame(_agenda->viewport(),name), agenda(_agenda) |
67 | { | 67 | { |
68 | setLineWidth(0); | 68 | setLineWidth(0); |
69 | setMargin(0); | 69 | setMargin(0); |
70 | setBackgroundColor(Qt::red); | 70 | setBackgroundColor(Qt::red); |
71 | minutes = new QTimer(this); | 71 | minutes = new QTimer(this); |
72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); | 72 | connect(minutes, SIGNAL(timeout()), this, SLOT(updateLoc())); |
73 | minutes->start(0, true); | 73 | minutes->start(0, true); |
74 | mTimeBox = new QLabel(this); | 74 | mTimeBox = new QLabel(this); |
75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); | 75 | mTimeBox->setAlignment(Qt::AlignRight | Qt::AlignBottom); |
76 | QPalette pal = mTimeBox->palette(); | 76 | QPalette pal = mTimeBox->palette(); |
77 | pal.setColor(QColorGroup::Foreground, Qt::red); | 77 | pal.setColor(QColorGroup::Foreground, Qt::red); |
78 | mTimeBox->setPalette(pal); | 78 | mTimeBox->setPalette(pal); |
79 | //mTimeBox->setAutoMask(true); | 79 | //mTimeBox->setAutoMask(true); |
80 | 80 | ||
81 | agenda->addChild(mTimeBox); | 81 | agenda->addChild(mTimeBox); |
82 | 82 | ||
83 | oldToday = -1; | 83 | oldToday = -1; |
84 | } | 84 | } |
85 | 85 | ||
86 | MarcusBains::~MarcusBains() | 86 | MarcusBains::~MarcusBains() |
87 | { | 87 | { |
88 | //delete minutes; | 88 | //delete minutes; |
89 | } | 89 | } |
90 | 90 | void MarcusBains::hideMe() | |
91 | { | ||
92 | hide(); mTimeBox->hide(); | ||
93 | } | ||
91 | int MarcusBains::todayColumn() | 94 | int MarcusBains::todayColumn() |
92 | { | 95 | { |
93 | QDate currentDate = QDate::currentDate(); | 96 | QDate currentDate = QDate::currentDate(); |
94 | 97 | ||
95 | DateList dateList = agenda->dateList(); | 98 | DateList dateList = agenda->dateList(); |
96 | DateList::ConstIterator it; | 99 | DateList::ConstIterator it; |
97 | int col = 0; | 100 | int col = 0; |
98 | for(it = dateList.begin(); it != dateList.end(); ++it) { | 101 | for(it = dateList.begin(); it != dateList.end(); ++it) { |
99 | if((*it) == currentDate) | 102 | if((*it) == currentDate) |
100 | return KOGlobals::self()->reverseLayout() ? | 103 | return KOGlobals::self()->reverseLayout() ? |
101 | agenda->columns() - 1 - col : col; | 104 | agenda->columns() - 1 - col : col; |
102 | ++col; | 105 | ++col; |
103 | } | 106 | } |
104 | 107 | ||
105 | return -1; | 108 | return -1; |
106 | } | 109 | } |
107 | void MarcusBains::updateLoc() | 110 | void MarcusBains::updateLoc() |
108 | { | 111 | { |
109 | updateLocation(); | 112 | updateLocation(); |
110 | } | 113 | } |
111 | void MarcusBains::updateLocation(bool recalculate) | 114 | void MarcusBains::updateLocation(bool recalculate) |
112 | { | 115 | { |
113 | 116 | ||
114 | QTime tim = QTime::currentTime(); | 117 | QTime tim = QTime::currentTime(); |
115 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); | 118 | //qDebug(" MarcusBains::updateLocation %s ", tim.toString().latin1()); |
116 | if((tim.hour() == 0) && (oldTime.hour()==23)) | 119 | if((tim.hour() == 0) && (oldTime.hour()==23)) |
117 | recalculate = true; | 120 | recalculate = true; |
118 | 121 | ||
119 | int mins = tim.hour()*60 + tim.minute(); | 122 | int mins = tim.hour()*60 + tim.minute(); |
120 | int minutesPerCell = 24 * 60 / agenda->rows(); | 123 | int minutesPerCell = 24 * 60 / agenda->rows(); |
121 | int y = mins*agenda->gridSpacingY()/minutesPerCell; | 124 | int y = mins*agenda->gridSpacingY()/minutesPerCell; |
122 | int today = recalculate ? todayColumn() : oldToday; | 125 | int today = recalculate ? todayColumn() : oldToday; |
123 | int x = agenda->gridSpacingX()*today; | 126 | int x = agenda->gridSpacingX()*today; |
124 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); | 127 | bool disabled = !(KOPrefs::instance()->mMarcusBainsEnabled); |
125 | 128 | ||
126 | oldTime = tim; | 129 | oldTime = tim; |
127 | oldToday = today; | 130 | oldToday = today; |
128 | 131 | ||
129 | if(disabled || (today<0)) { | 132 | if(disabled || (today<0)) { |
130 | hide(); mTimeBox->hide(); | 133 | hide(); mTimeBox->hide(); |
131 | return; | 134 | return; |
132 | } else { | 135 | } else { |
133 | show(); mTimeBox->show(); | 136 | show(); mTimeBox->show(); |
134 | } | 137 | } |
135 | 138 | ||
136 | if(recalculate) | 139 | if(recalculate) |
137 | setFixedSize(agenda->gridSpacingX(),1); | 140 | setFixedSize(agenda->gridSpacingX(),1); |
138 | agenda->moveChild(this, x, y); | 141 | agenda->moveChild(this, x, y); |
139 | raise(); | 142 | raise(); |
140 | 143 | ||
141 | if(recalculate) | 144 | if(recalculate) |
142 | //mTimeBox->setFont(QFont("helvetica",10)); | 145 | //mTimeBox->setFont(QFont("helvetica",10)); |
143 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); | 146 | mTimeBox->setFont(KOPrefs::instance()->mMarcusBainsFont); |
144 | 147 | ||
145 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); | 148 | mTimeBox->setText(KGlobal::locale()->formatTime(tim, KOPrefs::instance()->mMarcusBainsShowSeconds)); |
146 | mTimeBox->adjustSize(); | 149 | mTimeBox->adjustSize(); |
147 | // the -2 below is there because there is a bug in this program | 150 | // the -2 below is there because there is a bug in this program |
148 | // somewhere, where the last column of this widget is a few pixels | 151 | // somewhere, where the last column of this widget is a few pixels |
149 | // narrower than the other columns. | 152 | // narrower than the other columns. |
150 | int offs = (today==agenda->columns()-1) ? -4 : 0; | 153 | int offs = (today==agenda->columns()-1) ? -4 : 0; |
151 | agenda->moveChild(mTimeBox, | 154 | agenda->moveChild(mTimeBox, |
152 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, | 155 | x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, |
153 | y-mTimeBox->height()); | 156 | y-mTimeBox->height()); |
154 | mTimeBox->raise(); | 157 | mTimeBox->raise(); |
155 | //mTimeBox->setAutoMask(true); | 158 | //mTimeBox->setAutoMask(true); |
156 | int secs = QTime::currentTime().second(); | 159 | int secs = QTime::currentTime().second(); |
157 | minutes->start( (60 - secs +1)*1000 ,true); | 160 | minutes->start( (60 - secs +1)*1000 ,true); |
158 | } | 161 | } |
159 | 162 | ||
160 | 163 | ||
161 | //////////////////////////////////////////////////////////////////////////// | 164 | //////////////////////////////////////////////////////////////////////////// |
162 | 165 | ||
163 | 166 | ||
164 | /* | 167 | /* |
165 | Create an agenda widget with rows rows and columns columns. | 168 | Create an agenda widget with rows rows and columns columns. |
166 | */ | 169 | */ |
167 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, | 170 | KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, |
168 | const char *name,WFlags f) : | 171 | const char *name,WFlags f) : |
169 | QScrollView(parent,name,f) | 172 | QScrollView(parent,name,f) |
170 | { | 173 | { |
171 | 174 | ||
172 | mAllAgendaPopup = 0; | 175 | mAllAgendaPopup = 0; |
173 | mColumns = columns; | 176 | mColumns = columns; |
174 | mRows = rows; | 177 | mRows = rows; |
175 | mGridSpacingY = rowSize; | 178 | mGridSpacingY = rowSize; |
176 | mAllDayMode = false; | 179 | mAllDayMode = false; |
177 | #ifndef DESKTOP_VERSION | 180 | #ifndef DESKTOP_VERSION |
178 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 181 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
179 | #endif | 182 | #endif |
180 | mHolidayMask = 0; | 183 | mHolidayMask = 0; |
181 | init(); | 184 | init(); |
182 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); | 185 | connect ( this, SIGNAL (contentsMoving ( int , int ) ), this, SLOT ( slotContentMove(int,int)) ); |
183 | } | 186 | } |
184 | 187 | ||
185 | /* | 188 | /* |
186 | Create an agenda widget with columns columns and one row. This is used for | 189 | Create an agenda widget with columns columns and one row. This is used for |
187 | all-day events. | 190 | all-day events. |
188 | */ | 191 | */ |
189 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : | 192 | KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : |
190 | QScrollView(parent,name,f) | 193 | QScrollView(parent,name,f) |
191 | { | 194 | { |
192 | mAllAgendaPopup = 0; | 195 | mAllAgendaPopup = 0; |
193 | blockResize = false; | 196 | blockResize = false; |
194 | mColumns = columns; | 197 | mColumns = columns; |
195 | mRows = 1; | 198 | mRows = 1; |
196 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); | 199 | //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); |
197 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; | 200 | mGridSpacingY = KOPrefs::instance()->mAllDaySize; |
198 | mAllDayMode = true; | 201 | mAllDayMode = true; |
199 | #ifndef DESKTOP_VERSION | 202 | #ifndef DESKTOP_VERSION |
200 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); | 203 | //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); |
201 | #endif | 204 | #endif |
202 | mHolidayMask = 0; | 205 | mHolidayMask = 0; |
203 | init(); | 206 | init(); |
204 | } | 207 | } |
205 | 208 | ||
206 | 209 | ||
207 | KOAgenda::~KOAgenda() | 210 | KOAgenda::~KOAgenda() |
208 | { | 211 | { |
209 | if(mMarcusBains) delete mMarcusBains; | 212 | if(mMarcusBains) delete mMarcusBains; |
210 | 213 | ||
211 | } | 214 | } |
212 | 215 | ||
213 | Incidence *KOAgenda::selectedIncidence() const | 216 | Incidence *KOAgenda::selectedIncidence() const |
214 | { | 217 | { |
215 | return (mSelectedItem ? mSelectedItem->incidence() : 0); | 218 | return (mSelectedItem ? mSelectedItem->incidence() : 0); |
216 | } | 219 | } |
217 | 220 | ||
218 | 221 | ||
219 | QDate KOAgenda::selectedIncidenceDate() const | 222 | QDate KOAgenda::selectedIncidenceDate() const |
220 | { | 223 | { |
221 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); | 224 | return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); |
222 | } | 225 | } |
223 | 226 | ||
224 | 227 | ||
225 | void KOAgenda::init() | 228 | void KOAgenda::init() |
226 | { | 229 | { |
227 | mPopupTimer = new QTimer(this); | 230 | mPopupTimer = new QTimer(this); |
228 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); | 231 | connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); |
229 | 232 | ||
230 | mNewItemPopup = new QPopupMenu( this ); | 233 | mNewItemPopup = new QPopupMenu( this ); |
231 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); | 234 | connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); |
232 | QString pathString = ""; | 235 | QString pathString = ""; |
233 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { | 236 | if ( !KOPrefs::instance()->mToolBarMiniIcons ) { |
234 | if ( QApplication::desktop()->width() < 480 ) | 237 | if ( QApplication::desktop()->width() < 480 ) |
235 | pathString += "icons16/"; | 238 | pathString += "icons16/"; |
236 | } else | 239 | } else |
237 | pathString += "iconsmini/"; | 240 | pathString += "iconsmini/"; |
238 | 241 | ||
239 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); | 242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); |
240 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); | 243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); |
241 | mNewItemPopup->insertSeparator ( ); | 244 | mNewItemPopup->insertSeparator ( ); |
242 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); | 245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); |
243 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); | 246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); |
244 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); | 247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); |
245 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); | 248 | mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); |
246 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); | 249 | mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 ); |
247 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); | 250 | mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); |
248 | #ifndef _WIN32_ | 251 | #ifndef _WIN32_ |
249 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase | 252 | int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase |
250 | viewport()->setWFlags ( wflags); | 253 | viewport()->setWFlags ( wflags); |
251 | #endif | 254 | #endif |
252 | mGridSpacingX = 80; | 255 | mGridSpacingX = 80; |
253 | mResizeBorderWidth = 8; | 256 | mResizeBorderWidth = 8; |
254 | mScrollBorderWidth = 8; | 257 | mScrollBorderWidth = 8; |
255 | mScrollDelay = 30; | 258 | mScrollDelay = 30; |
256 | mScrollOffset = 10; | 259 | mScrollOffset = 10; |
257 | mPaintPixmap.resize( 20,20); | 260 | mPaintPixmap.resize( 20,20); |
258 | //enableClipper(true); | 261 | //enableClipper(true); |
259 | 262 | ||
260 | // Grab key strokes for keyboard navigation of agenda. Seems to have no | 263 | // Grab key strokes for keyboard navigation of agenda. Seems to have no |
261 | // effect. Has to be fixed. | 264 | // effect. Has to be fixed. |
262 | setFocusPolicy(WheelFocus); | 265 | setFocusPolicy(WheelFocus); |
263 | 266 | ||
264 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); | 267 | connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); |
265 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); | 268 | connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); |
266 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); | 269 | connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); |
267 | 270 | ||
268 | mStartCellX = 0; | 271 | mStartCellX = 0; |
269 | mStartCellY = 0; | 272 | mStartCellY = 0; |
270 | mCurrentCellX = 0; | 273 | mCurrentCellX = 0; |
271 | mCurrentCellY = 0; | 274 | mCurrentCellY = 0; |
272 | 275 | ||
273 | mSelectionCellX = 0; | 276 | mSelectionCellX = 0; |
274 | mSelectionYTop = 0; | 277 | mSelectionYTop = 0; |
275 | mSelectionHeight = 0; | 278 | mSelectionHeight = 0; |
276 | 279 | ||
277 | mOldLowerScrollValue = -1; | 280 | mOldLowerScrollValue = -1; |
278 | mOldUpperScrollValue = -1; | 281 | mOldUpperScrollValue = -1; |
279 | 282 | ||
280 | mClickedItem = 0; | 283 | mClickedItem = 0; |
281 | 284 | ||
282 | mActionItem = 0; | 285 | mActionItem = 0; |
283 | mActionType = NOP; | 286 | mActionType = NOP; |
284 | mItemMoved = false; | 287 | mItemMoved = false; |
285 | 288 | ||
286 | mSelectedItem = 0; | 289 | mSelectedItem = 0; |
287 | 290 | ||
288 | // mItems.setAutoDelete(true); | 291 | // mItems.setAutoDelete(true); |
289 | 292 | ||
290 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); | 293 | resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); |
291 | 294 | ||
292 | viewport()->update(); | 295 | viewport()->update(); |
293 | 296 | ||
294 | setMinimumSize(30, 1); | 297 | setMinimumSize(30, 1); |
295 | // setMaximumHeight(mGridSpacingY * mRows + 5); | 298 | // setMaximumHeight(mGridSpacingY * mRows + 5); |
296 | 299 | ||
297 | // Disable horizontal scrollbar. This is a hack. The geometry should be | 300 | // Disable horizontal scrollbar. This is a hack. The geometry should be |
298 | // controlled in a way that the contents horizontally always fits. Then it is | 301 | // controlled in a way that the contents horizontally always fits. Then it is |
299 | // not necessary to turn off the scrollbar. | 302 | // not necessary to turn off the scrollbar. |
300 | setHScrollBarMode(AlwaysOff); | 303 | setHScrollBarMode(AlwaysOff); |
301 | if ( ! mAllDayMode ) | 304 | if ( ! mAllDayMode ) |
302 | setVScrollBarMode(AlwaysOn); | 305 | setVScrollBarMode(AlwaysOn); |
303 | else | 306 | else |
304 | setVScrollBarMode(AlwaysOff); | 307 | setVScrollBarMode(AlwaysOff); |
305 | 308 | ||
306 | setStartHour(KOPrefs::instance()->mDayBegins); | 309 | setStartHour(KOPrefs::instance()->mDayBegins); |
307 | 310 | ||
308 | calculateWorkingHours(); | 311 | calculateWorkingHours(); |
309 | 312 | ||
310 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), | 313 | connect(verticalScrollBar(),SIGNAL(valueChanged(int)), |
311 | SLOT(checkScrollBoundaries(int))); | 314 | SLOT(checkScrollBoundaries(int))); |
312 | 315 | ||
313 | // Create the Marcus Bains line. | 316 | // Create the Marcus Bains line. |
314 | if(mAllDayMode) | 317 | if(mAllDayMode) |
315 | mMarcusBains = 0; | 318 | mMarcusBains = 0; |
316 | else { | 319 | else { |
317 | mMarcusBains = new MarcusBains(this); | 320 | mMarcusBains = new MarcusBains(this); |
318 | addChild(mMarcusBains); | 321 | addChild(mMarcusBains); |
319 | } | 322 | } |
320 | mPopupKind = 0; | 323 | mPopupKind = 0; |
321 | mPopupItem = 0; | 324 | mPopupItem = 0; |
322 | mInvalidPixmap = false; | 325 | mInvalidPixmap = false; |
323 | 326 | ||
324 | } | 327 | } |
325 | 328 | ||
326 | void KOAgenda::shrinkPixmap() | 329 | void KOAgenda::shrinkPixmap() |
327 | { | 330 | { |
328 | mPaintPixmap.resize( 20,20); | 331 | mPaintPixmap.resize( 20,20); |
329 | mInvalidPixmap = true; | 332 | mInvalidPixmap = true; |
330 | } | 333 | } |
331 | void KOAgenda::slotContentMove(int,int) | 334 | void KOAgenda::slotContentMove(int,int) |
332 | { | 335 | { |
333 | emit sendPing(); | 336 | emit sendPing(); |
334 | if ( mActionType == NOP ) | 337 | if ( mActionType == NOP ) |
335 | slotClearSelection(); | 338 | slotClearSelection(); |
336 | if ( mSelectedItem && !mActionItem ) { | 339 | if ( mSelectedItem && !mActionItem ) { |
337 | deselectItem(); | 340 | deselectItem(); |
338 | emit incidenceSelected( 0 ); | 341 | emit incidenceSelected( 0 ); |
339 | } | 342 | } |
340 | } | 343 | } |
341 | void KOAgenda::clear() | 344 | void KOAgenda::clear() |
342 | { | 345 | { |
343 | KOAgendaItem *item; | 346 | KOAgendaItem *item; |
344 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 347 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
345 | mUnusedItems.append( item ); | 348 | mUnusedItems.append( item ); |
346 | //item->hide(); | 349 | //item->hide(); |
347 | } | 350 | } |
348 | mItems.clear(); | 351 | mItems.clear(); |
349 | mSelectedItem = 0; | 352 | mSelectedItem = 0; |
350 | clearSelection(); | 353 | clearSelection(); |
351 | } | 354 | } |
352 | 355 | ||
353 | void KOAgenda::clearSelection() | 356 | void KOAgenda::clearSelection() |
354 | { | 357 | { |
355 | mSelectionCellX = 0; | 358 | mSelectionCellX = 0; |
356 | mSelectionYTop = 0; | 359 | mSelectionYTop = 0; |
357 | mSelectionHeight = 0; | 360 | mSelectionHeight = 0; |
358 | } | 361 | } |
359 | 362 | ||
360 | void KOAgenda::marcus_bains() | 363 | void KOAgenda::marcus_bains() |
361 | { | 364 | { |
362 | if(mMarcusBains) mMarcusBains->updateLocation(true); | 365 | if(mMarcusBains) mMarcusBains->updateLocation(true); |
363 | } | 366 | } |
364 | 367 | ||
365 | 368 | ||
366 | void KOAgenda::changeColumns(int columns) | 369 | void KOAgenda::changeColumns(int columns) |
367 | { | 370 | { |
368 | if (columns == 0) { | 371 | if (columns == 0) { |
369 | qDebug("KOAgenda::changeColumns() called with argument 0 "); | 372 | qDebug("KOAgenda::changeColumns() called with argument 0 "); |
370 | return; | 373 | return; |
371 | } | 374 | } |
372 | clear(); | 375 | clear(); |
373 | mColumns = columns; | 376 | mColumns = columns; |
374 | computeSizes(); | 377 | computeSizes(); |
378 | if(mMarcusBains) mMarcusBains->hideMe(); | ||
375 | } | 379 | } |
376 | 380 | ||
377 | /* | 381 | /* |
378 | This is the eventFilter function, which gets all events from the KOAgendaItems | 382 | This is the eventFilter function, which gets all events from the KOAgendaItems |
379 | contained in the agenda. It has to handle moving and resizing for all items. | 383 | contained in the agenda. It has to handle moving and resizing for all items. |
380 | */ | 384 | */ |
381 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) | 385 | bool KOAgenda::eventFilter ( QObject *object, QEvent *event ) |
382 | { | 386 | { |
383 | // kdDebug() << "KOAgenda::eventFilter" << endl; | 387 | // kdDebug() << "KOAgenda::eventFilter" << endl; |
384 | switch(event->type()) { | 388 | switch(event->type()) { |
385 | case QEvent::MouseButtonPress: | 389 | case QEvent::MouseButtonPress: |
386 | case QEvent::MouseButtonDblClick: | 390 | case QEvent::MouseButtonDblClick: |
387 | case QEvent::MouseButtonRelease: | 391 | case QEvent::MouseButtonRelease: |
388 | case QEvent::MouseMove: | 392 | case QEvent::MouseMove: |
389 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); | 393 | return eventFilter_mouse(object, static_cast<QMouseEvent *>(event)); |
390 | 394 | ||
391 | case (QEvent::Leave): | 395 | case (QEvent::Leave): |
392 | if (!mActionItem) | 396 | if (!mActionItem) |
393 | setCursor(arrowCursor); | 397 | setCursor(arrowCursor); |
394 | return true; | 398 | return true; |
395 | 399 | ||
396 | default: | 400 | default: |
397 | return QScrollView::eventFilter(object,event); | 401 | return QScrollView::eventFilter(object,event); |
398 | } | 402 | } |
399 | } | 403 | } |
400 | void KOAgenda::popupMenu() | 404 | void KOAgenda::popupMenu() |
401 | { | 405 | { |
402 | mPopupTimer->stop(); | 406 | mPopupTimer->stop(); |
403 | if ( mPopupKind == 1 || mPopupKind == 3 ) { | 407 | if ( mPopupKind == 1 || mPopupKind == 3 ) { |
404 | if (mActionItem ) { | 408 | if (mActionItem ) { |
405 | endItemAction(); | 409 | endItemAction(); |
406 | } | 410 | } |
407 | mLeftMouseDown = false; // no more leftMouse computation | 411 | mLeftMouseDown = false; // no more leftMouse computation |
408 | if (mPopupItem) { | 412 | if (mPopupItem) { |
409 | //mClickedItem = mPopupItem; | 413 | //mClickedItem = mPopupItem; |
410 | selectItem(mPopupItem); | 414 | selectItem(mPopupItem); |
411 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) | 415 | if ( mAllAgendaPopup && KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 1 ) |
412 | mAllAgendaPopup->installEventFilter( this ); | 416 | mAllAgendaPopup->installEventFilter( this ); |
413 | emit showIncidencePopupSignal(mPopupItem->incidence()); | 417 | emit showIncidencePopupSignal(mPopupItem->incidence()); |
414 | 418 | ||
415 | } | 419 | } |
416 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { | 420 | } else if ( mPopupKind == 2 || mPopupKind == 4 ) { |
417 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action | 421 | if ( mLeftMouseDown ) { // we have a simulated right click - clear left mouse action |
418 | endSelectAction( false ); // do not emit new event signal | 422 | endSelectAction( false ); // do not emit new event signal |
419 | mLeftMouseDown = false; // no more leftMouse computation | 423 | mLeftMouseDown = false; // no more leftMouse computation |
420 | } | 424 | } |
421 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) | 425 | if ( KOPrefs::instance()->mBlockPopupMenu && mPopupKind == 2 ) |
422 | mNewItemPopup->installEventFilter( this ); | 426 | mNewItemPopup->installEventFilter( this ); |
423 | mNewItemPopup->popup( mPopupPos); | 427 | mNewItemPopup->popup( mPopupPos); |
424 | 428 | ||
425 | } | 429 | } |
426 | mLeftMouseDown = false; | 430 | mLeftMouseDown = false; |
427 | mPopupItem = 0; | 431 | mPopupItem = 0; |
428 | mPopupKind = 0; | 432 | mPopupKind = 0; |
429 | } | 433 | } |
430 | void KOAgenda::categoryChanged(Incidence * inc) | 434 | void KOAgenda::categoryChanged(Incidence * inc) |
431 | { | 435 | { |
432 | KOAgendaItem *item; | 436 | KOAgendaItem *item; |
433 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { | 437 | for ( item=mItems.first(); item != 0; item=mItems.next() ) { |
434 | if ( item->incidence() == inc ) { | 438 | if ( item->incidence() == inc ) { |
435 | item->initColor (); | 439 | item->initColor (); |
436 | item->updateItem(); | 440 | item->updateItem(); |
437 | } | 441 | } |
438 | } | 442 | } |
439 | } | 443 | } |
440 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) | 444 | bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me) |
441 | { | 445 | { |
442 | 446 | ||
443 | if ( mInvalidPixmap ) { | 447 | if ( mInvalidPixmap ) { |
444 | mInvalidPixmap = false; | 448 | mInvalidPixmap = false; |
445 | qDebug("KO: Upsizing Pixmaps "); | 449 | qDebug("KO: Upsizing Pixmaps "); |
446 | computeSizes(); | 450 | computeSizes(); |
447 | emit updateViewSignal(); | 451 | emit updateViewSignal(); |
448 | return true; | 452 | return true; |
449 | } | 453 | } |
450 | emit sendPing(); | 454 | emit sendPing(); |
451 | static int startX = 0; | 455 | static int startX = 0; |
452 | static int startY = 0; | 456 | static int startY = 0; |
453 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); | 457 | int blockmoveDist = ( QApplication::desktop()->width() < 480 ? 7 : 9 ); |
454 | static bool blockMoving = true; | 458 | static bool blockMoving = true; |
455 | 459 | ||
456 | //qDebug("KOAgenda::eventFilter_mous "); | 460 | //qDebug("KOAgenda::eventFilter_mous "); |
457 | if ( object == mNewItemPopup ) { | 461 | if ( object == mNewItemPopup ) { |
458 | //qDebug("mNewItemPopup "); | 462 | //qDebug("mNewItemPopup "); |
459 | if ( me->type() == QEvent::MouseButtonRelease ) { | 463 | if ( me->type() == QEvent::MouseButtonRelease ) { |
460 | mNewItemPopup->removeEventFilter( this ); | 464 | mNewItemPopup->removeEventFilter( this ); |
461 | int dX = me->globalPos().x() - mPopupPos.x();; | 465 | int dX = me->globalPos().x() - mPopupPos.x();; |
462 | if ( dX < 0 ) | 466 | if ( dX < 0 ) |
463 | dX = -dX; | 467 | dX = -dX; |
464 | int dY = me->globalPos().y() - mPopupPos.y(); | 468 | int dY = me->globalPos().y() - mPopupPos.y(); |
465 | if ( dY < 0 ) | 469 | if ( dY < 0 ) |
466 | dY = -dY; | 470 | dY = -dY; |
467 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 471 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
468 | mNewItemPopup->hide(); | 472 | mNewItemPopup->hide(); |
469 | } | 473 | } |
470 | } | 474 | } |
471 | return true; | 475 | return true; |
472 | } | 476 | } |
473 | if ( object == mAllAgendaPopup ) { | 477 | if ( object == mAllAgendaPopup ) { |
474 | //qDebug(" mAllAgendaPopup "); | 478 | //qDebug(" mAllAgendaPopup "); |
475 | if ( me->type() == QEvent::MouseButtonRelease ) { | 479 | if ( me->type() == QEvent::MouseButtonRelease ) { |
476 | mAllAgendaPopup->removeEventFilter( this ); | 480 | mAllAgendaPopup->removeEventFilter( this ); |
477 | int dX = me->globalPos().x() - mPopupPos.x();; | 481 | int dX = me->globalPos().x() - mPopupPos.x();; |
478 | if ( dX < 0 ) | 482 | if ( dX < 0 ) |
479 | dX = -dX; | 483 | dX = -dX; |
480 | int dY = me->globalPos().y() - mPopupPos.y(); | 484 | int dY = me->globalPos().y() - mPopupPos.y(); |
481 | if ( dY < 0 ) | 485 | if ( dY < 0 ) |
482 | dY = -dY; | 486 | dY = -dY; |
483 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 487 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
484 | mAllAgendaPopup->hide(); | 488 | mAllAgendaPopup->hide(); |
485 | } | 489 | } |
486 | } | 490 | } |
487 | return true; | 491 | return true; |
488 | } | 492 | } |
489 | QPoint viewportPos; | 493 | QPoint viewportPos; |
490 | if (object != viewport()) { | 494 | if (object != viewport()) { |
491 | blockmoveDist = blockmoveDist*2; | 495 | blockmoveDist = blockmoveDist*2; |
492 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); | 496 | viewportPos = ((QWidget *)object)->mapToParent(me->pos()); |
493 | } else { | 497 | } else { |
494 | viewportPos = me->pos(); | 498 | viewportPos = me->pos(); |
495 | } | 499 | } |
496 | bool objIsNotViewport = (object != viewport()); | 500 | bool objIsNotViewport = (object != viewport()); |
497 | bool leftButt = false; | 501 | bool leftButt = false; |
498 | #ifdef DESKTOP_VERSION | 502 | #ifdef DESKTOP_VERSION |
499 | leftButt = (me->button() == LeftButton); | 503 | leftButt = (me->button() == LeftButton); |
500 | #endif | 504 | #endif |
501 | switch (me->type()) { | 505 | switch (me->type()) { |
502 | case QEvent::MouseButtonPress: | 506 | case QEvent::MouseButtonPress: |
503 | if (me->button() == LeftButton) { | 507 | if (me->button() == LeftButton) { |
504 | mPopupTimer->start( 600 ); | 508 | mPopupTimer->start( 600 ); |
505 | mLeftMouseDown = true; | 509 | mLeftMouseDown = true; |
506 | } | 510 | } |
507 | blockMoving = true; | 511 | blockMoving = true; |
508 | startX = viewportPos.x(); | 512 | startX = viewportPos.x(); |
509 | startY = viewportPos.y(); | 513 | startY = viewportPos.y(); |
510 | mPopupPos = me->globalPos(); | 514 | mPopupPos = me->globalPos(); |
511 | if ( objIsNotViewport && !leftButt ) { | 515 | if ( objIsNotViewport && !leftButt ) { |
512 | KOAgendaItem * tempItem = (KOAgendaItem *)object; | 516 | KOAgendaItem * tempItem = (KOAgendaItem *)object; |
513 | if (mAllDayMode) { | 517 | if (mAllDayMode) { |
514 | if ( tempItem->height() > 10 ) { | 518 | if ( tempItem->height() > 10 ) { |
515 | int minV = tempItem->height()/4; | 519 | int minV = tempItem->height()/4; |
516 | if ( minV > (blockmoveDist/2)-2 ) { | 520 | if ( minV > (blockmoveDist/2)-2 ) { |
517 | if ( minV > blockmoveDist ) | 521 | if ( minV > blockmoveDist ) |
518 | minV = blockmoveDist; | 522 | minV = blockmoveDist; |
519 | else | 523 | else |
520 | minV = (blockmoveDist/2); | 524 | minV = (blockmoveDist/2); |
521 | } | 525 | } |
522 | bool border = false; | 526 | bool border = false; |
523 | int diff = tempItem->y() - viewportPos.y(); | 527 | int diff = tempItem->y() - viewportPos.y(); |
524 | if ( diff < 0 ) | 528 | if ( diff < 0 ) |
525 | diff *= -1; | 529 | diff *= -1; |
526 | if ( diff < minV ) { | 530 | if ( diff < minV ) { |
527 | border = true; | 531 | border = true; |
528 | objIsNotViewport = false; | 532 | objIsNotViewport = false; |
529 | } | 533 | } |
530 | if ( ! border ) { | 534 | if ( ! border ) { |
531 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); | 535 | diff = tempItem->y() + tempItem->height()- viewportPos.y(); |
532 | if ( diff < 0 ) | 536 | if ( diff < 0 ) |
533 | diff *= -1; | 537 | diff *= -1; |
534 | if ( diff < minV ) { | 538 | if ( diff < minV ) { |
535 | border = true; | 539 | border = true; |
536 | objIsNotViewport = false; | 540 | objIsNotViewport = false; |
537 | } | 541 | } |
538 | } | 542 | } |
539 | } | 543 | } |
540 | } else { // not allday | 544 | } else { // not allday |
541 | if ( tempItem->width() > 10 ) { | 545 | if ( tempItem->width() > 10 ) { |
542 | int minH = tempItem->width()/4; | 546 | int minH = tempItem->width()/4; |
543 | if ( minH > (blockmoveDist/2)-2 ) { | 547 | if ( minH > (blockmoveDist/2)-2 ) { |
544 | if ( minH > blockmoveDist ) | 548 | if ( minH > blockmoveDist ) |
545 | minH = blockmoveDist; | 549 | minH = blockmoveDist; |
546 | else | 550 | else |
547 | minH = (blockmoveDist/2); | 551 | minH = (blockmoveDist/2); |
548 | } | 552 | } |
549 | bool border = false; | 553 | bool border = false; |
550 | int diff = tempItem->x() - viewportPos.x(); | 554 | int diff = tempItem->x() - viewportPos.x(); |
551 | if ( diff < 0 ) | 555 | if ( diff < 0 ) |
552 | diff *= -1; | 556 | diff *= -1; |
553 | if ( diff < minH ) { | 557 | if ( diff < minH ) { |
554 | border = true; | 558 | border = true; |
555 | objIsNotViewport = false; | 559 | objIsNotViewport = false; |
556 | } | 560 | } |
557 | if ( ! border ) { | 561 | if ( ! border ) { |
558 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); | 562 | diff = tempItem->x() + tempItem->width() - viewportPos.x(); |
559 | if ( diff < 0 ) | 563 | if ( diff < 0 ) |
560 | diff *= -1; | 564 | diff *= -1; |
561 | if ( diff < minH ) { | 565 | if ( diff < minH ) { |
562 | border = true; | 566 | border = true; |
563 | objIsNotViewport = false; | 567 | objIsNotViewport = false; |
564 | } | 568 | } |
565 | } | 569 | } |
566 | } | 570 | } |
567 | } | 571 | } |
568 | } | 572 | } |
569 | if ( objIsNotViewport ) { | 573 | if ( objIsNotViewport ) { |
570 | mPopupItem = (KOAgendaItem *)object; | 574 | mPopupItem = (KOAgendaItem *)object; |
571 | mPopupKind = 1; | 575 | mPopupKind = 1; |
572 | if (me->button() == RightButton) { | 576 | if (me->button() == RightButton) { |
573 | mPopupKind = 3; | 577 | mPopupKind = 3; |
574 | popupMenu(); | 578 | popupMenu(); |
575 | } else if (me->button() == LeftButton) { | 579 | } else if (me->button() == LeftButton) { |
576 | mActionItem = (KOAgendaItem *)object; | 580 | mActionItem = (KOAgendaItem *)object; |
577 | if (mActionItem) { | 581 | if (mActionItem) { |
578 | emit signalClearSelection(); | 582 | emit signalClearSelection(); |
579 | slotClearSelection(); | 583 | slotClearSelection(); |
580 | selectItem(mActionItem); | 584 | selectItem(mActionItem); |
581 | Incidence *incidence = mActionItem->incidence(); | 585 | Incidence *incidence = mActionItem->incidence(); |
582 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { | 586 | if ( incidence->isReadOnly() /*|| incidence->doesRecur() */) { |
583 | mActionItem = 0; | 587 | mActionItem = 0; |
584 | } else { | 588 | } else { |
585 | startItemAction(viewportPos); | 589 | startItemAction(viewportPos); |
586 | } | 590 | } |
587 | } | 591 | } |
588 | } | 592 | } |
589 | } else { // ---------- viewport() | 593 | } else { // ---------- viewport() |
590 | mPopupItem = 0; | 594 | mPopupItem = 0; |
591 | mPopupKind = 2; | 595 | mPopupKind = 2; |
592 | selectItem(0); | 596 | selectItem(0); |
593 | mActionItem = 0; | 597 | mActionItem = 0; |
594 | if (me->button() == RightButton) { | 598 | if (me->button() == RightButton) { |
595 | int x,y; | 599 | int x,y; |
596 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 600 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
597 | int gx,gy; | 601 | int gx,gy; |
598 | contentsToGrid(x,y,gx,gy); | 602 | contentsToGrid(x,y,gx,gy); |
599 | mCurrentCellX = gx; | 603 | mCurrentCellX = gx; |
600 | mCurrentCellY = gy; | 604 | mCurrentCellY = gy; |
601 | mStartCellX = gx; | 605 | mStartCellX = gx; |
602 | mStartCellY = gy; | 606 | mStartCellY = gy; |
603 | mPopupKind = 4; | 607 | mPopupKind = 4; |
604 | popupMenu(); | 608 | popupMenu(); |
605 | } else if (me->button() == LeftButton) { | 609 | } else if (me->button() == LeftButton) { |
606 | setCursor(arrowCursor); | 610 | setCursor(arrowCursor); |
607 | startSelectAction(viewportPos); | 611 | startSelectAction(viewportPos); |
608 | } | 612 | } |
609 | } | 613 | } |
610 | break; | 614 | break; |
611 | 615 | ||
612 | case QEvent::MouseButtonRelease: | 616 | case QEvent::MouseButtonRelease: |
613 | if (me->button() == LeftButton ) { | 617 | if (me->button() == LeftButton ) { |
614 | mPopupTimer->stop(); | 618 | mPopupTimer->stop(); |
615 | } | 619 | } |
616 | if (object != viewport()) { | 620 | if (object != viewport()) { |
617 | if (me->button() == LeftButton && mLeftMouseDown) { | 621 | if (me->button() == LeftButton && mLeftMouseDown) { |
618 | if (mActionItem) { | 622 | if (mActionItem) { |
619 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); | 623 | QPoint clipperPos = clipper()->mapFromGlobal(viewport()->mapToGlobal(viewportPos)); |
620 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); | 624 | //qDebug(" %d %d %d ",clipperPos.y(),visibleHeight() , 9 ); |
621 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { | 625 | if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { |
622 | mScrollUpTimer.stop(); | 626 | mScrollUpTimer.stop(); |
623 | mScrollDownTimer.stop(); | 627 | mScrollDownTimer.stop(); |
624 | mActionItem->resetMove(); | 628 | mActionItem->resetMove(); |
625 | placeSubCells( mActionItem ); | 629 | placeSubCells( mActionItem ); |
626 | // emit startDragSignal( mActionItem->incidence() ); | 630 | // emit startDragSignal( mActionItem->incidence() ); |
627 | setCursor( arrowCursor ); | 631 | setCursor( arrowCursor ); |
628 | mActionItem = 0; | 632 | mActionItem = 0; |
629 | mActionType = NOP; | 633 | mActionType = NOP; |
630 | mItemMoved = 0; | 634 | mItemMoved = 0; |
631 | mLeftMouseDown = false; | 635 | mLeftMouseDown = false; |
632 | return true; | 636 | return true; |
633 | } | 637 | } |
634 | endItemAction(); | 638 | endItemAction(); |
635 | } | 639 | } |
636 | } | 640 | } |
637 | 641 | ||
638 | } else { // ---------- viewport() | 642 | } else { // ---------- viewport() |
639 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click | 643 | if (me->button() == LeftButton && mLeftMouseDown ) { //left click |
640 | endSelectAction( true ); // emit new event signal | 644 | endSelectAction( true ); // emit new event signal |
641 | } | 645 | } |
642 | } | 646 | } |
643 | if (me->button() == LeftButton) | 647 | if (me->button() == LeftButton) |
644 | mLeftMouseDown = false; | 648 | mLeftMouseDown = false; |
645 | 649 | ||
646 | break; | 650 | break; |
647 | 651 | ||
648 | case QEvent::MouseMove: | 652 | case QEvent::MouseMove: |
649 | //qDebug("mm "); | 653 | //qDebug("mm "); |
650 | if ( !mLeftMouseDown ) | 654 | if ( !mLeftMouseDown ) |
651 | return false; | 655 | return false; |
652 | if ( blockMoving ) { | 656 | if ( blockMoving ) { |
653 | int dX, dY; | 657 | int dX, dY; |
654 | dX = startX - viewportPos.x(); | 658 | dX = startX - viewportPos.x(); |
655 | if ( dX < 0 ) | 659 | if ( dX < 0 ) |
656 | dX = -dX; | 660 | dX = -dX; |
657 | dY = viewportPos.y() - startY; | 661 | dY = viewportPos.y() - startY; |
658 | if ( dY < 0 ) | 662 | if ( dY < 0 ) |
659 | dY = -dY; | 663 | dY = -dY; |
660 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); | 664 | //qDebug("%d %d %d ", dX, dY , blockmoveDist ); |
661 | if ( dX > blockmoveDist || dY > blockmoveDist ) { | 665 | if ( dX > blockmoveDist || dY > blockmoveDist ) { |
662 | blockMoving = false; | 666 | blockMoving = false; |
663 | } | 667 | } |
664 | } | 668 | } |
665 | if ( ! blockMoving ) | 669 | if ( ! blockMoving ) |
666 | mPopupTimer->stop(); | 670 | mPopupTimer->stop(); |
667 | if (object != viewport()) { | 671 | if (object != viewport()) { |
668 | KOAgendaItem *moveItem = (KOAgendaItem *)object; | 672 | KOAgendaItem *moveItem = (KOAgendaItem *)object; |
669 | if (!moveItem->incidence()->isReadOnly() ) { | 673 | if (!moveItem->incidence()->isReadOnly() ) { |
670 | if (!mActionItem) | 674 | if (!mActionItem) |
671 | setNoActionCursor(moveItem,viewportPos); | 675 | setNoActionCursor(moveItem,viewportPos); |
672 | else { | 676 | else { |
673 | if ( !blockMoving ) | 677 | if ( !blockMoving ) |
674 | performItemAction(viewportPos); | 678 | performItemAction(viewportPos); |
675 | } | 679 | } |
676 | } | 680 | } |
677 | } else { // ---------- viewport() | 681 | } else { // ---------- viewport() |
678 | mPopupPos = viewport()->mapToGlobal( me->pos() ); | 682 | mPopupPos = viewport()->mapToGlobal( me->pos() ); |
679 | if ( mActionType == SELECT ) { | 683 | if ( mActionType == SELECT ) { |
680 | performSelectAction( viewportPos ); | 684 | performSelectAction( viewportPos ); |
681 | } | 685 | } |
682 | } | 686 | } |
683 | break; | 687 | break; |
684 | 688 | ||
685 | case QEvent::MouseButtonDblClick: | 689 | case QEvent::MouseButtonDblClick: |
686 | mPopupTimer->stop(); | 690 | mPopupTimer->stop(); |
687 | if (object == viewport()) { | 691 | if (object == viewport()) { |
688 | selectItem(0); | 692 | selectItem(0); |
689 | int x,y; | 693 | int x,y; |
690 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 694 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
691 | int gx,gy; | 695 | int gx,gy; |
692 | contentsToGrid(x,y,gx,gy); | 696 | contentsToGrid(x,y,gx,gy); |
693 | emit newEventSignal(gx,gy); | 697 | emit newEventSignal(gx,gy); |
694 | } else { | 698 | } else { |
695 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; | 699 | KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; |
696 | selectItem(doubleClickedItem); | 700 | selectItem(doubleClickedItem); |
697 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 701 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
698 | emit editIncidenceSignal(doubleClickedItem->incidence()); | 702 | emit editIncidenceSignal(doubleClickedItem->incidence()); |
699 | else | 703 | else |
700 | emit showIncidenceSignal(doubleClickedItem->incidence()); | 704 | emit showIncidenceSignal(doubleClickedItem->incidence()); |
701 | } | 705 | } |
702 | break; | 706 | break; |
703 | 707 | ||
704 | default: | 708 | default: |
705 | break; | 709 | break; |
706 | } | 710 | } |
707 | return true; | 711 | return true; |
708 | 712 | ||
709 | } | 713 | } |
710 | 714 | ||
711 | void KOAgenda::newItem( int item ) | 715 | void KOAgenda::newItem( int item ) |
712 | { | 716 | { |
713 | if ( item == 1 ) { //new event | 717 | if ( item == 1 ) { //new event |
714 | newEventSignal(mStartCellX ,mStartCellY ); | 718 | newEventSignal(mStartCellX ,mStartCellY ); |
715 | } else | 719 | } else |
716 | if ( item == 2 ) { //new event | 720 | if ( item == 2 ) { //new event |
717 | newTodoSignal(mStartCellX ,mStartCellY ); | 721 | newTodoSignal(mStartCellX ,mStartCellY ); |
718 | } else | 722 | } else |
719 | { | 723 | { |
720 | emit showDateView( item, mStartCellX ); | 724 | emit showDateView( item, mStartCellX ); |
721 | // 3Day view | 725 | // 3Day view |
722 | // 4Week view | 726 | // 4Week view |
723 | // 5Month view | 727 | // 5Month view |
724 | // 6Journal view | 728 | // 6Journal view |
725 | } | 729 | } |
726 | } | 730 | } |
727 | void KOAgenda::slotClearSelection() | 731 | void KOAgenda::slotClearSelection() |
728 | { | 732 | { |
729 | if (mSelectionHeight) { | 733 | if (mSelectionHeight) { |
730 | int selectionX = mSelectionCellX * mGridSpacingX; | 734 | int selectionX = mSelectionCellX * mGridSpacingX; |
731 | int top = mSelectionYTop - 2 *mGridSpacingY; | 735 | int top = mSelectionYTop - 2 *mGridSpacingY; |
732 | int hei = mSelectionHeight + 4 *mGridSpacingY; | 736 | int hei = mSelectionHeight + 4 *mGridSpacingY; |
733 | clearSelection(); | 737 | clearSelection(); |
734 | repaintContents( selectionX, top, | 738 | repaintContents( selectionX, top, |
735 | mGridSpacingX, hei ,false ); | 739 | mGridSpacingX, hei ,false ); |
736 | } | 740 | } |
737 | 741 | ||
738 | } | 742 | } |
739 | void KOAgenda::startSelectAction(QPoint viewportPos) | 743 | void KOAgenda::startSelectAction(QPoint viewportPos) |
740 | { | 744 | { |
741 | 745 | ||
742 | emit signalClearSelection(); | 746 | emit signalClearSelection(); |
743 | slotClearSelection(); | 747 | slotClearSelection(); |
744 | 748 | ||
745 | mActionType = SELECT; | 749 | mActionType = SELECT; |
746 | 750 | ||
747 | int x,y; | 751 | int x,y; |
748 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); | 752 | viewportToContents(viewportPos.x(),viewportPos.y(),x,y); |
749 | int gx,gy; | 753 | int gx,gy; |
750 | contentsToGrid(x,y,gx,gy); | 754 | contentsToGrid(x,y,gx,gy); |
751 | 755 | ||
752 | mStartCellX = gx; | 756 | mStartCellX = gx; |
753 | mStartCellY = gy; | 757 | mStartCellY = gy; |
754 | mCurrentCellX = gx; | 758 | mCurrentCellX = gx; |
755 | mCurrentCellY = gy; | 759 | mCurrentCellY = gy; |
756 | 760 | ||
757 | // Store new selection | 761 | // Store new selection |
758 | mSelectionCellX = gx; | 762 | mSelectionCellX = gx; |
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h index 86cf2f4..59e7472 100644 --- a/korganizer/koagenda.h +++ b/korganizer/koagenda.h | |||
@@ -1,307 +1,307 @@ | |||
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 | #ifndef KOAGENDA_H | 23 | #ifndef KOAGENDA_H |
24 | #define KOAGENDA_H | 24 | #define KOAGENDA_H |
25 | 25 | ||
26 | #include <qscrollview.h> | 26 | #include <qscrollview.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | #include <qmemarray.h> | 28 | #include <qmemarray.h> |
29 | #include <qpainter.h> | 29 | #include <qpainter.h> |
30 | #include <qpixmap.h> | 30 | #include <qpixmap.h> |
31 | #include <qguardedptr.h> | 31 | #include <qguardedptr.h> |
32 | 32 | ||
33 | #include "koagendaitem.h" | 33 | #include "koagendaitem.h" |
34 | #include "koeventview.h" | 34 | #include "koeventview.h" |
35 | 35 | ||
36 | class QPopupMenu; | 36 | class QPopupMenu; |
37 | class QTime; | 37 | class QTime; |
38 | class KConfig; | 38 | class KConfig; |
39 | class QFrame; | 39 | class QFrame; |
40 | class KOAgenda; | 40 | class KOAgenda; |
41 | class KCal::Event; | 41 | class KCal::Event; |
42 | class KCal::Todo; | 42 | class KCal::Todo; |
43 | 43 | ||
44 | using namespace KCal; | 44 | using namespace KCal; |
45 | 45 | ||
46 | class MarcusBains : public QFrame { | 46 | class MarcusBains : public QFrame { |
47 | Q_OBJECT | 47 | Q_OBJECT |
48 | public: | 48 | public: |
49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); | 49 | MarcusBains(KOAgenda *agenda=0,const char *name=0); |
50 | virtual ~MarcusBains(); | 50 | virtual ~MarcusBains(); |
51 | 51 | void hideMe(); | |
52 | public slots: | 52 | public slots: |
53 | void updateLocation(bool recalculate=false); | 53 | void updateLocation(bool recalculate=false); |
54 | void updateLoc(); | 54 | void updateLoc(); |
55 | 55 | ||
56 | private: | 56 | private: |
57 | int todayColumn(); | 57 | int todayColumn(); |
58 | QTimer *minutes; | 58 | QTimer *minutes; |
59 | QLabel *mTimeBox; | 59 | QLabel *mTimeBox; |
60 | KOAgenda *agenda; | 60 | KOAgenda *agenda; |
61 | QTime oldTime; | 61 | QTime oldTime; |
62 | int oldToday; | 62 | int oldToday; |
63 | }; | 63 | }; |
64 | 64 | ||
65 | 65 | ||
66 | class KOAgenda : public QScrollView | 66 | class KOAgenda : public QScrollView |
67 | { | 67 | { |
68 | Q_OBJECT | 68 | Q_OBJECT |
69 | public: | 69 | public: |
70 | enum MouseActionType { NOP, MOVE, SELECT, | 70 | enum MouseActionType { NOP, MOVE, SELECT, |
71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; | 71 | RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; |
72 | 72 | ||
73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, | 73 | KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, |
74 | const char * name=0, WFlags f=0 ); | 74 | const char * name=0, WFlags f=0 ); |
75 | KOAgenda ( int columns, QWidget * parent=0, | 75 | KOAgenda ( int columns, QWidget * parent=0, |
76 | const char * name=0, WFlags f=0 ); | 76 | const char * name=0, WFlags f=0 ); |
77 | virtual ~KOAgenda(); | 77 | virtual ~KOAgenda(); |
78 | bool mInvalidPixmap; | 78 | bool mInvalidPixmap; |
79 | 79 | ||
80 | Incidence *selectedIncidence() const; | 80 | Incidence *selectedIncidence() const; |
81 | QDate selectedIncidenceDate() const; | 81 | QDate selectedIncidenceDate() const; |
82 | 82 | ||
83 | virtual bool eventFilter ( QObject *, QEvent * ); | 83 | virtual bool eventFilter ( QObject *, QEvent * ); |
84 | 84 | ||
85 | void contentsToGrid (int x, int y, int& gx, int& gy); | 85 | void contentsToGrid (int x, int y, int& gx, int& gy); |
86 | void gridToContents (int gx, int gy, int& x, int& y); | 86 | void gridToContents (int gx, int gy, int& x, int& y); |
87 | 87 | ||
88 | int timeToY (const QTime &time); | 88 | int timeToY (const QTime &time); |
89 | QTime gyToTime (int y); | 89 | QTime gyToTime (int y); |
90 | 90 | ||
91 | void setStartHour(int startHour); | 91 | void setStartHour(int startHour); |
92 | 92 | ||
93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); | 93 | KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); |
94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); | 94 | KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); |
95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, | 95 | void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, |
96 | int YTop,int YBottom); | 96 | int YTop,int YBottom); |
97 | 97 | ||
98 | void changeColumns(int columns); | 98 | void changeColumns(int columns); |
99 | 99 | ||
100 | int columns() { return mColumns; } | 100 | int columns() { return mColumns; } |
101 | int rows() { return mRows; } | 101 | int rows() { return mRows; } |
102 | 102 | ||
103 | int gridSpacingX() const { return mGridSpacingX; } | 103 | int gridSpacingX() const { return mGridSpacingX; } |
104 | int gridSpacingY() const { return mGridSpacingY; } | 104 | int gridSpacingY() const { return mGridSpacingY; } |
105 | 105 | ||
106 | // virtual QSizePolicy sizePolicy() const; | 106 | // virtual QSizePolicy sizePolicy() const; |
107 | 107 | ||
108 | void clear(); | 108 | void clear(); |
109 | 109 | ||
110 | void clearSelection(); | 110 | void clearSelection(); |
111 | void hideUnused(); | 111 | void hideUnused(); |
112 | 112 | ||
113 | /** Calculates the minimum width */ | 113 | /** Calculates the minimum width */ |
114 | virtual int minimumWidth() const; | 114 | virtual int minimumWidth() const; |
115 | /** Update configuration from preference settings */ | 115 | /** Update configuration from preference settings */ |
116 | void updateConfig(); | 116 | void updateConfig(); |
117 | 117 | ||
118 | void checkScrollBoundaries(); | 118 | void checkScrollBoundaries(); |
119 | 119 | ||
120 | void setHolidayMask(QMemArray<bool> *); | 120 | void setHolidayMask(QMemArray<bool> *); |
121 | void setDateList(const DateList &selectedDates); | 121 | void setDateList(const DateList &selectedDates); |
122 | DateList dateList() const; | 122 | DateList dateList() const; |
123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); | 123 | void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); |
124 | void finishUpdate(); | 124 | void finishUpdate(); |
125 | void printSelection(); | 125 | void printSelection(); |
126 | void storePosition(); | 126 | void storePosition(); |
127 | void restorePosition(); | 127 | void restorePosition(); |
128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } | 128 | void setPopup( KOEventPopupMenu * p ) { mAllAgendaPopup = p; } |
129 | void shrinkPixmap(); | 129 | void shrinkPixmap(); |
130 | QTime getEndTime(); | 130 | QTime getEndTime(); |
131 | 131 | ||
132 | public slots: | 132 | public slots: |
133 | void slotContentMove(int,int); | 133 | void slotContentMove(int,int); |
134 | void categoryChanged(Incidence * inc); | 134 | void categoryChanged(Incidence * inc); |
135 | void slotClearSelection(); | 135 | void slotClearSelection(); |
136 | void popupMenu(); | 136 | void popupMenu(); |
137 | void newItem( int ); | 137 | void newItem( int ); |
138 | void moveChild( QWidget *, int, int ); | 138 | void moveChild( QWidget *, int, int ); |
139 | void scrollUp(); | 139 | void scrollUp(); |
140 | void scrollDown(); | 140 | void scrollDown(); |
141 | void updateTodo( Todo * t, int , bool ); | 141 | void updateTodo( Todo * t, int , bool ); |
142 | void popupAlarm(); | 142 | void popupAlarm(); |
143 | 143 | ||
144 | void checkScrollBoundaries(int); | 144 | void checkScrollBoundaries(int); |
145 | 145 | ||
146 | /** Deselect selected items. This function does not emit any signals. */ | 146 | /** Deselect selected items. This function does not emit any signals. */ |
147 | void deselectItem(); | 147 | void deselectItem(); |
148 | /** Select item. If the argument is 0, the currently selected item gets | 148 | /** Select item. If the argument is 0, the currently selected item gets |
149 | deselected. This function emits the itemSelected(bool) signal to inform | 149 | deselected. This function emits the itemSelected(bool) signal to inform |
150 | about selection/deseelction of events. */ | 150 | about selection/deseelction of events. */ |
151 | void selectItem(KOAgendaItem *); | 151 | void selectItem(KOAgendaItem *); |
152 | void finishResize(); | 152 | void finishResize(); |
153 | 153 | ||
154 | signals: | 154 | signals: |
155 | void signalClearSelection(); | 155 | void signalClearSelection(); |
156 | void showDateView( int, int); | 156 | void showDateView( int, int); |
157 | void newEventSignal(); | 157 | void newEventSignal(); |
158 | void newEventSignal(int gx,int gy); | 158 | void newEventSignal(int gx,int gy); |
159 | void newTodoSignal(int gx,int gy); | 159 | void newTodoSignal(int gx,int gy); |
160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 160 | void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); | 161 | void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); |
162 | void newStartSelectSignal(); | 162 | void newStartSelectSignal(); |
163 | void showIncidenceSignal(Incidence *); | 163 | void showIncidenceSignal(Incidence *); |
164 | void editIncidenceSignal(Incidence *); | 164 | void editIncidenceSignal(Incidence *); |
165 | void deleteIncidenceSignal(Incidence *); | 165 | void deleteIncidenceSignal(Incidence *); |
166 | void showIncidencePopupSignal(Incidence *); | 166 | void showIncidencePopupSignal(Incidence *); |
167 | 167 | ||
168 | void itemModified(KOAgendaItem *item, int ); | 168 | void itemModified(KOAgendaItem *item, int ); |
169 | void incidenceSelected(Incidence *); | 169 | void incidenceSelected(Incidence *); |
170 | 170 | ||
171 | void lowerYChanged(int); | 171 | void lowerYChanged(int); |
172 | void upperYChanged(int); | 172 | void upperYChanged(int); |
173 | 173 | ||
174 | void startDragSignal(Incidence *); | 174 | void startDragSignal(Incidence *); |
175 | void addToCalSignal(Incidence *, Incidence *); | 175 | void addToCalSignal(Incidence *, Incidence *); |
176 | void resizedSignal(); | 176 | void resizedSignal(); |
177 | void updateViewSignal(); | 177 | void updateViewSignal(); |
178 | void sendPing(); | 178 | void sendPing(); |
179 | 179 | ||
180 | protected: | 180 | protected: |
181 | KOEventPopupMenu * mAllAgendaPopup; | 181 | KOEventPopupMenu * mAllAgendaPopup; |
182 | QPainter mPixPainter; | 182 | QPainter mPixPainter; |
183 | QPixmap mPaintPixmap; | 183 | QPixmap mPaintPixmap; |
184 | QPixmap mHighlightPixmap; | 184 | QPixmap mHighlightPixmap; |
185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); | 185 | void drawContents(QPainter *p,int cx, int cy, int cw, int ch); |
186 | virtual void resizeEvent ( QResizeEvent * ); | 186 | virtual void resizeEvent ( QResizeEvent * ); |
187 | 187 | ||
188 | /** Handles mouse events. Called from eventFilter */ | 188 | /** Handles mouse events. Called from eventFilter */ |
189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); | 189 | virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); |
190 | 190 | ||
191 | /** Start selecting time span. */ | 191 | /** Start selecting time span. */ |
192 | void startSelectAction(QPoint viewportPos); | 192 | void startSelectAction(QPoint viewportPos); |
193 | 193 | ||
194 | /** Select time span. */ | 194 | /** Select time span. */ |
195 | void performSelectAction(QPoint viewportPos); | 195 | void performSelectAction(QPoint viewportPos); |
196 | 196 | ||
197 | /** Emd selecting time span. */ | 197 | /** Emd selecting time span. */ |
198 | void endSelectAction( bool emitNewEvent = false ); | 198 | void endSelectAction( bool emitNewEvent = false ); |
199 | 199 | ||
200 | /** Start moving/resizing agenda item */ | 200 | /** Start moving/resizing agenda item */ |
201 | void startItemAction(QPoint viewportPos); | 201 | void startItemAction(QPoint viewportPos); |
202 | 202 | ||
203 | /** Move/resize agenda item */ | 203 | /** Move/resize agenda item */ |
204 | void performItemAction(QPoint viewportPos); | 204 | void performItemAction(QPoint viewportPos); |
205 | 205 | ||
206 | /** End moving/resizing agenda item */ | 206 | /** End moving/resizing agenda item */ |
207 | void endItemAction(); | 207 | void endItemAction(); |
208 | 208 | ||
209 | /** Set cursor, when no item action is in progress */ | 209 | /** Set cursor, when no item action is in progress */ |
210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); | 210 | void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); |
211 | 211 | ||
212 | /** Place agenda item in agenda and adjust other cells if necessary */ | 212 | /** Place agenda item in agenda and adjust other cells if necessary */ |
213 | void placeSubCells(KOAgendaItem *placeItem); | 213 | void placeSubCells(KOAgendaItem *placeItem); |
214 | 214 | ||
215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. | 215 | /** Process the keyevent, including the ignored keyevents of eventwidgets. |
216 | * Implements pgup/pgdn and cursor key navigation in the view. | 216 | * Implements pgup/pgdn and cursor key navigation in the view. |
217 | */ | 217 | */ |
218 | void keyPressEvent( QKeyEvent * ); | 218 | void keyPressEvent( QKeyEvent * ); |
219 | 219 | ||
220 | void calculateWorkingHours(); | 220 | void calculateWorkingHours(); |
221 | 221 | ||
222 | virtual void contentsMousePressEvent ( QMouseEvent * ); | 222 | virtual void contentsMousePressEvent ( QMouseEvent * ); |
223 | 223 | ||
224 | private: | 224 | private: |
225 | void init(); | 225 | void init(); |
226 | void marcus_bains(); | 226 | void marcus_bains(); |
227 | bool mAllDayMode; | 227 | bool mAllDayMode; |
228 | bool blockResize; | 228 | bool blockResize; |
229 | bool mLeftMouseDown; | 229 | bool mLeftMouseDown; |
230 | KOAgendaItem *mPopupItem; | 230 | KOAgendaItem *mPopupItem; |
231 | QTimer* mPopupTimer; | 231 | QTimer* mPopupTimer; |
232 | int mPopupKind; | 232 | int mPopupKind; |
233 | QPoint mPopupPos; | 233 | QPoint mPopupPos; |
234 | QTimer mResizeTimer; | 234 | QTimer mResizeTimer; |
235 | double mContentPosition; | 235 | double mContentPosition; |
236 | 236 | ||
237 | // Width and height of agenda cells | 237 | // Width and height of agenda cells |
238 | int mGridSpacingX; | 238 | int mGridSpacingX; |
239 | int mGridSpacingY; | 239 | int mGridSpacingY; |
240 | 240 | ||
241 | // size of border, where mouse action will resize the KOAgendaItem | 241 | // size of border, where mouse action will resize the KOAgendaItem |
242 | int mResizeBorderWidth; | 242 | int mResizeBorderWidth; |
243 | 243 | ||
244 | // size of border, where mouse mve will cause a scroll of the agenda | 244 | // size of border, where mouse mve will cause a scroll of the agenda |
245 | int mScrollBorderWidth; | 245 | int mScrollBorderWidth; |
246 | int mScrollDelay; | 246 | int mScrollDelay; |
247 | int mScrollOffset; | 247 | int mScrollOffset; |
248 | 248 | ||
249 | QTimer mScrollUpTimer; | 249 | QTimer mScrollUpTimer; |
250 | QTimer mScrollDownTimer; | 250 | QTimer mScrollDownTimer; |
251 | 251 | ||
252 | // Number of Columns/Rows of agenda grid | 252 | // Number of Columns/Rows of agenda grid |
253 | int mColumns; | 253 | int mColumns; |
254 | int mRows; | 254 | int mRows; |
255 | 255 | ||
256 | // Cells to store Move and Resize coordiantes | 256 | // Cells to store Move and Resize coordiantes |
257 | int mStartCellX; | 257 | int mStartCellX; |
258 | int mStartCellY; | 258 | int mStartCellY; |
259 | int mCurrentCellX; | 259 | int mCurrentCellX; |
260 | int mCurrentCellY; | 260 | int mCurrentCellY; |
261 | 261 | ||
262 | // Working Hour coordiantes | 262 | // Working Hour coordiantes |
263 | bool mWorkingHoursEnable; | 263 | bool mWorkingHoursEnable; |
264 | int mWorkingHoursYTop; | 264 | int mWorkingHoursYTop; |
265 | int mWorkingHoursYBottom; | 265 | int mWorkingHoursYBottom; |
266 | 266 | ||
267 | // Selection | 267 | // Selection |
268 | int mSelectionCellX; | 268 | int mSelectionCellX; |
269 | int mSelectionYTop; | 269 | int mSelectionYTop; |
270 | int mSelectionHeight; | 270 | int mSelectionHeight; |
271 | 271 | ||
272 | // List of dates to be displayed | 272 | // List of dates to be displayed |
273 | DateList mSelectedDates; | 273 | DateList mSelectedDates; |
274 | 274 | ||
275 | // The KOAgendaItem, which has been right-clicked last | 275 | // The KOAgendaItem, which has been right-clicked last |
276 | KOAgendaItem *mClickedItem; | 276 | KOAgendaItem *mClickedItem; |
277 | 277 | ||
278 | // The KOAgendaItem, which is being moved/resized | 278 | // The KOAgendaItem, which is being moved/resized |
279 | QGuardedPtr<KOAgendaItem> mActionItem; | 279 | QGuardedPtr<KOAgendaItem> mActionItem; |
280 | 280 | ||
281 | // Currently selected item | 281 | // Currently selected item |
282 | QGuardedPtr<KOAgendaItem> mSelectedItem; | 282 | QGuardedPtr<KOAgendaItem> mSelectedItem; |
283 | 283 | ||
284 | // The Marcus Bains Line widget. | 284 | // The Marcus Bains Line widget. |
285 | MarcusBains *mMarcusBains; | 285 | MarcusBains *mMarcusBains; |
286 | void computeSizes(); | 286 | void computeSizes(); |
287 | 287 | ||
288 | MouseActionType mActionType; | 288 | MouseActionType mActionType; |
289 | 289 | ||
290 | bool mItemMoved; | 290 | bool mItemMoved; |
291 | 291 | ||
292 | // List of all Items contained in agenda | 292 | // List of all Items contained in agenda |
293 | QPtrList<KOAgendaItem> mItems; | 293 | QPtrList<KOAgendaItem> mItems; |
294 | QPtrList<KOAgendaItem> mUnusedItems; | 294 | QPtrList<KOAgendaItem> mUnusedItems; |
295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); | 295 | KOAgendaItem* getNewItem(Incidence * event,QDate qd, QWidget* viewport); |
296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems | 296 | QPopupMenu *mItemPopup; // Right mouse button popup menu for KOAgendaItems |
297 | QPopupMenu *mNewItemPopup; | 297 | QPopupMenu *mNewItemPopup; |
298 | 298 | ||
299 | int mOldLowerScrollValue; | 299 | int mOldLowerScrollValue; |
300 | int mOldUpperScrollValue; | 300 | int mOldUpperScrollValue; |
301 | KOAgendaItem * getItemForTodo ( Todo * todo ); | 301 | KOAgendaItem * getItemForTodo ( Todo * todo ); |
302 | QMemArray<bool> *mHolidayMask; | 302 | QMemArray<bool> *mHolidayMask; |
303 | int mCurPixWid; | 303 | int mCurPixWid; |
304 | int mCurPixHei; | 304 | int mCurPixHei; |
305 | }; | 305 | }; |
306 | 306 | ||
307 | #endif // KOAGENDA_H | 307 | #endif // KOAGENDA_H |
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index f46a103..82c0f4c 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp | |||
@@ -976,749 +976,749 @@ void KOTodoView::resetCurrentItem() | |||
976 | processSelectionChange(); | 976 | processSelectionChange(); |
977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); | 977 | QTimer::singleShot( 100, this, SLOT ( resetFocusToList() )); |
978 | } | 978 | } |
979 | void KOTodoView::resetFocusToList() | 979 | void KOTodoView::resetFocusToList() |
980 | { | 980 | { |
981 | topLevelWidget()->setActiveWindow(); | 981 | topLevelWidget()->setActiveWindow(); |
982 | mTodoListView->setFocus(); | 982 | mTodoListView->setFocus(); |
983 | } | 983 | } |
984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; | 984 | //Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove; |
985 | bool KOTodoView::checkTodo( Todo * todo ) | 985 | bool KOTodoView::checkTodo( Todo * todo ) |
986 | { | 986 | { |
987 | 987 | ||
988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) | 988 | if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) |
989 | return false; | 989 | return false; |
990 | if ( !todo->isCompleted() ) { | 990 | if ( !todo->isCompleted() ) { |
991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) | 991 | if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) |
992 | return true; | 992 | return true; |
993 | } | 993 | } |
994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { | 994 | if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { |
995 | if ( todo->hasStartDate() ) | 995 | if ( todo->hasStartDate() ) |
996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) | 996 | if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) |
997 | return false; | 997 | return false; |
998 | if ( todo->hasDueDate() ) | 998 | if ( todo->hasDueDate() ) |
999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) | 999 | if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) |
1000 | return false; | 1000 | return false; |
1001 | } | 1001 | } |
1002 | return true; | 1002 | return true; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | void KOTodoView::restoreItemState( QListViewItem *item ) | 1005 | void KOTodoView::restoreItemState( QListViewItem *item ) |
1006 | { | 1006 | { |
1007 | pendingSubtodo = 0; | 1007 | pendingSubtodo = 0; |
1008 | while( item ) { | 1008 | while( item ) { |
1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1009 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); | 1010 | todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); |
1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); | 1011 | if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); |
1012 | item = item->nextSibling(); | 1012 | item = item->nextSibling(); |
1013 | } | 1013 | } |
1014 | } | 1014 | } |
1015 | 1015 | ||
1016 | 1016 | ||
1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator | 1017 | QMap<Todo *,KOTodoViewItem *>::ConstIterator |
1018 | KOTodoView::insertTodoItem(Todo *todo) | 1018 | KOTodoView::insertTodoItem(Todo *todo) |
1019 | { | 1019 | { |
1020 | 1020 | ||
1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; | 1021 | // kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; |
1022 | // TODO: Check, if dynmaic cast is necessary | 1022 | // TODO: Check, if dynmaic cast is necessary |
1023 | 1023 | ||
1024 | pendingSubtodo = 0; | 1024 | pendingSubtodo = 0; |
1025 | Incidence *incidence = todo->relatedTo(); | 1025 | Incidence *incidence = todo->relatedTo(); |
1026 | while ( incidence && !incidence->calEnabled() ) | 1026 | while ( incidence && !incidence->calEnabled() ) |
1027 | incidence = incidence->relatedTo(); | 1027 | incidence = incidence->relatedTo(); |
1028 | if (incidence && incidence->typeID() == todoID ) { | 1028 | if (incidence && incidence->typeID() == todoID ) { |
1029 | Todo *relatedTodo = static_cast<Todo *>(incidence); | 1029 | Todo *relatedTodo = static_cast<Todo *>(incidence); |
1030 | 1030 | ||
1031 | // kdDebug() << " has Related" << endl; | 1031 | // kdDebug() << " has Related" << endl; |
1032 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1032 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1033 | itemIterator = mTodoMap.find(relatedTodo); | 1033 | itemIterator = mTodoMap.find(relatedTodo); |
1034 | if (itemIterator == mTodoMap.end()) { | 1034 | if (itemIterator == mTodoMap.end()) { |
1035 | // kdDebug() << " related not yet in list" << endl; | 1035 | // kdDebug() << " related not yet in list" << endl; |
1036 | itemIterator = insertTodoItem (relatedTodo); | 1036 | itemIterator = insertTodoItem (relatedTodo); |
1037 | } | 1037 | } |
1038 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem | 1038 | // isn't this pretty stupid? We give one Todo to the KOTodoViewItem |
1039 | // and one into the map. Sure finding is more easy but why? -zecke | 1039 | // and one into the map. Sure finding is more easy but why? -zecke |
1040 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); | 1040 | KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); |
1041 | return mTodoMap.insert(todo,todoItem); | 1041 | return mTodoMap.insert(todo,todoItem); |
1042 | } else { | 1042 | } else { |
1043 | // kdDebug() << " no Related" << endl; | 1043 | // kdDebug() << " no Related" << endl; |
1044 | // see above -zecke | 1044 | // see above -zecke |
1045 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1045 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1046 | return mTodoMap.insert(todo,todoItem); | 1046 | return mTodoMap.insert(todo,todoItem); |
1047 | } | 1047 | } |
1048 | } | 1048 | } |
1049 | 1049 | ||
1050 | 1050 | ||
1051 | void KOTodoView::updateConfig() | 1051 | void KOTodoView::updateConfig() |
1052 | { | 1052 | { |
1053 | updateView(); | 1053 | updateView(); |
1054 | mTodoListView->repaintContents(); | 1054 | mTodoListView->repaintContents(); |
1055 | } | 1055 | } |
1056 | 1056 | ||
1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() | 1057 | QPtrList<Incidence> KOTodoView::selectedIncidences() |
1058 | { | 1058 | { |
1059 | QPtrList<Incidence> selected; | 1059 | QPtrList<Incidence> selected; |
1060 | 1060 | ||
1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1061 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1062 | // if (!item) item = mActiveItem; | 1062 | // if (!item) item = mActiveItem; |
1063 | if (item) selected.append(item->todo()); | 1063 | if (item) selected.append(item->todo()); |
1064 | 1064 | ||
1065 | return selected; | 1065 | return selected; |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | QPtrList<Todo> KOTodoView::selectedTodos() | 1068 | QPtrList<Todo> KOTodoView::selectedTodos() |
1069 | { | 1069 | { |
1070 | QPtrList<Todo> selected; | 1070 | QPtrList<Todo> selected; |
1071 | 1071 | ||
1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); | 1072 | KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); |
1073 | // if (!item) item = mActiveItem; | 1073 | // if (!item) item = mActiveItem; |
1074 | if (item) selected.append(item->todo()); | 1074 | if (item) selected.append(item->todo()); |
1075 | 1075 | ||
1076 | return selected; | 1076 | return selected; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | void KOTodoView::changeEventDisplay(Event *, int) | 1079 | void KOTodoView::changeEventDisplay(Event *, int) |
1080 | { | 1080 | { |
1081 | updateView(); | 1081 | updateView(); |
1082 | } | 1082 | } |
1083 | 1083 | ||
1084 | void KOTodoView::showDates(const QDate &, const QDate &) | 1084 | void KOTodoView::showDates(const QDate &, const QDate &) |
1085 | { | 1085 | { |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void KOTodoView::showEvents(QPtrList<Event>) | 1088 | void KOTodoView::showEvents(QPtrList<Event>) |
1089 | { | 1089 | { |
1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; | 1090 | kdDebug() << "KOTodoView::selectEvents(): not yet implemented" << endl; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 1093 | void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
1094 | const QDate &td) | 1094 | const QDate &td) |
1095 | { | 1095 | { |
1096 | #ifndef KORG_NOPRINTER | 1096 | #ifndef KORG_NOPRINTER |
1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); | 1097 | calPrinter->preview(CalPrinter::Todolist, fd, td); |
1098 | #endif | 1098 | #endif |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | void KOTodoView::editItem(QListViewItem *item ) | 1101 | void KOTodoView::editItem(QListViewItem *item ) |
1102 | { | 1102 | { |
1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); | 1103 | emit editTodoSignal(((KOTodoViewItem *)item)->todo()); |
1104 | } | 1104 | } |
1105 | 1105 | ||
1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) | 1106 | void KOTodoView::showItem(QListViewItem *item,const QPoint &,int) |
1107 | { | 1107 | { |
1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); | 1108 | emit showTodoSignal(((KOTodoViewItem *)item)->todo()); |
1109 | } | 1109 | } |
1110 | 1110 | ||
1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) | 1111 | void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column) |
1112 | { | 1112 | { |
1113 | pendingSubtodo = 0; | 1113 | pendingSubtodo = 0; |
1114 | mActiveItem = (KOTodoViewItem *)item; | 1114 | mActiveItem = (KOTodoViewItem *)item; |
1115 | if (item) { | 1115 | if (item) { |
1116 | switch (column){ | 1116 | switch (column){ |
1117 | case 1: | 1117 | case 1: |
1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; | 1118 | mPriorityPopupMenu->popup(QCursor::pos ()); break; |
1119 | case 2: | 1119 | case 2: |
1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; | 1120 | mPercentageCompletedPopupMenu->popup(QCursor::pos ()); break; |
1121 | case 3: | 1121 | case 3: |
1122 | moveTodo(); | 1122 | moveTodo(); |
1123 | break; | 1123 | break; |
1124 | case 7: | 1124 | case 7: |
1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; | 1125 | mCategoryPopupMenu->popup(QCursor::pos ()); break; |
1126 | case 8: | 1126 | case 8: |
1127 | mCalPopupMenu->popup(QCursor::pos ()); break; | 1127 | mCalPopupMenu->popup(QCursor::pos ()); break; |
1128 | default: | 1128 | default: |
1129 | mItemPopupMenu->popup(QCursor::pos()); | 1129 | mItemPopupMenu->popup(QCursor::pos()); |
1130 | } | 1130 | } |
1131 | } else mPopupMenu->popup(QCursor::pos()); | 1131 | } else mPopupMenu->popup(QCursor::pos()); |
1132 | } | 1132 | } |
1133 | void KOTodoView::newTodo() | 1133 | void KOTodoView::newTodo() |
1134 | { | 1134 | { |
1135 | emit newTodoSignal(); | 1135 | emit newTodoSignal(); |
1136 | } | 1136 | } |
1137 | 1137 | ||
1138 | void KOTodoView::newSubTodo() | 1138 | void KOTodoView::newSubTodo() |
1139 | { | 1139 | { |
1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1140 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1141 | if (mActiveItem) { | 1141 | if (mActiveItem) { |
1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { | 1142 | if ( mQuickAdd->isVisible() && !mQuickAdd->text().isEmpty() && mQuickAdd->text() != i18n("Click to add new Todo") ) { |
1143 | addQuickTodoPar( mActiveItem->todo()); | 1143 | addQuickTodoPar( mActiveItem->todo()); |
1144 | } else | 1144 | } else |
1145 | emit newSubTodoSignal(mActiveItem->todo()); | 1145 | emit newSubTodoSignal(mActiveItem->todo()); |
1146 | } | 1146 | } |
1147 | } | 1147 | } |
1148 | void KOTodoView::unparentTodo() | 1148 | void KOTodoView::unparentTodo() |
1149 | { | 1149 | { |
1150 | if (mActiveItem) { | 1150 | if (mActiveItem) { |
1151 | emit unparentTodoSignal(mActiveItem->todo()); | 1151 | emit unparentTodoSignal(mActiveItem->todo()); |
1152 | } | 1152 | } |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | void KOTodoView::reparentTodo() | 1155 | void KOTodoView::reparentTodo() |
1156 | { | 1156 | { |
1157 | if (mActiveItem) { | 1157 | if (mActiveItem) { |
1158 | topLevelWidget()->setCaption(i18n("Click on new parent item")); | 1158 | topLevelWidget()->setCaption(i18n("Click on new parent item")); |
1159 | pendingSubtodo = mActiveItem; | 1159 | pendingSubtodo = mActiveItem; |
1160 | } | 1160 | } |
1161 | } | 1161 | } |
1162 | void KOTodoView::editTodo() | 1162 | void KOTodoView::editTodo() |
1163 | { | 1163 | { |
1164 | if (mActiveItem) { | 1164 | if (mActiveItem) { |
1165 | emit editTodoSignal(mActiveItem->todo()); | 1165 | emit editTodoSignal(mActiveItem->todo()); |
1166 | } | 1166 | } |
1167 | } | 1167 | } |
1168 | void KOTodoView::cloneTodo() | 1168 | void KOTodoView::cloneTodo() |
1169 | { | 1169 | { |
1170 | if (mActiveItem) { | 1170 | if (mActiveItem) { |
1171 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); | 1171 | emit cloneTodoSignal((Incidence*)mActiveItem->todo()); |
1172 | } | 1172 | } |
1173 | } | 1173 | } |
1174 | void KOTodoView::cancelTodo() | 1174 | void KOTodoView::cancelTodo() |
1175 | { | 1175 | { |
1176 | if (mActiveItem) { | 1176 | if (mActiveItem) { |
1177 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); | 1177 | emit cancelTodoSignal((Incidence*)mActiveItem->todo()); |
1178 | } | 1178 | } |
1179 | } | 1179 | } |
1180 | void KOTodoView::moveTodo() | 1180 | void KOTodoView::moveTodo() |
1181 | { | 1181 | { |
1182 | if (mActiveItem) { | 1182 | if (mActiveItem) { |
1183 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); | 1183 | emit moveTodoSignal((Incidence*)mActiveItem->todo()); |
1184 | } | 1184 | } |
1185 | } | 1185 | } |
1186 | void KOTodoView::beamTodo() | 1186 | void KOTodoView::beamTodo() |
1187 | { | 1187 | { |
1188 | if (mActiveItem) { | 1188 | if (mActiveItem) { |
1189 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); | 1189 | emit beamTodoSignal((Incidence*)mActiveItem->todo()); |
1190 | } | 1190 | } |
1191 | } | 1191 | } |
1192 | 1192 | ||
1193 | 1193 | ||
1194 | void KOTodoView::showTodo() | 1194 | void KOTodoView::showTodo() |
1195 | { | 1195 | { |
1196 | if (mActiveItem) { | 1196 | if (mActiveItem) { |
1197 | emit showTodoSignal(mActiveItem->todo()); | 1197 | emit showTodoSignal(mActiveItem->todo()); |
1198 | } | 1198 | } |
1199 | } | 1199 | } |
1200 | 1200 | ||
1201 | void KOTodoView::deleteTodo() | 1201 | void KOTodoView::deleteTodo() |
1202 | { | 1202 | { |
1203 | if (mActiveItem) { | 1203 | if (mActiveItem) { |
1204 | emit deleteTodoSignal(mActiveItem->todo()); | 1204 | emit deleteTodoSignal(mActiveItem->todo()); |
1205 | } | 1205 | } |
1206 | } | 1206 | } |
1207 | 1207 | ||
1208 | void KOTodoView::setNewPriority(int index) | 1208 | void KOTodoView::setNewPriority(int index) |
1209 | { | 1209 | { |
1210 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1210 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1211 | mActiveItem->todo()->setPriority(mPriority[index]); | 1211 | mActiveItem->todo()->setPriority(mPriority[index]); |
1212 | mActiveItem->construct(); | 1212 | mActiveItem->construct(); |
1213 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); | 1213 | todoModified (mActiveItem->todo(), KOGlobals::PRIORITY_MODIFIED); |
1214 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1214 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1215 | } | 1215 | } |
1216 | processSelectionChange(); | 1216 | processSelectionChange(); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | void KOTodoView::setNewPercentage(int index) | 1219 | void KOTodoView::setNewPercentage(int index) |
1220 | { | 1220 | { |
1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1221 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1222 | 1222 | ||
1223 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { | 1223 | if ( mPercentage[index] == 100 && !mActiveItem->isOn() ) { |
1224 | mActiveItem->setOn( true ); | 1224 | mActiveItem->setOn( true ); |
1225 | processSelectionChange(); | 1225 | processSelectionChange(); |
1226 | return; | 1226 | return; |
1227 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { | 1227 | } else if ( mPercentage[index] != 100 && mActiveItem->isOn() ) { |
1228 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); | 1228 | KOTodoViewItem* par = (static_cast<KOTodoViewItem*>(mActiveItem->parent())); |
1229 | if ( par && par->isOn() ) | 1229 | if ( par && par->isOn() ) |
1230 | par->setOn( false ); | 1230 | par->setOn( false ); |
1231 | } | 1231 | } |
1232 | if (mPercentage[index] == 100) { | 1232 | if (mPercentage[index] == 100) { |
1233 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); | 1233 | mActiveItem->todo()->setCompleted(QDateTime::currentDateTime()); |
1234 | } else { | 1234 | } else { |
1235 | mActiveItem->todo()->setCompleted(false); | 1235 | mActiveItem->todo()->setCompleted(false); |
1236 | } | 1236 | } |
1237 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); | 1237 | mActiveItem->todo()->setPercentComplete(mPercentage[index]); |
1238 | mActiveItem->construct(); | 1238 | mActiveItem->construct(); |
1239 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); | 1239 | todoModified (mActiveItem->todo (), KOGlobals::COMPLETION_MODIFIED); |
1240 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1240 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1241 | } | 1241 | } |
1242 | processSelectionChange(); | 1242 | processSelectionChange(); |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | void KOTodoView::fillCategories () | 1245 | void KOTodoView::fillCategories () |
1246 | { | 1246 | { |
1247 | mCategoryPopupMenu->clear(); | 1247 | mCategoryPopupMenu->clear(); |
1248 | if ( ! mActiveItem ) return; | 1248 | if ( ! mActiveItem ) return; |
1249 | QStringList checkedCategories = mActiveItem->todo()->categories (); | 1249 | QStringList checkedCategories = mActiveItem->todo()->categories (); |
1250 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); | 1250 | for (QStringList::Iterator it = KOPrefs::instance()->mCustomCategories.begin (); |
1251 | it != KOPrefs::instance()->mCustomCategories.end (); | 1251 | it != KOPrefs::instance()->mCustomCategories.end (); |
1252 | ++it) { | 1252 | ++it) { |
1253 | int index = mCategoryPopupMenu->insertItem (*it); | 1253 | int index = mCategoryPopupMenu->insertItem (*it); |
1254 | mCategory[index] = *it; | 1254 | mCategory[index] = *it; |
1255 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); | 1255 | if (checkedCategories.find (*it) != checkedCategories.end ()) mCategoryPopupMenu->setItemChecked (index, true); |
1256 | } | 1256 | } |
1257 | } | 1257 | } |
1258 | void KOTodoView::fillCal () | 1258 | void KOTodoView::fillCal () |
1259 | { | 1259 | { |
1260 | mCalPopupMenu->clear(); | 1260 | mCalPopupMenu->clear(); |
1261 | if (!mActiveItem) return; | 1261 | if (!mActiveItem) return; |
1262 | bool readO = mActiveItem->todo()->isReadOnly(); | 1262 | bool readO = mActiveItem->todo()->isReadOnly(); |
1263 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); | 1263 | KopiCalendarFile * kkf = KOPrefs::instance()->mCalendars.first(); |
1264 | while ( kkf ) { | 1264 | while ( kkf ) { |
1265 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); | 1265 | int index = mCalPopupMenu->insertItem( kkf->mName, kkf->mCalNumber); |
1266 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) | 1266 | if ( kkf->mErrorOnLoad || kkf->isReadOnly || readO ) |
1267 | mCalPopupMenu->setItemEnabled( index, false ); | 1267 | mCalPopupMenu->setItemEnabled( index, false ); |
1268 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); | 1268 | mCalPopupMenu->setItemChecked (index, kkf->mCalNumber == mActiveItem->todo()->calID()); |
1269 | kkf = KOPrefs::instance()->mCalendars.next(); | 1269 | kkf = KOPrefs::instance()->mCalendars.next(); |
1270 | } | 1270 | } |
1271 | } | 1271 | } |
1272 | void KOTodoView::changedCal (int index ) | 1272 | void KOTodoView::changedCal (int index ) |
1273 | { | 1273 | { |
1274 | if (!mActiveItem) return; | 1274 | if (!mActiveItem) return; |
1275 | mActiveItem->todo()->setCalID( index ); | 1275 | mActiveItem->todo()->setCalID( index ); |
1276 | mActiveItem->construct(); | 1276 | mActiveItem->construct(); |
1277 | } | 1277 | } |
1278 | void KOTodoView::changedCategories(int index) | 1278 | void KOTodoView::changedCategories(int index) |
1279 | { | 1279 | { |
1280 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { | 1280 | if (mActiveItem && !mActiveItem->todo()->isReadOnly ()) { |
1281 | QStringList categories = mActiveItem->todo()->categories (); | 1281 | QStringList categories = mActiveItem->todo()->categories (); |
1282 | QString colcat = categories.first(); | 1282 | QString colcat = categories.first(); |
1283 | if (categories.find (mCategory[index]) != categories.end ()) | 1283 | if (categories.find (mCategory[index]) != categories.end ()) |
1284 | categories.remove (mCategory[index]); | 1284 | categories.remove (mCategory[index]); |
1285 | else | 1285 | else |
1286 | categories.insert (categories.end(), mCategory[index]); | 1286 | categories.insert (categories.end(), mCategory[index]); |
1287 | categories.sort (); | 1287 | categories.sort (); |
1288 | if ( !colcat.isEmpty() ) { | 1288 | if ( !colcat.isEmpty() ) { |
1289 | if ( categories.find ( colcat ) != categories.end () ) { | 1289 | if ( categories.find ( colcat ) != categories.end () ) { |
1290 | categories.remove( colcat ); | 1290 | categories.remove( colcat ); |
1291 | categories.prepend( colcat ); | 1291 | categories.prepend( colcat ); |
1292 | } | 1292 | } |
1293 | } | 1293 | } |
1294 | mActiveItem->todo()->setCategories (categories); | 1294 | mActiveItem->todo()->setCategories (categories); |
1295 | mActiveItem->construct(); | 1295 | mActiveItem->construct(); |
1296 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); | 1296 | mActiveItem->todo()->setRevision( mActiveItem->todo()->revision()+1 ); |
1297 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); | 1297 | todoModified (mActiveItem->todo (), KOGlobals::CATEGORY_MODIFIED); |
1298 | } | 1298 | } |
1299 | } | 1299 | } |
1300 | void KOTodoView::itemDoubleClicked(QListViewItem *item) | 1300 | void KOTodoView::itemDoubleClicked(QListViewItem *item) |
1301 | { | 1301 | { |
1302 | if ( pendingSubtodo != 0 ) { | 1302 | if ( pendingSubtodo != 0 ) { |
1303 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1303 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1304 | } | 1304 | } |
1305 | pendingSubtodo = 0; | 1305 | pendingSubtodo = 0; |
1306 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); | 1306 | //int row = mTodoListView->header()->sectionAt ( mTodoListView->header()->mapFromGlobal( QCursor::pos()).x() ); |
1307 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); | 1307 | int row = mTodoListView->header()->sectionAt ( mTodoListView->viewportToContents(mTodoListView->viewport()->mapFromGlobal( QCursor::pos())) .x() ); |
1308 | //qDebug("ROW %d ", row); | 1308 | //qDebug("ROW %d ", row); |
1309 | if (!item) { | 1309 | if (!item) { |
1310 | newTodo(); | 1310 | newTodo(); |
1311 | return; | 1311 | return; |
1312 | } else { | 1312 | } else { |
1313 | if ( row == 1 ) { | 1313 | if ( row == 1 ) { |
1314 | mActiveItem = (KOTodoViewItem *) item; | 1314 | mActiveItem = (KOTodoViewItem *) item; |
1315 | newSubTodo(); | 1315 | newSubTodo(); |
1316 | return; | 1316 | return; |
1317 | } | 1317 | } |
1318 | if ( row == 5 || row == 6 || row == 2) { | 1318 | if ( row == 5 || row == 6 || row == 2) { |
1319 | mActiveItem = (KOTodoViewItem *) item; | 1319 | mActiveItem = (KOTodoViewItem *) item; |
1320 | Todo * t = mActiveItem->todo(); | 1320 | Todo * t = mActiveItem->todo(); |
1321 | if ( t->isRunning() ) { | 1321 | if ( t->isRunning() ) { |
1322 | if ( t->runTime() < 15) { | 1322 | if ( t->runTime() < 15) { |
1323 | t->stopRunning(); | 1323 | t->stopRunning(); |
1324 | mActiveItem->construct(); | 1324 | mActiveItem->construct(); |
1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); | 1325 | topLevelWidget()->setCaption(i18n("Todo stopped - no data saved because runtime was < 15 sec!")); |
1326 | return; | 1326 | return; |
1327 | } | 1327 | } |
1328 | else | 1328 | else |
1329 | toggleRunningItem(); | 1329 | toggleRunningItem(); |
1330 | return; | 1330 | return; |
1331 | } else { | 1331 | } else { |
1332 | t->setRunning( true ); | 1332 | t->setRunning( true ); |
1333 | mActiveItem->construct(); | 1333 | mActiveItem->construct(); |
1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); | 1334 | topLevelWidget()->setCaption(i18n("Todo started! Double click again to stop!")); |
1335 | return; | 1335 | return; |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) | 1339 | if ( KOPrefs::instance()->mEditOnDoubleClick ) |
1340 | editItem( item ); | 1340 | editItem( item ); |
1341 | else | 1341 | else |
1342 | showItem( item , QPoint(), 0 ); | 1342 | showItem( item , QPoint(), 0 ); |
1343 | } | 1343 | } |
1344 | void KOTodoView::toggleRunningItem() | 1344 | void KOTodoView::toggleRunningItem() |
1345 | { | 1345 | { |
1346 | // qDebug("KOTodoView::toggleRunning() "); | 1346 | // qDebug("KOTodoView::toggleRunning() "); |
1347 | if ( ! mActiveItem ) | 1347 | if ( ! mActiveItem ) |
1348 | return; | 1348 | return; |
1349 | Todo * t = mActiveItem->todo(); | 1349 | Todo * t = mActiveItem->todo(); |
1350 | if ( t->isRunning() ) { | 1350 | if ( t->isRunning() ) { |
1351 | KOStopTodoPrefs tp ( t, this ); | 1351 | KOStopTodoPrefs tp ( t, this ); |
1352 | if (QApplication::desktop()->width() <= 800 ){ | 1352 | if (QApplication::desktop()->width() <= 800 ){ |
1353 | int wid = tp.width(); | 1353 | int wid = tp.width(); |
1354 | int hei = tp.height(); | 1354 | int hei = tp.height(); |
1355 | int xx = (QApplication::desktop()->width()-wid)/2; | 1355 | int xx = (QApplication::desktop()->width()-wid)/2; |
1356 | int yy = (QApplication::desktop()->height()-hei)/2; | 1356 | int yy = (QApplication::desktop()->height()-hei)/2; |
1357 | tp.setGeometry( xx,yy,wid,hei ); | 1357 | tp.setGeometry( xx,yy,wid,hei ); |
1358 | } | 1358 | } |
1359 | tp.exec(); | 1359 | tp.exec(); |
1360 | mActiveItem->construct(); | 1360 | updateTodo ( t, 0 ); |
1361 | } else { | 1361 | } else { |
1362 | KOStartTodoPrefs tp ( t->summary(), this ); | 1362 | KOStartTodoPrefs tp ( t->summary(), this ); |
1363 | if (QApplication::desktop()->width() <= 800 ){ | 1363 | if (QApplication::desktop()->width() <= 800 ){ |
1364 | int wid = tp.width(); | 1364 | int wid = tp.width(); |
1365 | int hei = tp.height(); | 1365 | int hei = tp.height(); |
1366 | int xx = (QApplication::desktop()->width()-wid)/2; | 1366 | int xx = (QApplication::desktop()->width()-wid)/2; |
1367 | int yy = (QApplication::desktop()->height()-hei)/2; | 1367 | int yy = (QApplication::desktop()->height()-hei)/2; |
1368 | tp.setGeometry( xx,yy,wid,hei ); | 1368 | tp.setGeometry( xx,yy,wid,hei ); |
1369 | } | 1369 | } |
1370 | if ( !tp.exec() ) return; | 1370 | if ( !tp.exec() ) return; |
1371 | if ( tp.stopAll() ) { | 1371 | if ( tp.stopAll() ) { |
1372 | mCalendar->stopAllTodos(); | 1372 | mCalendar->stopAllTodos(); |
1373 | t->setRunning( true ); | 1373 | t->setRunning( true ); |
1374 | updateView(); | 1374 | updateView(); |
1375 | } else { | 1375 | } else { |
1376 | t->setRunning( true ); | 1376 | t->setRunning( true ); |
1377 | mActiveItem->construct(); | 1377 | updateTodo ( t, 0 ); |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | void KOTodoView::itemClicked(QListViewItem *item) | 1382 | void KOTodoView::itemClicked(QListViewItem *item) |
1383 | { | 1383 | { |
1384 | //qDebug("KOTodoView::itemClicked %d", item); | 1384 | //qDebug("KOTodoView::itemClicked %d", item); |
1385 | if (!item) { | 1385 | if (!item) { |
1386 | if ( pendingSubtodo != 0 ) { | 1386 | if ( pendingSubtodo != 0 ) { |
1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); | 1387 | topLevelWidget()->setCaption(i18n("Reparenting aborted!")); |
1388 | } | 1388 | } |
1389 | pendingSubtodo = 0; | 1389 | pendingSubtodo = 0; |
1390 | return; | 1390 | return; |
1391 | } | 1391 | } |
1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1392 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1393 | if ( pendingSubtodo != 0 ) { | 1393 | if ( pendingSubtodo != 0 ) { |
1394 | bool allowReparent = true; | 1394 | bool allowReparent = true; |
1395 | QListViewItem *par = item; | 1395 | QListViewItem *par = item; |
1396 | while ( par ) { | 1396 | while ( par ) { |
1397 | if ( par == pendingSubtodo ) { | 1397 | if ( par == pendingSubtodo ) { |
1398 | allowReparent = false; | 1398 | allowReparent = false; |
1399 | break; | 1399 | break; |
1400 | } | 1400 | } |
1401 | par = par->parent(); | 1401 | par = par->parent(); |
1402 | } | 1402 | } |
1403 | if ( !allowReparent ) { | 1403 | if ( !allowReparent ) { |
1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); | 1404 | topLevelWidget()->setCaption(i18n("Recursive reparenting not possible!")); |
1405 | pendingSubtodo = 0; | 1405 | pendingSubtodo = 0; |
1406 | } else { | 1406 | } else { |
1407 | Todo* newParent = todoItem->todo(); | 1407 | Todo* newParent = todoItem->todo(); |
1408 | Todo* newSub = pendingSubtodo->todo(); | 1408 | Todo* newSub = pendingSubtodo->todo(); |
1409 | pendingSubtodo = 0; | 1409 | pendingSubtodo = 0; |
1410 | emit reparentTodoSignal( newParent,newSub ); | 1410 | emit reparentTodoSignal( newParent,newSub ); |
1411 | return; | 1411 | return; |
1412 | } | 1412 | } |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | } | 1415 | } |
1416 | 1416 | ||
1417 | void KOTodoView::setDocumentId( const QString &id ) | 1417 | void KOTodoView::setDocumentId( const QString &id ) |
1418 | { | 1418 | { |
1419 | 1419 | ||
1420 | mDocPrefs->setDoc( id ); | 1420 | mDocPrefs->setDoc( id ); |
1421 | } | 1421 | } |
1422 | 1422 | ||
1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) | 1423 | void KOTodoView::itemStateChanged( QListViewItem *item ) |
1424 | { | 1424 | { |
1425 | if (!item) return; | 1425 | if (!item) return; |
1426 | 1426 | ||
1427 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; | 1427 | KOTodoViewItem *todoItem = (KOTodoViewItem *)item; |
1428 | 1428 | ||
1429 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; | 1429 | // kdDebug() << "KOTodoView::itemStateChanged(): " << todoItem->todo()->summary() << endl; |
1430 | 1430 | ||
1431 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); | 1431 | if( mDocPrefs ) mDocPrefs->writeEntry( todoItem->todo()->uid(), todoItem->isOpen() ); |
1432 | } | 1432 | } |
1433 | 1433 | ||
1434 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const | 1434 | void KOTodoView::saveLayout(KConfig *config, const QString &group) const |
1435 | { | 1435 | { |
1436 | mTodoListView->saveLayout(config,group); | 1436 | mTodoListView->saveLayout(config,group); |
1437 | } | 1437 | } |
1438 | 1438 | ||
1439 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) | 1439 | void KOTodoView::restoreLayout(KConfig *config, const QString &group) |
1440 | { | 1440 | { |
1441 | mTodoListView->restoreLayout(config,group); | 1441 | mTodoListView->restoreLayout(config,group); |
1442 | } | 1442 | } |
1443 | 1443 | ||
1444 | void KOTodoView::processSelectionChange() | 1444 | void KOTodoView::processSelectionChange() |
1445 | { | 1445 | { |
1446 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; | 1446 | // kdDebug() << "KOTodoView::processSelectionChange()" << endl; |
1447 | 1447 | ||
1448 | KOTodoViewItem *item = | 1448 | KOTodoViewItem *item = |
1449 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); | 1449 | static_cast<KOTodoViewItem *>( mTodoListView->selectedItem() ); |
1450 | 1450 | ||
1451 | if ( !item ) { | 1451 | if ( !item ) { |
1452 | emit incidenceSelected( 0 ); | 1452 | emit incidenceSelected( 0 ); |
1453 | mNewSubBut->setEnabled( false ); | 1453 | mNewSubBut->setEnabled( false ); |
1454 | } else { | 1454 | } else { |
1455 | emit incidenceSelected( item->todo() ); | 1455 | emit incidenceSelected( item->todo() ); |
1456 | mNewSubBut->setEnabled( true ); | 1456 | mNewSubBut->setEnabled( true ); |
1457 | } | 1457 | } |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | void KOTodoView::modified(bool b) | 1460 | void KOTodoView::modified(bool b) |
1461 | { | 1461 | { |
1462 | emit isModified(b); | 1462 | emit isModified(b); |
1463 | } | 1463 | } |
1464 | void KOTodoView::setTodoModified( Todo* todo ) | 1464 | void KOTodoView::setTodoModified( Todo* todo ) |
1465 | { | 1465 | { |
1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); | 1466 | todoModified( todo, KOGlobals::UNKNOWN_MODIFIED ); |
1467 | } | 1467 | } |
1468 | void KOTodoView::clearSelection() | 1468 | void KOTodoView::clearSelection() |
1469 | { | 1469 | { |
1470 | mTodoListView->selectAll( false ); | 1470 | mTodoListView->selectAll( false ); |
1471 | } | 1471 | } |
1472 | void KOTodoView::setAllOpen() | 1472 | void KOTodoView::setAllOpen() |
1473 | { | 1473 | { |
1474 | if ( isFlatDisplay ) { | 1474 | if ( isFlatDisplay ) { |
1475 | isFlatDisplay = false; | 1475 | isFlatDisplay = false; |
1476 | mPopupMenu->setItemChecked( 8,false ); | 1476 | mPopupMenu->setItemChecked( 8,false ); |
1477 | updateView(); | 1477 | updateView(); |
1478 | } else { | 1478 | } else { |
1479 | storeCurrentItem(); | 1479 | storeCurrentItem(); |
1480 | } | 1480 | } |
1481 | setOpen(mTodoListView->firstChild(), true); | 1481 | setOpen(mTodoListView->firstChild(), true); |
1482 | resetCurrentItem(); | 1482 | resetCurrentItem(); |
1483 | } | 1483 | } |
1484 | void KOTodoView::setAllClose() | 1484 | void KOTodoView::setAllClose() |
1485 | { | 1485 | { |
1486 | if ( isFlatDisplay ) { | 1486 | if ( isFlatDisplay ) { |
1487 | isFlatDisplay = false; | 1487 | isFlatDisplay = false; |
1488 | mPopupMenu->setItemChecked( 8,false ); | 1488 | mPopupMenu->setItemChecked( 8,false ); |
1489 | updateView(); | 1489 | updateView(); |
1490 | } else { | 1490 | } else { |
1491 | storeCurrentItem(); | 1491 | storeCurrentItem(); |
1492 | } | 1492 | } |
1493 | setOpen(mTodoListView->firstChild(), false); | 1493 | setOpen(mTodoListView->firstChild(), false); |
1494 | resetCurrentItem(); | 1494 | resetCurrentItem(); |
1495 | } | 1495 | } |
1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) | 1496 | void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) |
1497 | { | 1497 | { |
1498 | 1498 | ||
1499 | while ( item ) { | 1499 | while ( item ) { |
1500 | setOpen( item->firstChild(), setOpenI ); | 1500 | setOpen( item->firstChild(), setOpenI ); |
1501 | item->setOpen( setOpenI ); | 1501 | item->setOpen( setOpenI ); |
1502 | item = item->nextSibling(); | 1502 | item = item->nextSibling(); |
1503 | } | 1503 | } |
1504 | } | 1504 | } |
1505 | 1505 | ||
1506 | void KOTodoView::displayAllFlat() | 1506 | void KOTodoView::displayAllFlat() |
1507 | { | 1507 | { |
1508 | storeCurrentItem(); | 1508 | storeCurrentItem(); |
1509 | pendingSubtodo = 0; | 1509 | pendingSubtodo = 0; |
1510 | if ( mBlockUpdate ) { | 1510 | if ( mBlockUpdate ) { |
1511 | return; | 1511 | return; |
1512 | } | 1512 | } |
1513 | mPopupMenu->setItemChecked( 8,true ); | 1513 | mPopupMenu->setItemChecked( 8,true ); |
1514 | isFlatDisplay = true; | 1514 | isFlatDisplay = true; |
1515 | QPtrList<Todo> todoList = calendar()->todos(); | 1515 | QPtrList<Todo> todoList = calendar()->todos(); |
1516 | mTodoMap.clear(); | 1516 | mTodoMap.clear(); |
1517 | mTodoListView->clear(); | 1517 | mTodoListView->clear(); |
1518 | Todo *todo; | 1518 | Todo *todo; |
1519 | for(todo = todoList.first(); todo; todo = todoList.next()) { | 1519 | for(todo = todoList.first(); todo; todo = todoList.next()) { |
1520 | if ( checkTodo( todo ) ) { | 1520 | if ( checkTodo( todo ) ) { |
1521 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); | 1521 | KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); |
1522 | mTodoMap.insert(todo,todoItem); | 1522 | mTodoMap.insert(todo,todoItem); |
1523 | } | 1523 | } |
1524 | } | 1524 | } |
1525 | resetCurrentItem(); | 1525 | resetCurrentItem(); |
1526 | } | 1526 | } |
1527 | 1527 | ||
1528 | void KOTodoView::setAllFlat() | 1528 | void KOTodoView::setAllFlat() |
1529 | { | 1529 | { |
1530 | if ( isFlatDisplay ) { | 1530 | if ( isFlatDisplay ) { |
1531 | isFlatDisplay = false; | 1531 | isFlatDisplay = false; |
1532 | mPopupMenu->setItemChecked( 8,false ); | 1532 | mPopupMenu->setItemChecked( 8,false ); |
1533 | updateView(); | 1533 | updateView(); |
1534 | return; | 1534 | return; |
1535 | } | 1535 | } |
1536 | displayAllFlat(); | 1536 | displayAllFlat(); |
1537 | } | 1537 | } |
1538 | 1538 | ||
1539 | void KOTodoView::purgeCompleted() | 1539 | void KOTodoView::purgeCompleted() |
1540 | { | 1540 | { |
1541 | emit purgeCompletedSignal(); | 1541 | emit purgeCompletedSignal(); |
1542 | 1542 | ||
1543 | } | 1543 | } |
1544 | void KOTodoView::toggleQuickTodo() | 1544 | void KOTodoView::toggleQuickTodo() |
1545 | { | 1545 | { |
1546 | if ( mQuickBar->isVisible() ) { | 1546 | if ( mQuickBar->isVisible() ) { |
1547 | mQuickBar->hide(); | 1547 | mQuickBar->hide(); |
1548 | KOPrefs::instance()->mEnableQuickTodo = false; | 1548 | KOPrefs::instance()->mEnableQuickTodo = false; |
1549 | } | 1549 | } |
1550 | else { | 1550 | else { |
1551 | mQuickBar->show(); | 1551 | mQuickBar->show(); |
1552 | KOPrefs::instance()->mEnableQuickTodo = true; | 1552 | KOPrefs::instance()->mEnableQuickTodo = true; |
1553 | } | 1553 | } |
1554 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); | 1554 | mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); |
1555 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); | 1555 | mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); |
1556 | } | 1556 | } |
1557 | 1557 | ||
1558 | void KOTodoView::toggleRunning() | 1558 | void KOTodoView::toggleRunning() |
1559 | { | 1559 | { |
1560 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; | 1560 | KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; |
1561 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); | 1561 | mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); |
1562 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); | 1562 | mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); |
1563 | updateView(); | 1563 | updateView(); |
1564 | if ( KOPrefs::instance()->mHideNonStartedTodos ) | 1564 | if ( KOPrefs::instance()->mHideNonStartedTodos ) |
1565 | topLevelWidget()->setCaption(i18n("Hide not Running")); | 1565 | topLevelWidget()->setCaption(i18n("Hide not Running")); |
1566 | else | 1566 | else |
1567 | topLevelWidget()->setCaption(i18n("Show not Running")); | 1567 | topLevelWidget()->setCaption(i18n("Show not Running")); |
1568 | } | 1568 | } |
1569 | 1569 | ||
1570 | void KOTodoView::toggleCompleted() | 1570 | void KOTodoView::toggleCompleted() |
1571 | { | 1571 | { |
1572 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; | 1572 | KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; |
1573 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); | 1573 | mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); |
1574 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); | 1574 | mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); |
1575 | updateView(); | 1575 | updateView(); |
1576 | if ( KOPrefs::instance()->mShowCompletedTodo ) | 1576 | if ( KOPrefs::instance()->mShowCompletedTodo ) |
1577 | topLevelWidget()->setCaption(i18n("Show Completed")); | 1577 | topLevelWidget()->setCaption(i18n("Show Completed")); |
1578 | else | 1578 | else |
1579 | topLevelWidget()->setCaption(i18n("Hide Completed")); | 1579 | topLevelWidget()->setCaption(i18n("Hide Completed")); |
1580 | } | 1580 | } |
1581 | 1581 | ||
1582 | void KOTodoView::addQuickTodo() | 1582 | void KOTodoView::addQuickTodo() |
1583 | { | 1583 | { |
1584 | addQuickTodoPar( 0 ); | 1584 | addQuickTodoPar( 0 ); |
1585 | } | 1585 | } |
1586 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) | 1586 | void KOTodoView::addQuickTodoPar( Todo * parentTodo) |
1587 | { | 1587 | { |
1588 | Todo *todo = new Todo(); | 1588 | Todo *todo = new Todo(); |
1589 | todo->setSummary(mQuickAdd->text()); | 1589 | todo->setSummary(mQuickAdd->text()); |
1590 | todo->setOrganizer(KOPrefs::instance()->email()); | 1590 | todo->setOrganizer(KOPrefs::instance()->email()); |
1591 | if ( parentTodo ) { | 1591 | if ( parentTodo ) { |
1592 | todo->setRelatedTo(parentTodo); | 1592 | todo->setRelatedTo(parentTodo); |
1593 | 1593 | ||
1594 | todo->setCategories (parentTodo->categoriesStr ()); | 1594 | todo->setCategories (parentTodo->categoriesStr ()); |
1595 | todo->setSecrecy (parentTodo->secrecy ()); | 1595 | todo->setSecrecy (parentTodo->secrecy ()); |
1596 | if ( parentTodo->priority() < 3 ) | 1596 | if ( parentTodo->priority() < 3 ) |
1597 | todo->setPriority( parentTodo->priority() ); | 1597 | todo->setPriority( parentTodo->priority() ); |
1598 | todo->setCalID( parentTodo->calID() ); | 1598 | todo->setCalID( parentTodo->calID() ); |
1599 | } else { | 1599 | } else { |
1600 | CalFilter * cf = mCalendar->filter(); | 1600 | CalFilter * cf = mCalendar->filter(); |
1601 | if ( cf ) { | 1601 | if ( cf ) { |
1602 | if ( cf->isEnabled()&& cf->showCategories()) { | 1602 | if ( cf->isEnabled()&& cf->showCategories()) { |
1603 | todo->setCategories(cf->categoryList()); | 1603 | todo->setCategories(cf->categoryList()); |
1604 | } | 1604 | } |
1605 | if ( cf->isEnabled() ) | 1605 | if ( cf->isEnabled() ) |
1606 | todo->setSecrecy( cf->getSecrecy()); | 1606 | todo->setSecrecy( cf->getSecrecy()); |
1607 | } | 1607 | } |
1608 | } | 1608 | } |
1609 | mCalendar->addTodo(todo); | 1609 | mCalendar->addTodo(todo); |
1610 | mQuickAdd->setText(""); | 1610 | mQuickAdd->setText(""); |
1611 | todoModified (todo, KOGlobals::EVENTADDED ); | 1611 | todoModified (todo, KOGlobals::EVENTADDED ); |
1612 | updateView(); | 1612 | updateView(); |
1613 | 1613 | ||
1614 | } | 1614 | } |
1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) | 1615 | void KOTodoView::keyPressEvent ( QKeyEvent * e ) |
1616 | { | 1616 | { |
1617 | // e->ignore(); | 1617 | // e->ignore(); |
1618 | //return; | 1618 | //return; |
1619 | if ( !isVisible() ) { | 1619 | if ( !isVisible() ) { |
1620 | e->ignore(); | 1620 | e->ignore(); |
1621 | return; | 1621 | return; |
1622 | } | 1622 | } |
1623 | switch ( e->key() ) { | 1623 | switch ( e->key() ) { |
1624 | case Qt::Key_Down: | 1624 | case Qt::Key_Down: |
1625 | case Qt::Key_Up: | 1625 | case Qt::Key_Up: |
1626 | // KOrg::BaseView::keyPressEvent ( e ); | 1626 | // KOrg::BaseView::keyPressEvent ( e ); |
1627 | e->ignore(); | 1627 | e->ignore(); |
1628 | break; | 1628 | break; |
1629 | 1629 | ||
1630 | case Qt::Key_Q: | 1630 | case Qt::Key_Q: |
1631 | 1631 | ||
1632 | 1632 | ||
1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { | 1633 | if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton ) { |
1634 | e->ignore(); | 1634 | e->ignore(); |
1635 | break; | 1635 | break; |
1636 | } | 1636 | } |
1637 | toggleQuickTodo(); | 1637 | toggleQuickTodo(); |
1638 | break; | 1638 | break; |
1639 | case Qt::Key_U: | 1639 | case Qt::Key_U: |
1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1640 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1641 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1642 | unparentTodo(); | 1642 | unparentTodo(); |
1643 | e->accept(); | 1643 | e->accept(); |
1644 | } else | 1644 | } else |
1645 | e->ignore(); | 1645 | e->ignore(); |
1646 | break; | 1646 | break; |
1647 | case Qt::Key_S: | 1647 | case Qt::Key_S: |
1648 | if ( e->state() == Qt::ControlButton ) { | 1648 | if ( e->state() == Qt::ControlButton ) { |
1649 | e->ignore(); | 1649 | e->ignore(); |
1650 | break; | 1650 | break; |
1651 | } | 1651 | } |
1652 | if ( e->state() == Qt::ShiftButton ) { | 1652 | if ( e->state() == Qt::ShiftButton ) { |
1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1653 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1654 | reparentTodo(); | 1654 | reparentTodo(); |
1655 | e->accept(); | 1655 | e->accept(); |
1656 | } else | 1656 | } else |
1657 | e->ignore(); | 1657 | e->ignore(); |
1658 | break; | 1658 | break; |
1659 | case Qt::Key_P: | 1659 | case Qt::Key_P: |
1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { | 1660 | if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { |
1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); | 1661 | mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); |
1662 | if ( pendingSubtodo ) | 1662 | if ( pendingSubtodo ) |
1663 | itemClicked(mActiveItem); | 1663 | itemClicked(mActiveItem); |
1664 | e->accept(); | 1664 | e->accept(); |
1665 | } else | 1665 | } else |
1666 | e->ignore(); | 1666 | e->ignore(); |
1667 | break; | 1667 | break; |
1668 | case Qt::Key_Escape: | 1668 | case Qt::Key_Escape: |
1669 | if ( pendingSubtodo ) { | 1669 | if ( pendingSubtodo ) { |
1670 | itemClicked(0); | 1670 | itemClicked(0); |
1671 | e->accept(); | 1671 | e->accept(); |
1672 | } else | 1672 | } else |
1673 | e->ignore(); | 1673 | e->ignore(); |
1674 | break; | 1674 | break; |
1675 | default: | 1675 | default: |
1676 | e->ignore(); | 1676 | e->ignore(); |
1677 | } | 1677 | } |
1678 | 1678 | ||
1679 | if ( true ) { | 1679 | if ( true ) { |
1680 | if ( e->key() == Qt::Key_I ) { | 1680 | if ( e->key() == Qt::Key_I ) { |
1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); | 1681 | KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); |
1682 | if ( cn ) { | 1682 | if ( cn ) { |
1683 | mActiveItem = cn; | 1683 | mActiveItem = cn; |
1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); | 1684 | KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); |
1685 | if ( ci ){ | 1685 | if ( ci ){ |
1686 | showTodo(); | 1686 | showTodo(); |
1687 | cn = (KOTodoViewItem*)cn->itemBelow(); | 1687 | cn = (KOTodoViewItem*)cn->itemBelow(); |
1688 | if ( cn ) { | 1688 | if ( cn ) { |
1689 | mTodoListView->setCurrentItem ( cn ); | 1689 | mTodoListView->setCurrentItem ( cn ); |
1690 | mTodoListView->ensureItemVisible ( cn ); | 1690 | mTodoListView->ensureItemVisible ( cn ); |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | } | 1693 | } |
1694 | } | 1694 | } |
1695 | e->accept(); | 1695 | e->accept(); |
1696 | 1696 | ||
1697 | } | 1697 | } |
1698 | 1698 | ||
1699 | } | 1699 | } |
1700 | 1700 | ||
1701 | } | 1701 | } |
1702 | void KOTodoView::updateTodo( Todo * t, int type ) | 1702 | void KOTodoView::updateTodo( Todo * t, int type ) |
1703 | { | 1703 | { |
1704 | if ( mBlockUpdate) | 1704 | if ( mBlockUpdate) |
1705 | return; | 1705 | return; |
1706 | 1706 | ||
1707 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; | 1707 | QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; |
1708 | itemIterator = mTodoMap.find(t); | 1708 | itemIterator = mTodoMap.find(t); |
1709 | if (itemIterator != mTodoMap.end()) { | 1709 | if (itemIterator != mTodoMap.end()) { |
1710 | (*itemIterator)->construct(); | 1710 | (*itemIterator)->construct(); |
1711 | } else { | 1711 | } else { |
1712 | if ( type == KOGlobals::EVENTADDED ) { | 1712 | if ( type == KOGlobals::EVENTADDED ) { |
1713 | insertTodoItem( t ); | 1713 | insertTodoItem( t ); |
1714 | } | 1714 | } |
1715 | } | 1715 | } |
1716 | 1716 | ||
1717 | } | 1717 | } |
1718 | 1718 | ||
1719 | void KOTodoView::todoModified(Todo * t , int p ) | 1719 | void KOTodoView::todoModified(Todo * t , int p ) |
1720 | { | 1720 | { |
1721 | mBlockUpdate = true; | 1721 | mBlockUpdate = true; |
1722 | emit todoModifiedSignal ( t, p ); | 1722 | emit todoModifiedSignal ( t, p ); |
1723 | mBlockUpdate = false; | 1723 | mBlockUpdate = false; |
1724 | } | 1724 | } |