summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-03-31 23:55:51 (UTC)
committer zautrix <zautrix>2005-03-31 23:55:51 (UTC)
commitb76ad1e7e329051a47e28c9d132ce3fcd0b25c5c (patch) (unidiff)
treeb0b3d0eb7a3d29981c183275aadeed0cbbef0007 /korganizer
parentc0fa26aa3b33c293853bdd7d028ddb0545e33c85 (diff)
downloadkdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.zip
kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.gz
kdepimpi-b76ad1e7e329051a47e28c9d132ce3fcd0b25c5c.tar.bz2
fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagenda.cpp5
-rw-r--r--korganizer/koagenda.h2
-rw-r--r--korganizer/koagendaview.cpp15
-rw-r--r--korganizer/koagendaview.h1
-rw-r--r--korganizer/komonthview.cpp7
-rw-r--r--korganizer/kotodoview.cpp103
-rw-r--r--korganizer/kotodoview.h5
-rw-r--r--korganizer/koviewmanager.cpp4
8 files changed, 109 insertions, 33 deletions
diff --git a/korganizer/koagenda.cpp b/korganizer/koagenda.cpp
index 1a24887..9720f43 100644
--- a/korganizer/koagenda.cpp
+++ b/korganizer/koagenda.cpp
@@ -147,193 +147,193 @@ void MarcusBains::updateLocation(bool recalculate)
147 // somewhere, where the last column of this widget is a few pixels 147 // somewhere, where the last column of this widget is a few pixels
148 // narrower than the other columns. 148 // narrower than the other columns.
149 int offs = (today==agenda->columns()-1) ? -4 : 0; 149 int offs = (today==agenda->columns()-1) ? -4 : 0;
150 agenda->moveChild(mTimeBox, 150 agenda->moveChild(mTimeBox,
151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1, 151 x+agenda->gridSpacingX()-mTimeBox->width()+offs-1,
152 y-mTimeBox->height()); 152 y-mTimeBox->height());
153 153
154 mTimeBox->raise(); 154 mTimeBox->raise();
155 //mTimeBox->setAutoMask(true); 155 //mTimeBox->setAutoMask(true);
156 minutes->start(5000,true); 156 minutes->start(5000,true);
157} 157}
158 158
159 159
160//////////////////////////////////////////////////////////////////////////// 160////////////////////////////////////////////////////////////////////////////
161 161
162 162
163/* 163/*
164 Create an agenda widget with rows rows and columns columns. 164 Create an agenda widget with rows rows and columns columns.
165*/ 165*/
166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent, 166KOAgenda::KOAgenda(int columns,int rows,int rowSize,QWidget *parent,
167 const char *name,WFlags f) : 167 const char *name,WFlags f) :
168 QScrollView(parent,name,f) 168 QScrollView(parent,name,f)
169{ 169{
170 170
171 171
172 mColumns = columns; 172 mColumns = columns;
173 mRows = rows; 173 mRows = rows;
174 mGridSpacingY = rowSize; 174 mGridSpacingY = rowSize;
175 mAllDayMode = false; 175 mAllDayMode = false;
176#ifndef DESKTOP_VERSION 176#ifndef DESKTOP_VERSION
177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 177 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
178#endif 178#endif
179 mHolidayMask = 0; 179 mHolidayMask = 0;
180 init(); 180 init();
181} 181}
182 182
183/* 183/*
184 Create an agenda widget with columns columns and one row. This is used for 184 Create an agenda widget with columns columns and one row. This is used for
185 all-day events. 185 all-day events.
186*/ 186*/
187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) : 187KOAgenda::KOAgenda(int columns,QWidget *parent,const char *name,WFlags f) :
188 QScrollView(parent,name,f) 188 QScrollView(parent,name,f)
189{ 189{
190 blockResize = false; 190 blockResize = false;
191 mColumns = columns; 191 mColumns = columns;
192 mRows = 1; 192 mRows = 1;
193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize); 193 //qDebug("aaaaaaaaaaaaaaaaaaldays %d ", KOPrefs::instance()->mAllDaySize);
194 mGridSpacingY = KOPrefs::instance()->mAllDaySize; 194 mGridSpacingY = KOPrefs::instance()->mAllDaySize;
195 mAllDayMode = true; 195 mAllDayMode = true;
196#ifndef DESKTOP_VERSION 196#ifndef DESKTOP_VERSION
197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 197 //QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
198#endif 198#endif
199 mHolidayMask = 0; 199 mHolidayMask = 0;
200 init(); 200 init();
201} 201}
202 202
203 203
204KOAgenda::~KOAgenda() 204KOAgenda::~KOAgenda()
205{ 205{
206 if(mMarcusBains) delete mMarcusBains; 206 if(mMarcusBains) delete mMarcusBains;
207 207
208} 208}
209 209
210Incidence *KOAgenda::selectedIncidence() const 210Incidence *KOAgenda::selectedIncidence() const
211{ 211{
212 return (mSelectedItem ? mSelectedItem->incidence() : 0); 212 return (mSelectedItem ? mSelectedItem->incidence() : 0);
213} 213}
214 214
215 215
216QDate KOAgenda::selectedIncidenceDate() const 216QDate KOAgenda::selectedIncidenceDate() const
217{ 217{
218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate()); 218 return (mSelectedItem ? mSelectedItem->itemDate() : QDate());
219} 219}
220 220
221 221
222void KOAgenda::init() 222void KOAgenda::init()
223{ 223{
224 mPopupTimer = new QTimer(this); 224 mPopupTimer = new QTimer(this);
225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); 225 connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu()));
226 226
227 mNewItemPopup = new QPopupMenu( this ); 227 mNewItemPopup = new QPopupMenu( this );
228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) ); 228 connect ( mNewItemPopup, SIGNAL (activated ( int ) ), this, SLOT ( newItem(int)) );
229 QString pathString = ""; 229 QString pathString = "";
230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) { 230 if ( !KOPrefs::instance()->mToolBarMiniIcons ) {
231 if ( QApplication::desktop()->width() < 480 ) 231 if ( QApplication::desktop()->width() < 480 )
232 pathString += "icons16/"; 232 pathString += "icons16/";
233 } else 233 } else
234 pathString += "iconsmini/"; 234 pathString += "iconsmini/";
235 235
236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 ); 236 mNewItemPopup->insertItem ( SmallIcon( pathString +"newevent" ), i18n("New Event..."), 1 );
237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 ); 237 mNewItemPopup->insertItem ( SmallIcon( pathString +"newtodo" ), i18n("New Todo..."),2 );
238 mNewItemPopup->insertSeparator ( ); 238 mNewItemPopup->insertSeparator ( );
239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); 239 mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 );
240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 ); 240 mNewItemPopup->insertItem ( SmallIcon( pathString +"xdays" ), i18n("Next days"),8 );
241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 ); 241 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next week"),4 );
242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 ); 242 mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next two weeks"),5 );
243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next month"),6 ); 243 mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("This month"),6 );
244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); 244 mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 );
245#ifndef _WIN32_ 245#ifndef _WIN32_
246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase 246 int wflags = viewport()-> getWFlags() |WRepaintNoErase;//WResizeNoErase
247 viewport()->setWFlags ( wflags); 247 viewport()->setWFlags ( wflags);
248#endif 248#endif
249 mGridSpacingX = 80; 249 mGridSpacingX = 80;
250 mResizeBorderWidth = 8; 250 mResizeBorderWidth = 8;
251 mScrollBorderWidth = 8; 251 mScrollBorderWidth = 8;
252 mScrollDelay = 30; 252 mScrollDelay = 30;
253 mScrollOffset = 10; 253 mScrollOffset = 10;
254 mPaintPixmap.resize( 20,20); 254 mPaintPixmap.resize( 20,20);
255 //enableClipper(true); 255 //enableClipper(true);
256 256
257 // Grab key strokes for keyboard navigation of agenda. Seems to have no 257 // Grab key strokes for keyboard navigation of agenda. Seems to have no
258 // effect. Has to be fixed. 258 // effect. Has to be fixed.
259 setFocusPolicy(WheelFocus); 259 setFocusPolicy(WheelFocus);
260 260
261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp())); 261 connect(&mScrollUpTimer,SIGNAL(timeout()),SLOT(scrollUp()));
262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown())); 262 connect(&mScrollDownTimer,SIGNAL(timeout()),SLOT(scrollDown()));
263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize())); 263 connect(&mResizeTimer,SIGNAL(timeout()),SLOT(finishResize()));
264 264
265 mStartCellX = 0; 265 mStartCellX = 0;
266 mStartCellY = 0; 266 mStartCellY = 0;
267 mCurrentCellX = 0; 267 mCurrentCellX = 0;
268 mCurrentCellY = 0; 268 mCurrentCellY = 0;
269 269
270 mSelectionCellX = 0; 270 mSelectionCellX = 0;
271 mSelectionYTop = 0; 271 mSelectionYTop = 0;
272 mSelectionHeight = 0; 272 mSelectionHeight = 0;
273 273
274 mOldLowerScrollValue = -1; 274 mOldLowerScrollValue = -1;
275 mOldUpperScrollValue = -1; 275 mOldUpperScrollValue = -1;
276 276
277 mClickedItem = 0; 277 mClickedItem = 0;
278 278
279 mActionItem = 0; 279 mActionItem = 0;
280 mActionType = NOP; 280 mActionType = NOP;
281 mItemMoved = false; 281 mItemMoved = false;
282 282
283 mSelectedItem = 0; 283 mSelectedItem = 0;
284 284
285 // mItems.setAutoDelete(true); 285 // mItems.setAutoDelete(true);
286 286
287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 ); 287 resizeContents( mGridSpacingX * mColumns + 1 , mGridSpacingY * mRows + 1 );
288 288
289 viewport()->update(); 289 viewport()->update();
290 290
291 setMinimumSize(30, 1); 291 setMinimumSize(30, 1);
292// setMaximumHeight(mGridSpacingY * mRows + 5); 292// setMaximumHeight(mGridSpacingY * mRows + 5);
293 293
294 // Disable horizontal scrollbar. This is a hack. The geometry should be 294 // Disable horizontal scrollbar. This is a hack. The geometry should be
295 // controlled in a way that the contents horizontally always fits. Then it is 295 // controlled in a way that the contents horizontally always fits. Then it is
296 // not necessary to turn off the scrollbar. 296 // not necessary to turn off the scrollbar.
297 setHScrollBarMode(AlwaysOff); 297 setHScrollBarMode(AlwaysOff);
298 if ( ! mAllDayMode ) 298 if ( ! mAllDayMode )
299 setVScrollBarMode(AlwaysOn); 299 setVScrollBarMode(AlwaysOn);
300 else 300 else
301 setVScrollBarMode(AlwaysOff); 301 setVScrollBarMode(AlwaysOff);
302 302
303 setStartHour(KOPrefs::instance()->mDayBegins); 303 setStartHour(KOPrefs::instance()->mDayBegins);
304 304
305 calculateWorkingHours(); 305 calculateWorkingHours();
306 306
307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)), 307 connect(verticalScrollBar(),SIGNAL(valueChanged(int)),
308 SLOT(checkScrollBoundaries(int))); 308 SLOT(checkScrollBoundaries(int)));
309 309
310 // Create the Marcus Bains line. 310 // Create the Marcus Bains line.
311 if(mAllDayMode) 311 if(mAllDayMode)
312 mMarcusBains = 0; 312 mMarcusBains = 0;
313 else { 313 else {
314 mMarcusBains = new MarcusBains(this); 314 mMarcusBains = new MarcusBains(this);
315 addChild(mMarcusBains); 315 addChild(mMarcusBains);
316 } 316 }
317 mPopupKind = 0; 317 mPopupKind = 0;
318 mPopupItem = 0; 318 mPopupItem = 0;
319} 319}
320 320
321void KOAgenda::clear() 321void KOAgenda::clear()
322{ 322{
323 KOAgendaItem *item; 323 KOAgendaItem *item;
324 for ( item=mItems.first(); item != 0; item=mItems.next() ) { 324 for ( item=mItems.first(); item != 0; item=mItems.next() ) {
325 mUnusedItems.append( item ); 325 mUnusedItems.append( item );
326 //item->hide(); 326 //item->hide();
327 } 327 }
328 mItems.clear(); 328 mItems.clear();
329 mSelectedItem = 0; 329 mSelectedItem = 0;
330 clearSelection(); 330 clearSelection();
331} 331}
332 332
333void KOAgenda::clearSelection() 333void KOAgenda::clearSelection()
334{ 334{
335 mSelectionCellX = 0; 335 mSelectionCellX = 0;
336 mSelectionYTop = 0; 336 mSelectionYTop = 0;
337 mSelectionHeight = 0; 337 mSelectionHeight = 0;
338} 338}
339 339
@@ -661,194 +661,193 @@ bool KOAgenda::eventFilter_mouse(QObject *object, QMouseEvent *me)
661 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) { 661 if ( mActionType == MOVE && (clipperPos.y() > visibleHeight()-2 ||clipperPos.y() < 0 ) ) {
662 mScrollUpTimer.stop(); 662 mScrollUpTimer.stop();
663 mScrollDownTimer.stop(); 663 mScrollDownTimer.stop();
664 mActionItem->resetMove(); 664 mActionItem->resetMove();
665 placeSubCells( mActionItem ); 665 placeSubCells( mActionItem );
666 // emit startDragSignal( mActionItem->incidence() ); 666 // emit startDragSignal( mActionItem->incidence() );
667 setCursor( arrowCursor ); 667 setCursor( arrowCursor );
668 mActionItem = 0; 668 mActionItem = 0;
669 mActionType = NOP; 669 mActionType = NOP;
670 mItemMoved = 0; 670 mItemMoved = 0;
671 leftMouseDown = false; 671 leftMouseDown = false;
672 return true; 672 return true;
673 } 673 }
674 endItemAction(); 674 endItemAction();
675 } 675 }
676 } 676 }
677 677
678 } else { // ---------- viewport() 678 } else { // ---------- viewport()
679 if (me->button() == LeftButton && leftMouseDown ) { //left click 679 if (me->button() == LeftButton && leftMouseDown ) { //left click
680 endSelectAction( true ); // emit new event signal 680 endSelectAction( true ); // emit new event signal
681 } 681 }
682 } 682 }
683 if (me->button() == LeftButton) 683 if (me->button() == LeftButton)
684 leftMouseDown = false; 684 leftMouseDown = false;
685 685
686 break; 686 break;
687 687
688 case QEvent::MouseMove: 688 case QEvent::MouseMove:
689 if ( !leftMouseDown ) 689 if ( !leftMouseDown )
690 return true; 690 return true;
691 if ( blockMoving ) { 691 if ( blockMoving ) {
692 int dX, dY; 692 int dX, dY;
693 dX = startX - viewportPos.x(); 693 dX = startX - viewportPos.x();
694 if ( dX < 0 ) 694 if ( dX < 0 )
695 dX = -dX; 695 dX = -dX;
696 dY = viewportPos.y() - startY; 696 dY = viewportPos.y() - startY;
697 if ( dY < 0 ) 697 if ( dY < 0 )
698 dY = -dY; 698 dY = -dY;
699 //qDebug("%d %d %d ", dX, dY , blockmoveDist ); 699 //qDebug("%d %d %d ", dX, dY , blockmoveDist );
700 if ( dX > blockmoveDist || dY > blockmoveDist ) { 700 if ( dX > blockmoveDist || dY > blockmoveDist ) {
701 blockMoving = false; 701 blockMoving = false;
702 } 702 }
703 } 703 }
704 if (object != viewport()) { 704 if (object != viewport()) {
705 KOAgendaItem *moveItem = (KOAgendaItem *)object; 705 KOAgendaItem *moveItem = (KOAgendaItem *)object;
706 if (!moveItem->incidence()->isReadOnly() ) { 706 if (!moveItem->incidence()->isReadOnly() ) {
707 if (!mActionItem) 707 if (!mActionItem)
708 setNoActionCursor(moveItem,viewportPos); 708 setNoActionCursor(moveItem,viewportPos);
709 else { 709 else {
710 if ( !blockMoving ) 710 if ( !blockMoving )
711 performItemAction(viewportPos); 711 performItemAction(viewportPos);
712 } 712 }
713 } 713 }
714 } else { // ---------- viewport() 714 } else { // ---------- viewport()
715 if ( mActionType == SELECT ) { 715 if ( mActionType == SELECT ) {
716 performSelectAction( viewportPos ); 716 performSelectAction( viewportPos );
717 } 717 }
718 } 718 }
719 break; 719 break;
720 720
721 case QEvent::MouseButtonDblClick: 721 case QEvent::MouseButtonDblClick:
722 blockMoving = false; 722 blockMoving = false;
723 leftMouseDown = false; 723 leftMouseDown = false;
724 if (object == viewport()) { 724 if (object == viewport()) {
725 selectItem(0); 725 selectItem(0);
726 int x,y; 726 int x,y;
727 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 727 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
728 int gx,gy; 728 int gx,gy;
729 contentsToGrid(x,y,gx,gy); 729 contentsToGrid(x,y,gx,gy);
730 emit newEventSignal(gx,gy); 730 emit newEventSignal(gx,gy);
731 } else { 731 } else {
732 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object; 732 KOAgendaItem *doubleClickedItem = (KOAgendaItem *)object;
733 selectItem(doubleClickedItem); 733 selectItem(doubleClickedItem);
734 if ( KOPrefs::instance()->mEditOnDoubleClick ) 734 if ( KOPrefs::instance()->mEditOnDoubleClick )
735 emit editIncidenceSignal(doubleClickedItem->incidence()); 735 emit editIncidenceSignal(doubleClickedItem->incidence());
736 else 736 else
737 emit showIncidenceSignal(doubleClickedItem->incidence()); 737 emit showIncidenceSignal(doubleClickedItem->incidence());
738 } 738 }
739 break; 739 break;
740 740
741 default: 741 default:
742 break; 742 break;
743 } 743 }
744 return true; 744 return true;
745#endif 745#endif
746} 746}
747 747
748void KOAgenda::newItem( int item ) 748void KOAgenda::newItem( int item )
749{ 749{
750 if ( item == 1 ) { //new event 750 if ( item == 1 ) { //new event
751 newEventSignal(mStartCellX ,mStartCellY ); 751 newEventSignal(mStartCellX ,mStartCellY );
752 } else 752 } else
753 if ( item == 2 ) { //new event 753 if ( item == 2 ) { //new event
754 newTodoSignal(mStartCellX ,mStartCellY ); 754 newTodoSignal(mStartCellX ,mStartCellY );
755 } else 755 } else
756 { 756 {
757 QDate day = mSelectedDates[mStartCellX]; 757 emit showDateView( item, mStartCellX );
758 emit showDateView( item, day );
759 // 3Day view 758 // 3Day view
760 // 4Week view 759 // 4Week view
761 // 5Month view 760 // 5Month view
762 // 6Journal view 761 // 6Journal view
763 } 762 }
764} 763}
765void KOAgenda::startSelectAction(QPoint viewportPos) 764void KOAgenda::startSelectAction(QPoint viewportPos)
766{ 765{
767 //emit newStartSelectSignal(); 766 //emit newStartSelectSignal();
768 767
769 mActionType = SELECT; 768 mActionType = SELECT;
770 769
771 int x,y; 770 int x,y;
772 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 771 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
773 int gx,gy; 772 int gx,gy;
774 contentsToGrid(x,y,gx,gy); 773 contentsToGrid(x,y,gx,gy);
775 774
776 mStartCellX = gx; 775 mStartCellX = gx;
777 mStartCellY = gy; 776 mStartCellY = gy;
778 mCurrentCellX = gx; 777 mCurrentCellX = gx;
779 mCurrentCellY = gy; 778 mCurrentCellY = gy;
780 779
781 // Store coordinates of old selection 780 // Store coordinates of old selection
782 int selectionX = mSelectionCellX * mGridSpacingX; 781 int selectionX = mSelectionCellX * mGridSpacingX;
783 int selectionYTop = mSelectionYTop; 782 int selectionYTop = mSelectionYTop;
784 int selectionHeight = mSelectionHeight; 783 int selectionHeight = mSelectionHeight;
785 784
786 // Store new selection 785 // Store new selection
787 mSelectionCellX = gx; 786 mSelectionCellX = gx;
788 mSelectionYTop = gy * mGridSpacingY; 787 mSelectionYTop = gy * mGridSpacingY;
789 mSelectionHeight = mGridSpacingY; 788 mSelectionHeight = mGridSpacingY;
790 789
791 // Clear old selection 790 // Clear old selection
792 repaintContents( selectionX, selectionYTop, 791 repaintContents( selectionX, selectionYTop,
793 mGridSpacingX, selectionHeight,false ); 792 mGridSpacingX, selectionHeight,false );
794 793
795 // Paint new selection 794 // Paint new selection
796 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop, 795 // repaintContents( mSelectionCellX * mGridSpacingX, mSelectionYTop,
797 // mGridSpacingX, mSelectionHeight ); 796 // mGridSpacingX, mSelectionHeight );
798} 797}
799 798
800void KOAgenda::performSelectAction(QPoint viewportPos) 799void KOAgenda::performSelectAction(QPoint viewportPos)
801{ 800{
802 int x,y; 801 int x,y;
803 viewportToContents(viewportPos.x(),viewportPos.y(),x,y); 802 viewportToContents(viewportPos.x(),viewportPos.y(),x,y);
804 int gx,gy; 803 int gx,gy;
805 contentsToGrid(x,y,gx,gy); 804 contentsToGrid(x,y,gx,gy);
806 805
807 QPoint clipperPos = clipper()-> 806 QPoint clipperPos = clipper()->
808 mapFromGlobal(viewport()->mapToGlobal(viewportPos)); 807 mapFromGlobal(viewport()->mapToGlobal(viewportPos));
809 808
810 // Scroll if cursor was moved to upper or lower end of agenda. 809 // Scroll if cursor was moved to upper or lower end of agenda.
811 if (clipperPos.y() < mScrollBorderWidth) { 810 if (clipperPos.y() < mScrollBorderWidth) {
812 mScrollUpTimer.start(mScrollDelay); 811 mScrollUpTimer.start(mScrollDelay);
813 } else if (visibleHeight() - clipperPos.y() < 812 } else if (visibleHeight() - clipperPos.y() <
814 mScrollBorderWidth) { 813 mScrollBorderWidth) {
815 mScrollDownTimer.start(mScrollDelay); 814 mScrollDownTimer.start(mScrollDelay);
816 } else { 815 } else {
817 mScrollUpTimer.stop(); 816 mScrollUpTimer.stop();
818 mScrollDownTimer.stop(); 817 mScrollDownTimer.stop();
819 } 818 }
820 819
821 if ( gy > mCurrentCellY ) { 820 if ( gy > mCurrentCellY ) {
822 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 821 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
823 822
824#if 0 823#if 0
825 // FIXME: Repaint only the newly selected region 824 // FIXME: Repaint only the newly selected region
826 repaintContents( mSelectionCellX * mGridSpacingX, 825 repaintContents( mSelectionCellX * mGridSpacingX,
827 mCurrentCellY + mGridSpacingY, 826 mCurrentCellY + mGridSpacingY,
828 mGridSpacingX, 827 mGridSpacingX,
829 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY ); 828 mSelectionHeight - ( gy - mCurrentCellY - 1 ) * mGridSpacingY );
830#else 829#else
831 repaintContents( (KOGlobals::self()->reverseLayout() ? 830 repaintContents( (KOGlobals::self()->reverseLayout() ?
832 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 831 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
833 mGridSpacingX, mSelectionYTop, 832 mGridSpacingX, mSelectionYTop,
834 mGridSpacingX, mSelectionHeight , false); 833 mGridSpacingX, mSelectionHeight , false);
835#endif 834#endif
836 835
837 mCurrentCellY = gy; 836 mCurrentCellY = gy;
838 } else if ( gy < mCurrentCellY ) { 837 } else if ( gy < mCurrentCellY ) {
839 if ( gy >= mStartCellY ) { 838 if ( gy >= mStartCellY ) {
840 int selectionHeight = mSelectionHeight; 839 int selectionHeight = mSelectionHeight;
841 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop; 840 mSelectionHeight = ( gy + 1 ) * mGridSpacingY - mSelectionYTop;
842 841
843 repaintContents( (KOGlobals::self()->reverseLayout() ? 842 repaintContents( (KOGlobals::self()->reverseLayout() ?
844 mColumns - 1 - mSelectionCellX : mSelectionCellX) * 843 mColumns - 1 - mSelectionCellX : mSelectionCellX) *
845 mGridSpacingX, mSelectionYTop, 844 mGridSpacingX, mSelectionYTop,
846 mGridSpacingX, selectionHeight,false ); 845 mGridSpacingX, selectionHeight,false );
847 846
848 mCurrentCellY = gy; 847 mCurrentCellY = gy;
849 } else { 848 } else {
850 } 849 }
851 } 850 }
852} 851}
853 852
854void KOAgenda::endSelectAction( bool emitNewEvent ) 853void KOAgenda::endSelectAction( bool emitNewEvent )
diff --git a/korganizer/koagenda.h b/korganizer/koagenda.h
index 3d33ae5..35c08b6 100644
--- a/korganizer/koagenda.h
+++ b/korganizer/koagenda.h
@@ -52,193 +52,193 @@ class MarcusBains : public QFrame {
52 void updateLocation(bool recalculate=false); 52 void updateLocation(bool recalculate=false);
53 void updateLoc(); 53 void updateLoc();
54 54
55 private: 55 private:
56 int todayColumn(); 56 int todayColumn();
57 QTimer *minutes; 57 QTimer *minutes;
58 QLabel *mTimeBox; 58 QLabel *mTimeBox;
59 KOAgenda *agenda; 59 KOAgenda *agenda;
60 QTime oldTime; 60 QTime oldTime;
61 int oldToday; 61 int oldToday;
62}; 62};
63 63
64 64
65class KOAgenda : public QScrollView 65class KOAgenda : public QScrollView
66{ 66{
67 Q_OBJECT 67 Q_OBJECT
68 public: 68 public:
69 enum MouseActionType { NOP, MOVE, SELECT, 69 enum MouseActionType { NOP, MOVE, SELECT,
70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT }; 70 RESIZETOP, RESIZEBOTTOM, RESIZELEFT, RESIZERIGHT };
71 71
72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0, 72 KOAgenda ( int columns, int rows, int columnSize, QWidget * parent=0,
73 const char * name=0, WFlags f=0 ); 73 const char * name=0, WFlags f=0 );
74 KOAgenda ( int columns, QWidget * parent=0, 74 KOAgenda ( int columns, QWidget * parent=0,
75 const char * name=0, WFlags f=0 ); 75 const char * name=0, WFlags f=0 );
76 virtual ~KOAgenda(); 76 virtual ~KOAgenda();
77 77
78 Incidence *selectedIncidence() const; 78 Incidence *selectedIncidence() const;
79 QDate selectedIncidenceDate() const; 79 QDate selectedIncidenceDate() const;
80 80
81 virtual bool eventFilter ( QObject *, QEvent * ); 81 virtual bool eventFilter ( QObject *, QEvent * );
82 82
83 void contentsToGrid (int x, int y, int& gx, int& gy); 83 void contentsToGrid (int x, int y, int& gx, int& gy);
84 void gridToContents (int gx, int gy, int& x, int& y); 84 void gridToContents (int gx, int gy, int& x, int& y);
85 85
86 int timeToY (const QTime &time); 86 int timeToY (const QTime &time);
87 QTime gyToTime (int y); 87 QTime gyToTime (int y);
88 88
89 void setStartHour(int startHour); 89 void setStartHour(int startHour);
90 90
91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom); 91 KOAgendaItem *insertItem (Incidence *event,QDate qd,int X,int YTop,int YBottom);
92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd); 92 KOAgendaItem *insertAllDayItem (Incidence *event,QDate qd,int XBegin,int XEnd);
93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd, 93 void insertMultiItem (Event *event,QDate qd,int XBegin,int XEnd,
94 int YTop,int YBottom); 94 int YTop,int YBottom);
95 95
96 void changeColumns(int columns); 96 void changeColumns(int columns);
97 97
98 int columns() { return mColumns; } 98 int columns() { return mColumns; }
99 int rows() { return mRows; } 99 int rows() { return mRows; }
100 100
101 int gridSpacingX() const { return mGridSpacingX; } 101 int gridSpacingX() const { return mGridSpacingX; }
102 int gridSpacingY() const { return mGridSpacingY; } 102 int gridSpacingY() const { return mGridSpacingY; }
103 103
104// virtual QSizePolicy sizePolicy() const; 104// virtual QSizePolicy sizePolicy() const;
105 105
106 void clear(); 106 void clear();
107 107
108 void clearSelection(); 108 void clearSelection();
109 void hideUnused(); 109 void hideUnused();
110 110
111 /** Calculates the minimum width */ 111 /** Calculates the minimum width */
112 virtual int minimumWidth() const; 112 virtual int minimumWidth() const;
113 /** Update configuration from preference settings */ 113 /** Update configuration from preference settings */
114 void updateConfig(); 114 void updateConfig();
115 115
116 void checkScrollBoundaries(); 116 void checkScrollBoundaries();
117 117
118 void setHolidayMask(QMemArray<bool> *); 118 void setHolidayMask(QMemArray<bool> *);
119 void setDateList(const DateList &selectedDates); 119 void setDateList(const DateList &selectedDates);
120 DateList dateList() const; 120 DateList dateList() const;
121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false); 121 void drawContentsToPainter( QPainter* paint = 0, bool backgroundOnly = false);
122 void finishUpdate(); 122 void finishUpdate();
123 void printSelection(); 123 void printSelection();
124 void storePosition(); 124 void storePosition();
125 void restorePosition(); 125 void restorePosition();
126 126
127 127
128 public slots: 128 public slots:
129 void popupMenu(); 129 void popupMenu();
130 void newItem( int ); 130 void newItem( int );
131 void moveChild( QWidget *, int, int ); 131 void moveChild( QWidget *, int, int );
132 void scrollUp(); 132 void scrollUp();
133 void scrollDown(); 133 void scrollDown();
134 void updateTodo( Todo * t, int , bool ); 134 void updateTodo( Todo * t, int , bool );
135 void popupAlarm(); 135 void popupAlarm();
136 136
137 void checkScrollBoundaries(int); 137 void checkScrollBoundaries(int);
138 138
139 /** Deselect selected items. This function does not emit any signals. */ 139 /** Deselect selected items. This function does not emit any signals. */
140 void deselectItem(); 140 void deselectItem();
141 /** Select item. If the argument is 0, the currently selected item gets 141 /** Select item. If the argument is 0, the currently selected item gets
142 deselected. This function emits the itemSelected(bool) signal to inform 142 deselected. This function emits the itemSelected(bool) signal to inform
143 about selection/deseelction of events. */ 143 about selection/deseelction of events. */
144 void selectItem(KOAgendaItem *); 144 void selectItem(KOAgendaItem *);
145 void finishResize(); 145 void finishResize();
146 146
147 signals: 147 signals:
148 void showDateView( int, QDate ); 148 void showDateView( int, int);
149 void newEventSignal(); 149 void newEventSignal();
150 void newEventSignal(int gx,int gy); 150 void newEventSignal(int gx,int gy);
151 void newTodoSignal(int gx,int gy); 151 void newTodoSignal(int gx,int gy);
152 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 152 void newEventSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
153 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd); 153 void newTimeSpanSignal(int gxStart, int gyStart, int gxEnd, int gyEnd);
154 void newStartSelectSignal(); 154 void newStartSelectSignal();
155 void showIncidenceSignal(Incidence *); 155 void showIncidenceSignal(Incidence *);
156 void editIncidenceSignal(Incidence *); 156 void editIncidenceSignal(Incidence *);
157 void deleteIncidenceSignal(Incidence *); 157 void deleteIncidenceSignal(Incidence *);
158 void showIncidencePopupSignal(Incidence *); 158 void showIncidencePopupSignal(Incidence *);
159 159
160 void itemModified(KOAgendaItem *item, int ); 160 void itemModified(KOAgendaItem *item, int );
161 void incidenceSelected(Incidence *); 161 void incidenceSelected(Incidence *);
162 162
163 void lowerYChanged(int); 163 void lowerYChanged(int);
164 void upperYChanged(int); 164 void upperYChanged(int);
165 165
166 void startDragSignal(Incidence *); 166 void startDragSignal(Incidence *);
167 void addToCalSignal(Incidence *, Incidence *); 167 void addToCalSignal(Incidence *, Incidence *);
168 void resizedSignal(); 168 void resizedSignal();
169 169
170 protected: 170 protected:
171 QPainter mPixPainter; 171 QPainter mPixPainter;
172 QPixmap mPaintPixmap; 172 QPixmap mPaintPixmap;
173 QPixmap mHighlightPixmap; 173 QPixmap mHighlightPixmap;
174 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 174 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
175 virtual void resizeEvent ( QResizeEvent * ); 175 virtual void resizeEvent ( QResizeEvent * );
176 176
177 /** Handles mouse events. Called from eventFilter */ 177 /** Handles mouse events. Called from eventFilter */
178 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * ); 178 virtual bool eventFilter_mouse ( QObject *, QMouseEvent * );
179 179
180 /** Start selecting time span. */ 180 /** Start selecting time span. */
181 void startSelectAction(QPoint viewportPos); 181 void startSelectAction(QPoint viewportPos);
182 182
183 /** Select time span. */ 183 /** Select time span. */
184 void performSelectAction(QPoint viewportPos); 184 void performSelectAction(QPoint viewportPos);
185 185
186 /** Emd selecting time span. */ 186 /** Emd selecting time span. */
187 void endSelectAction( bool emitNewEvent = false ); 187 void endSelectAction( bool emitNewEvent = false );
188 188
189 /** Start moving/resizing agenda item */ 189 /** Start moving/resizing agenda item */
190 void startItemAction(QPoint viewportPos); 190 void startItemAction(QPoint viewportPos);
191 191
192 /** Move/resize agenda item */ 192 /** Move/resize agenda item */
193 void performItemAction(QPoint viewportPos); 193 void performItemAction(QPoint viewportPos);
194 194
195 /** End moving/resizing agenda item */ 195 /** End moving/resizing agenda item */
196 void endItemAction(); 196 void endItemAction();
197 197
198 /** Set cursor, when no item action is in progress */ 198 /** Set cursor, when no item action is in progress */
199 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos); 199 void setNoActionCursor(KOAgendaItem *moveItem,QPoint viewportPos);
200 200
201 /** Place agenda item in agenda and adjust other cells if necessary */ 201 /** Place agenda item in agenda and adjust other cells if necessary */
202 void placeSubCells(KOAgendaItem *placeItem); 202 void placeSubCells(KOAgendaItem *placeItem);
203 203
204 /** Process the keyevent, including the ignored keyevents of eventwidgets. 204 /** Process the keyevent, including the ignored keyevents of eventwidgets.
205 * Implements pgup/pgdn and cursor key navigation in the view. 205 * Implements pgup/pgdn and cursor key navigation in the view.
206 */ 206 */
207 void keyPressEvent( QKeyEvent * ); 207 void keyPressEvent( QKeyEvent * );
208 208
209 void calculateWorkingHours(); 209 void calculateWorkingHours();
210 210
211 virtual void contentsMousePressEvent ( QMouseEvent * ); 211 virtual void contentsMousePressEvent ( QMouseEvent * );
212 212
213 private: 213 private:
214 void init(); 214 void init();
215 void marcus_bains(); 215 void marcus_bains();
216 bool mAllDayMode; 216 bool mAllDayMode;
217 bool blockResize; 217 bool blockResize;
218 bool mLeftMouseDown; 218 bool mLeftMouseDown;
219 KOAgendaItem *mPopupItem; 219 KOAgendaItem *mPopupItem;
220 QTimer* mPopupTimer; 220 QTimer* mPopupTimer;
221 int mPopupKind; 221 int mPopupKind;
222 QPoint mPopupPos; 222 QPoint mPopupPos;
223 QTimer mResizeTimer; 223 QTimer mResizeTimer;
224 double mContentPosition; 224 double mContentPosition;
225 225
226 // Width and height of agenda cells 226 // Width and height of agenda cells
227 int mGridSpacingX; 227 int mGridSpacingX;
228 int mGridSpacingY; 228 int mGridSpacingY;
229 229
230 // size of border, where mouse action will resize the KOAgendaItem 230 // size of border, where mouse action will resize the KOAgendaItem
231 int mResizeBorderWidth; 231 int mResizeBorderWidth;
232 232
233 // size of border, where mouse mve will cause a scroll of the agenda 233 // size of border, where mouse mve will cause a scroll of the agenda
234 int mScrollBorderWidth; 234 int mScrollBorderWidth;
235 int mScrollDelay; 235 int mScrollDelay;
236 int mScrollOffset; 236 int mScrollOffset;
237 237
238 QTimer mScrollUpTimer; 238 QTimer mScrollUpTimer;
239 QTimer mScrollDownTimer; 239 QTimer mScrollDownTimer;
240 240
241 // Number of Columns/Rows of agenda grid 241 // Number of Columns/Rows of agenda grid
242 int mColumns; 242 int mColumns;
243 int mRows; 243 int mRows;
244 244
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index b9909d6..2996acb 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -395,194 +395,194 @@ KOAgendaView::KOAgendaView(Calendar *cal,QWidget *parent,const char *name) :
395 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up ); 395 mSplitterAgenda->setMinimizeDirection ( KDGanttMinimizeSplitter::Up );
396 topLayout->addWidget( mSplitterAgenda ); 396 topLayout->addWidget( mSplitterAgenda );
397 mAllDayFrame = new QHBox(mSplitterAgenda); 397 mAllDayFrame = new QHBox(mSplitterAgenda);
398 mAllDayFrame->setFocusPolicy(NoFocus); 398 mAllDayFrame->setFocusPolicy(NoFocus);
399 QWidget *agendaFrame = new QWidget(mSplitterAgenda); 399 QWidget *agendaFrame = new QWidget(mSplitterAgenda);
400 agendaFrame->setFocusPolicy(NoFocus); 400 agendaFrame->setFocusPolicy(NoFocus);
401 401
402 // Create all-day agenda widget 402 // Create all-day agenda widget
403 mDummyAllDayLeft = new QVBox( mAllDayFrame ); 403 mDummyAllDayLeft = new QVBox( mAllDayFrame );
404 404
405 mExpandButton = new QPushButton(mDummyAllDayLeft); 405 mExpandButton = new QPushButton(mDummyAllDayLeft);
406 mExpandButton->setPixmap( expandPix ); 406 mExpandButton->setPixmap( expandPix );
407 int widebut = mExpandButton->sizeHint().width()+4; 407 int widebut = mExpandButton->sizeHint().width()+4;
408 int heibut = mExpandButton->sizeHint().height()+4; 408 int heibut = mExpandButton->sizeHint().height()+4;
409 if ( heibut > widebut ) 409 if ( heibut > widebut )
410 widebut = heibut ; 410 widebut = heibut ;
411 if ( QApplication::desktop()->width() < 480 ) 411 if ( QApplication::desktop()->width() < 480 )
412 widebut = widebut*3/2; 412 widebut = widebut*3/2;
413 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, 413 //mExpandButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
414 // QSizePolicy::Fixed ) ); 414 // QSizePolicy::Fixed ) );
415 mExpandButton->setFixedSize( widebut, widebut); 415 mExpandButton->setFixedSize( widebut, widebut);
416 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) ); 416 connect( mExpandButton, SIGNAL( clicked() ), SIGNAL( toggleExpand() ) );
417 mExpandButton->setFocusPolicy(NoFocus); 417 mExpandButton->setFocusPolicy(NoFocus);
418 mAllDayAgenda = new KOAgenda(1,mAllDayFrame); 418 mAllDayAgenda = new KOAgenda(1,mAllDayFrame);
419 mAllDayAgenda->setFocusPolicy(NoFocus); 419 mAllDayAgenda->setFocusPolicy(NoFocus);
420 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame); 420 QLabel *dummyAllDayRight = new QLabel (mAllDayFrame);
421 421
422 // Create event context menu for all day agenda 422 // Create event context menu for all day agenda
423 mAllDayAgendaPopup = eventPopup(); 423 mAllDayAgendaPopup = eventPopup();
424 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 424 connect(mAllDayAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
425 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 425 mAllDayAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
426 426
427 // Create agenda frame 427 // Create agenda frame
428 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3); 428 QGridLayout *agendaLayout = new QGridLayout(agendaFrame,4,3);
429 // QHBox *agendaFrame = new QHBox(splitterAgenda); 429 // QHBox *agendaFrame = new QHBox(splitterAgenda);
430 430
431 // create event indicator bars 431 // create event indicator bars
432 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame); 432 mEventIndicatorTop = new EventIndicator(EventIndicator::Top,agendaFrame);
433#ifndef DESKTOP_VERSION 433#ifndef DESKTOP_VERSION
434 // FIX 434 // FIX
435 mEventIndicatorTop->setPaintWidget( mSplitterAgenda ); 435 mEventIndicatorTop->setPaintWidget( mSplitterAgenda );
436#endif 436#endif
437 mDayLabelsFrame = new QHBox(agendaFrame); 437 mDayLabelsFrame = new QHBox(agendaFrame);
438 //topLayout->addWidget(mDayLabelsFrame); 438 //topLayout->addWidget(mDayLabelsFrame);
439 mDayLabels = new QFrame (mDayLabelsFrame); 439 mDayLabels = new QFrame (mDayLabelsFrame);
440 mLayoutDayLabels = new QHBoxLayout(mDayLabels); 440 mLayoutDayLabels = new QHBoxLayout(mDayLabels);
441 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2); 441 agendaLayout->addMultiCellWidget(mDayLabelsFrame ,0,0,0,2);
442 agendaLayout->addWidget(mEventIndicatorTop,1,1); 442 agendaLayout->addWidget(mEventIndicatorTop,1,1);
443 443
444 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom, 444 mEventIndicatorBottom = new EventIndicator(EventIndicator::Bottom,
445 agendaFrame); 445 agendaFrame);
446 agendaLayout->addWidget(mEventIndicatorBottom,3,1); 446 agendaLayout->addWidget(mEventIndicatorBottom,3,1);
447 QWidget *dummyAgendaRight = new QWidget(agendaFrame); 447 QWidget *dummyAgendaRight = new QWidget(agendaFrame);
448 agendaLayout->addWidget(dummyAgendaRight,1,2); 448 agendaLayout->addWidget(dummyAgendaRight,1,2);
449 449
450 // Create time labels 450 // Create time labels
451 mTimeLabels = new TimeLabels(24,agendaFrame); 451 mTimeLabels = new TimeLabels(24,agendaFrame);
452 agendaLayout->addWidget(mTimeLabels,2,0); 452 agendaLayout->addWidget(mTimeLabels,2,0);
453 connect(mTimeLabels,SIGNAL( scaleChanged()), 453 connect(mTimeLabels,SIGNAL( scaleChanged()),
454 this,SLOT(updateConfig())); 454 this,SLOT(updateConfig()));
455 455
456 // Create agenda 456 // Create agenda
457 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame); 457 mAgenda = new KOAgenda(1,96,KOPrefs::instance()->mHourSize,agendaFrame);
458 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2); 458 agendaLayout->addMultiCellWidget(mAgenda,2,2,1,2);
459 agendaLayout->setColStretch(1,1); 459 agendaLayout->setColStretch(1,1);
460 mAgenda->setFocusPolicy(NoFocus); 460 mAgenda->setFocusPolicy(NoFocus);
461 // Create event context menu for agenda 461 // Create event context menu for agenda
462 mAgendaPopup = eventPopup(); 462 mAgendaPopup = eventPopup();
463 463
464 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")), 464 mAgendaPopup->addAdditionalItem(QIconSet(SmallIcon("bell")),
465 i18n("Toggle Alarm"),mAgenda, 465 i18n("Toggle Alarm"),mAgenda,
466 SLOT(popupAlarm()),true); 466 SLOT(popupAlarm()),true);
467 467
468 468
469 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)), 469 connect(mAgenda,SIGNAL(showIncidencePopupSignal(Incidence *)),
470 mAgendaPopup,SLOT(showIncidencePopup(Incidence *))); 470 mAgendaPopup,SLOT(showIncidencePopup(Incidence *)));
471 471
472 // make connections between dependent widgets 472 // make connections between dependent widgets
473 mTimeLabels->setAgenda(mAgenda); 473 mTimeLabels->setAgenda(mAgenda);
474 474
475 // Update widgets to reflect user preferences 475 // Update widgets to reflect user preferences
476 // updateConfig(); 476 // updateConfig();
477 477
478 // createDayLabels(); 478 // createDayLabels();
479 479
480 // these blank widgets make the All Day Event box line up with the agenda 480 // these blank widgets make the All Day Event box line up with the agenda
481 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 481 dummyAllDayRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
482 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width()); 482 dummyAgendaRight->setFixedWidth(mAgenda->verticalScrollBar()->width());
483 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width()); 483 mDummyAllDayLeft->setFixedWidth(mTimeLabels->width());
484 484
485 // Scrolling 485 // Scrolling
486 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)), 486 connect(mAgenda->verticalScrollBar(),SIGNAL(valueChanged(int)),
487 mTimeLabels, SLOT(positionChanged())); 487 mTimeLabels, SLOT(positionChanged()));
488 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)), 488 connect(mTimeLabels->verticalScrollBar(),SIGNAL(valueChanged(int)),
489 SLOT(setContentsPos(int))); 489 SLOT(setContentsPos(int)));
490 490
491 connect(mAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 491 connect(mAgenda,SIGNAL(showDateView( int, int)),SLOT(slotShowDateView( int, int )));
492 connect(mAllDayAgenda,SIGNAL(showDateView( int, QDate )),SIGNAL(showDateView( int, QDate ))); 492 connect(mAllDayAgenda,SIGNAL(showDateView( int, int )), SLOT(slotShowDateView( int, int ) ));
493 493
494 // Create/Show/Edit/Delete Event 494 // Create/Show/Edit/Delete Event
495 connect(mAgenda,SIGNAL(newEventSignal(int,int)), 495 connect(mAgenda,SIGNAL(newEventSignal(int,int)),
496 SLOT(newEvent(int,int))); 496 SLOT(newEvent(int,int)));
497 connect(mAgenda,SIGNAL(newTodoSignal(int,int)), 497 connect(mAgenda,SIGNAL(newTodoSignal(int,int)),
498 SLOT(newTodo(int,int))); 498 SLOT(newTodo(int,int)));
499 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)), 499 connect(mAgenda,SIGNAL(newEventSignal(int,int,int,int)),
500 SLOT(newEvent(int,int,int,int))); 500 SLOT(newEvent(int,int,int,int)));
501 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)), 501 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int)),
502 SLOT(newEventAllDay(int,int))); 502 SLOT(newEventAllDay(int,int)));
503 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)), 503 connect(mAllDayAgenda,SIGNAL(newTodoSignal(int,int)),
504 SLOT(newTodoAllDay(int,int))); 504 SLOT(newTodoAllDay(int,int)));
505 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)), 505 connect(mAllDayAgenda,SIGNAL(newEventSignal(int,int,int,int)),
506 SLOT(newEventAllDay(int,int))); 506 SLOT(newEventAllDay(int,int)));
507 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 507 connect(mAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
508 SLOT(newTimeSpanSelected(int,int,int,int))); 508 SLOT(newTimeSpanSelected(int,int,int,int)));
509 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)), 509 connect(mAllDayAgenda,SIGNAL(newTimeSpanSignal(int,int,int,int)),
510 SLOT(newTimeSpanSelectedAllDay(int,int,int,int))); 510 SLOT(newTimeSpanSelectedAllDay(int,int,int,int)));
511 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 511 connect(mAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
512 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView())); 512 connect(mAllDayAgenda,SIGNAL(newStartSelectSignal()),SLOT(updateView()));
513 513
514 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 514 connect(mAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
515 SIGNAL(editIncidenceSignal(Incidence *))); 515 SIGNAL(editIncidenceSignal(Incidence *)));
516 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)), 516 connect(mAllDayAgenda,SIGNAL(editIncidenceSignal(Incidence *)),
517 SIGNAL(editIncidenceSignal(Incidence *))); 517 SIGNAL(editIncidenceSignal(Incidence *)));
518 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 518 connect(mAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
519 SIGNAL(showIncidenceSignal(Incidence *))); 519 SIGNAL(showIncidenceSignal(Incidence *)));
520 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)), 520 connect(mAllDayAgenda,SIGNAL(showIncidenceSignal(Incidence *)),
521 SIGNAL(showIncidenceSignal(Incidence *))); 521 SIGNAL(showIncidenceSignal(Incidence *)));
522 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 522 connect(mAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
523 SIGNAL(deleteIncidenceSignal(Incidence *))); 523 SIGNAL(deleteIncidenceSignal(Incidence *)));
524 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)), 524 connect(mAllDayAgenda,SIGNAL(deleteIncidenceSignal(Incidence *)),
525 SIGNAL(deleteIncidenceSignal(Incidence *))); 525 SIGNAL(deleteIncidenceSignal(Incidence *)));
526 526
527 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 527 connect(mAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
528 SLOT(updateEventDates(KOAgendaItem *, int ))); 528 SLOT(updateEventDates(KOAgendaItem *, int )));
529 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )), 529 connect(mAllDayAgenda,SIGNAL(itemModified(KOAgendaItem *, int )),
530 SLOT(updateEventDates(KOAgendaItem *, int))); 530 SLOT(updateEventDates(KOAgendaItem *, int)));
531 531
532 // event indicator update 532 // event indicator update
533 connect(mAgenda,SIGNAL(lowerYChanged(int)), 533 connect(mAgenda,SIGNAL(lowerYChanged(int)),
534 SLOT(updateEventIndicatorTop(int))); 534 SLOT(updateEventIndicatorTop(int)));
535 connect(mAgenda,SIGNAL(upperYChanged(int)), 535 connect(mAgenda,SIGNAL(upperYChanged(int)),
536 SLOT(updateEventIndicatorBottom(int))); 536 SLOT(updateEventIndicatorBottom(int)));
537 // drag signals 537 // drag signals
538 /* 538 /*
539 connect(mAgenda,SIGNAL(startDragSignal(Event *)), 539 connect(mAgenda,SIGNAL(startDragSignal(Event *)),
540 SLOT(startDrag(Event *))); 540 SLOT(startDrag(Event *)));
541 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)), 541 connect(mAllDayAgenda,SIGNAL(startDragSignal(Event *)),
542 SLOT(startDrag(Event *))); 542 SLOT(startDrag(Event *)));
543 */ 543 */
544 // synchronize selections 544 // synchronize selections
545 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 545 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
546 mAllDayAgenda, SLOT( deselectItem() ) ); 546 mAllDayAgenda, SLOT( deselectItem() ) );
547 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 547 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
548 mAgenda, SLOT( deselectItem() ) ); 548 mAgenda, SLOT( deselectItem() ) );
549 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 549 connect( mAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
550 SIGNAL( incidenceSelected( Incidence * ) ) ); 550 SIGNAL( incidenceSelected( Incidence * ) ) );
551 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ), 551 connect( mAllDayAgenda, SIGNAL( incidenceSelected( Incidence * ) ),
552 SIGNAL( incidenceSelected( Incidence * ) ) ); 552 SIGNAL( incidenceSelected( Incidence * ) ) );
553 connect( mAgenda, SIGNAL( resizedSignal() ), 553 connect( mAgenda, SIGNAL( resizedSignal() ),
554 SLOT( updateConfig( ) ) ); 554 SLOT( updateConfig( ) ) );
555 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ), 555 connect( mAgenda, SIGNAL( addToCalSignal(Incidence *, Incidence *) ),
556 SLOT( addToCalSlot(Incidence *, Incidence * ) ) ); 556 SLOT( addToCalSlot(Incidence *, Incidence * ) ) );
557 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ), 557 connect( mAllDayAgenda, SIGNAL( addToCalSignal(Incidence * ,Incidence *) ),
558 SLOT( addToCalSlot(Incidence * , Incidence *) ) ); 558 SLOT( addToCalSlot(Incidence * , Incidence *) ) );
559 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 559 // connect( mAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
560 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) ); 560 //connect( mAllDayAgenda, SIGNAL( cloneIncidenceSignal(Incidence *) ), SIGNAL( cloneIncidenceSignal(Incidence *) ) );
561 561
562 562
563} 563}
564 564
565void KOAgendaView::toggleAllDay() 565void KOAgendaView::toggleAllDay()
566{ 566{
567 if ( mSplitterAgenda->firstHandle() ) 567 if ( mSplitterAgenda->firstHandle() )
568 mSplitterAgenda->firstHandle()->toggle(); 568 mSplitterAgenda->firstHandle()->toggle();
569} 569}
570void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 570void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
571{ 571{
572 calendar()->addIncidence( inc ); 572 calendar()->addIncidence( inc );
573 573
574 if ( incOld ) { 574 if ( incOld ) {
575 if ( incOld->type() == "Todo" ) 575 if ( incOld->type() == "Todo" )
576 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 576 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
577 else 577 else
578 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 578 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
579 } 579 }
580 580
581} 581}
582 582
583KOAgendaView::~KOAgendaView() 583KOAgendaView::~KOAgendaView()
584{ 584{
585 delete mAgendaPopup; 585 delete mAgendaPopup;
586 delete mAllDayAgendaPopup; 586 delete mAllDayAgendaPopup;
587 delete KOAgendaItem::paintPix(); 587 delete KOAgendaItem::paintPix();
588 delete KOAgendaItem::paintPixSel(); 588 delete KOAgendaItem::paintPixSel();
@@ -1217,192 +1217,203 @@ void KOAgendaView::fillAgenda()
1217 if ( todo->hasCompletedDate() ) 1217 if ( todo->hasCompletedDate() )
1218 dt = todo->completed(); 1218 dt = todo->completed();
1219 else 1219 else
1220 dt = todo->dtDue();; 1220 dt = todo->dtDue();;
1221 1221
1222 1222
1223 int endY = mAgenda->timeToY(dt.time()) - 1; 1223 int endY = mAgenda->timeToY(dt.time()) - 1;
1224 int hi = (18/KOPrefs::instance()->mHourSize); 1224 int hi = (18/KOPrefs::instance()->mHourSize);
1225 //qDebug("hei %d ",KOPrefs::instance()->mHourSize); 1225 //qDebug("hei %d ",KOPrefs::instance()->mHourSize);
1226 int startY = endY -hi; 1226 int startY = endY -hi;
1227 1227
1228 mAgenda->insertItem(todo,currentDate,curCol,startY,endY); 1228 mAgenda->insertItem(todo,currentDate,curCol,startY,endY);
1229 1229
1230 if (startY < mMinY[curCol]) mMinY[curCol] = startY; 1230 if (startY < mMinY[curCol]) mMinY[curCol] = startY;
1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY; 1231 if (endY > mMaxY[curCol]) mMaxY[curCol] = endY;
1232 } 1232 }
1233 } 1233 }
1234 } 1234 }
1235 // ---------- display Todos] -------------- 1235 // ---------- display Todos] --------------
1236 1236
1237 ++curCol; 1237 ++curCol;
1238 } 1238 }
1239 mAgenda->hideUnused(); 1239 mAgenda->hideUnused();
1240 mAllDayAgenda->hideUnused(); 1240 mAllDayAgenda->hideUnused();
1241 mAgenda->checkScrollBoundaries(); 1241 mAgenda->checkScrollBoundaries();
1242 1242
1243 deleteSelectedDateTime(); 1243 deleteSelectedDateTime();
1244 1244
1245 createDayLabels(); 1245 createDayLabels();
1246 emit incidenceSelected( 0 ); 1246 emit incidenceSelected( 0 );
1247 1247
1248 if ( globalFlagBlockAgenda == 2 ) { 1248 if ( globalFlagBlockAgenda == 2 ) {
1249 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 1249 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
1250 setStartHour( KOPrefs::instance()->mDayBegins ); 1250 setStartHour( KOPrefs::instance()->mDayBegins );
1251 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 1251 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
1252 setStartHour( QTime::currentTime ().hour() ); 1252 setStartHour( QTime::currentTime ().hour() );
1253 // qApp->processEvents(); 1253 // qApp->processEvents();
1254 } 1254 }
1255 qApp->processEvents(); 1255 qApp->processEvents();
1256 //qDebug("qApp->processEvents(); END "); 1256 //qDebug("qApp->processEvents(); END ");
1257 globalFlagBlockAgenda = 0; 1257 globalFlagBlockAgenda = 0;
1258 1258
1259 // mAgenda->hideUnused(); 1259 // mAgenda->hideUnused();
1260 //mAllDayAgenda->hideUnused(); 1260 //mAllDayAgenda->hideUnused();
1261 mAllDayAgenda->drawContentsToPainter(); 1261 mAllDayAgenda->drawContentsToPainter();
1262 mAgenda->drawContentsToPainter(); 1262 mAgenda->drawContentsToPainter();
1263 repaintAgenda(); 1263 repaintAgenda();
1264 onlyOne = false; 1264 onlyOne = false;
1265 // mAgenda->finishUpdate(); 1265 // mAgenda->finishUpdate();
1266 //mAllDayAgenda->finishUpdate(); 1266 //mAllDayAgenda->finishUpdate();
1267 1267
1268 // repaintAgenda(); 1268 // repaintAgenda();
1269 //qApp->processEvents(); 1269 //qApp->processEvents();
1270 // globalFlagBlockAgenda = 0; 1270 // globalFlagBlockAgenda = 0;
1271} 1271}
1272void KOAgendaView::repaintAgenda() 1272void KOAgendaView::repaintAgenda()
1273{ 1273{
1274 // mAllDayAgenda->drawContentsToPainter(); 1274 // mAllDayAgenda->drawContentsToPainter();
1275// mAllDayAgenda->viewport()->repaint( false ); 1275// mAllDayAgenda->viewport()->repaint( false );
1276// mAgenda->drawContentsToPainter(); 1276// mAgenda->drawContentsToPainter();
1277// mAgenda->viewport()->repaint( false ); 1277// mAgenda->viewport()->repaint( false );
1278// qApp->processEvents(); 1278// qApp->processEvents();
1279 1279
1280 //qDebug("KOAgendaView::repaintAgenda() "); 1280 //qDebug("KOAgendaView::repaintAgenda() ");
1281 //qApp->processEvents(); 1281 //qApp->processEvents();
1282 mAgenda->viewport()->repaint( false ); 1282 mAgenda->viewport()->repaint( false );
1283 mAllDayAgenda->viewport()->repaint( false ); 1283 mAllDayAgenda->viewport()->repaint( false );
1284 mAgenda->finishUpdate(); 1284 mAgenda->finishUpdate();
1285 mAllDayAgenda->finishUpdate(); 1285 mAllDayAgenda->finishUpdate();
1286} 1286}
1287 1287
1288 1288
1289void KOAgendaView::clearView() 1289void KOAgendaView::clearView()
1290{ 1290{
1291 // kdDebug() << "ClearView" << endl; 1291 // kdDebug() << "ClearView" << endl;
1292 mAllDayAgenda->clear(); 1292 mAllDayAgenda->clear();
1293 mAgenda->clear(); 1293 mAgenda->clear();
1294} 1294}
1295 1295
1296void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd, 1296void KOAgendaView::printPreview(CalPrinter *calPrinter, const QDate &fd,
1297 const QDate &td) 1297 const QDate &td)
1298{ 1298{
1299#ifndef KORG_NOPRINTER 1299#ifndef KORG_NOPRINTER
1300 if (fd == td) 1300 if (fd == td)
1301 calPrinter->preview(CalPrinter::Day, fd, td); 1301 calPrinter->preview(CalPrinter::Day, fd, td);
1302 else 1302 else
1303 calPrinter->preview(CalPrinter::Week, fd, td); 1303 calPrinter->preview(CalPrinter::Week, fd, td);
1304#endif 1304#endif
1305} 1305}
1306 1306
1307// void KOAgendaView::updateMovedTodo() 1307// void KOAgendaView::updateMovedTodo()
1308// { 1308// {
1309// // updateConfig(); 1309// // updateConfig();
1310// // emit updateTodoViews(); 1310// // emit updateTodoViews();
1311// } 1311// }
1312 1312
1313void KOAgendaView::slotShowDateView( int mode , int d )
1314{
1315 if ( d >= mSelectedDates.count() ) {
1316 qDebug("KOAgendaView::slotShowDateView datecounterror %d d ", d, mSelectedDates.count() );
1317
1318 } else {
1319 QDate day = mSelectedDates[d];
1320 emit showDateView(mode , day );
1321 }
1322
1323}
1313void KOAgendaView::newEvent(int gx, int gy) 1324void KOAgendaView::newEvent(int gx, int gy)
1314{ 1325{
1315 if (!mSelectedDates.count()) return; 1326 if (!mSelectedDates.count()) return;
1316 1327
1317 QDate day = mSelectedDates[gx]; 1328 QDate day = mSelectedDates[gx];
1318 1329
1319 QTime time = mAgenda->gyToTime(gy); 1330 QTime time = mAgenda->gyToTime(gy);
1320 QDateTime dt(day,time); 1331 QDateTime dt(day,time);
1321 // if ( dt < QDateTime::currentDateTime () ) 1332 // if ( dt < QDateTime::currentDateTime () )
1322 // dt = QDateTime::currentDateTime ().addSecs( 3600 ); 1333 // dt = QDateTime::currentDateTime ().addSecs( 3600 );
1323 emit newEventSignal(dt); 1334 emit newEventSignal(dt);
1324} 1335}
1325 1336
1326void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd) 1337void KOAgendaView::newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd)
1327{ 1338{
1328 if (!mSelectedDates.count()) return; 1339 if (!mSelectedDates.count()) return;
1329 1340
1330 QDate dayStart = mSelectedDates[gxStart]; 1341 QDate dayStart = mSelectedDates[gxStart];
1331 QDate dayEnd = mSelectedDates[gxEnd]; 1342 QDate dayEnd = mSelectedDates[gxEnd];
1332 1343
1333 QTime timeStart = mAgenda->gyToTime(gyStart); 1344 QTime timeStart = mAgenda->gyToTime(gyStart);
1334 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 ); 1345 QTime timeEnd = mAgenda->gyToTime( gyEnd + 1 );
1335 1346
1336 QDateTime dtStart(dayStart,timeStart); 1347 QDateTime dtStart(dayStart,timeStart);
1337 QDateTime dtEnd(dayEnd,timeEnd); 1348 QDateTime dtEnd(dayEnd,timeEnd);
1338 1349
1339 emit newEventSignal(dtStart,dtEnd); 1350 emit newEventSignal(dtStart,dtEnd);
1340} 1351}
1341 1352
1342void KOAgendaView::newEventAllDay(int gx, int ) 1353void KOAgendaView::newEventAllDay(int gx, int )
1343{ 1354{
1344 if (!mSelectedDates.count()) return; 1355 if (!mSelectedDates.count()) return;
1345 1356
1346 QDate day = mSelectedDates[gx]; 1357 QDate day = mSelectedDates[gx];
1347 1358
1348 emit newEventSignal(day); 1359 emit newEventSignal(day);
1349} 1360}
1350void KOAgendaView::newTodoAllDay(int gx, int ) 1361void KOAgendaView::newTodoAllDay(int gx, int )
1351{ 1362{
1352 if (!mSelectedDates.count()) return; 1363 if (!mSelectedDates.count()) return;
1353 1364
1354 QDateTime day (mSelectedDates[gx] ); 1365 QDateTime day (mSelectedDates[gx] );
1355 emit newTodoSignal(day, true); 1366 emit newTodoSignal(day, true);
1356} 1367}
1357void KOAgendaView::newTodo(int gx, int gy ) 1368void KOAgendaView::newTodo(int gx, int gy )
1358{ 1369{
1359 if (!mSelectedDates.count()) return; 1370 if (!mSelectedDates.count()) return;
1360 QDate dayStart = mSelectedDates[gx]; 1371 QDate dayStart = mSelectedDates[gx];
1361 QTime timeStart = mAgenda->gyToTime(gy); 1372 QTime timeStart = mAgenda->gyToTime(gy);
1362 QDateTime dt (dayStart,timeStart); 1373 QDateTime dt (dayStart,timeStart);
1363 emit newTodoSignal( dt, false ); 1374 emit newTodoSignal( dt, false );
1364} 1375}
1365 1376
1366void KOAgendaView::updateEventIndicatorTop(int newY) 1377void KOAgendaView::updateEventIndicatorTop(int newY)
1367{ 1378{
1368 uint i; 1379 uint i;
1369 for(i=0;i<mMinY.size();++i) { 1380 for(i=0;i<mMinY.size();++i) {
1370 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true); 1381 if (newY >= mMinY.at(i)) mEventIndicatorTop->enableColumn(i,true);
1371 else mEventIndicatorTop->enableColumn(i,false); 1382 else mEventIndicatorTop->enableColumn(i,false);
1372 } 1383 }
1373 1384
1374 mEventIndicatorTop->update(); 1385 mEventIndicatorTop->update();
1375} 1386}
1376 1387
1377void KOAgendaView::updateEventIndicatorBottom(int newY) 1388void KOAgendaView::updateEventIndicatorBottom(int newY)
1378{ 1389{
1379 uint i; 1390 uint i;
1380 for(i=0;i<mMaxY.size();++i) { 1391 for(i=0;i<mMaxY.size();++i) {
1381 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true); 1392 if (newY <= mMaxY.at(i)) mEventIndicatorBottom->enableColumn(i,true);
1382 else mEventIndicatorBottom->enableColumn(i,false); 1393 else mEventIndicatorBottom->enableColumn(i,false);
1383 } 1394 }
1384 1395
1385 mEventIndicatorBottom->update(); 1396 mEventIndicatorBottom->update();
1386} 1397}
1387 1398
1388void KOAgendaView::startDrag(Event *event) 1399void KOAgendaView::startDrag(Event *event)
1389{ 1400{
1390#ifndef KORG_NODND 1401#ifndef KORG_NODND
1391 DndFactory factory( calendar() ); 1402 DndFactory factory( calendar() );
1392 ICalDrag *vd = factory.createDrag(event,this); 1403 ICalDrag *vd = factory.createDrag(event,this);
1393 if (vd->drag()) { 1404 if (vd->drag()) {
1394 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl; 1405 kdDebug() << "KOAgendaView::startDrag(): Delete drag source" << endl;
1395 } 1406 }
1396#endif 1407#endif
1397} 1408}
1398 1409
1399void KOAgendaView::readSettings() 1410void KOAgendaView::readSettings()
1400{ 1411{
1401 readSettings(KOGlobals::config()); 1412 readSettings(KOGlobals::config());
1402} 1413}
1403 1414
1404void KOAgendaView::readSettings(KConfig *config) 1415void KOAgendaView::readSettings(KConfig *config)
1405{ 1416{
1406 // kdDebug() << "KOAgendaView::readSettings()" << endl; 1417 // kdDebug() << "KOAgendaView::readSettings()" << endl;
1407 1418
1408 config->setGroup("Views"); 1419 config->setGroup("Views");
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index 57b4e46..6dc81c6 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -113,177 +113,178 @@ class TimeLabels : public QScrollView {
113 113
114class EventIndicator : public QFrame { 114class EventIndicator : public QFrame {
115 Q_OBJECT 115 Q_OBJECT
116 public: 116 public:
117 enum Location { Top, Bottom }; 117 enum Location { Top, Bottom };
118 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 118 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
119 virtual ~EventIndicator(); 119 virtual ~EventIndicator();
120 120
121 void changeColumns(int columns); 121 void changeColumns(int columns);
122 void setPaintWidget( KDGanttMinimizeSplitter* ); 122 void setPaintWidget( KDGanttMinimizeSplitter* );
123 void setXOffset( int ); 123 void setXOffset( int );
124 void enableColumn(int column, bool enable); 124 void enableColumn(int column, bool enable);
125 125
126 protected: 126 protected:
127 void drawContents(QPainter *); 127 void drawContents(QPainter *);
128 128
129 private: 129 private:
130 int mXOffset; 130 int mXOffset;
131 KDGanttMinimizeSplitter* mPaintWidget; 131 KDGanttMinimizeSplitter* mPaintWidget;
132 int mColumns; 132 int mColumns;
133 QHBox *mTopBox; 133 QHBox *mTopBox;
134 QBoxLayout *mTopLayout; 134 QBoxLayout *mTopLayout;
135 Location mLocation; 135 Location mLocation;
136 QPixmap mPixmap; 136 QPixmap mPixmap;
137 QMemArray<bool> mEnabled; 137 QMemArray<bool> mEnabled;
138}; 138};
139 139
140/** 140/**
141 KOAgendaView is the agenda-like view used to display events in an one or 141 KOAgendaView is the agenda-like view used to display events in an one or
142 multi-day view. 142 multi-day view.
143*/ 143*/
144class KOAgendaView : public KOEventView { 144class KOAgendaView : public KOEventView {
145 Q_OBJECT 145 Q_OBJECT
146 public: 146 public:
147 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 ); 147 KOAgendaView(Calendar *cal,QWidget *parent = 0,const char *name = 0 );
148 virtual ~KOAgendaView(); 148 virtual ~KOAgendaView();
149 void setStartHour( int ); 149 void setStartHour( int );
150 void toggleAllDay(); 150 void toggleAllDay();
151 151
152 152
153 /** Returns maximum number of days supported by the koagendaview */ 153 /** Returns maximum number of days supported by the koagendaview */
154 virtual int maxDatesHint(); 154 virtual int maxDatesHint();
155 155
156 /** Returns number of currently shown dates. */ 156 /** Returns number of currently shown dates. */
157 virtual int currentDateCount(); 157 virtual int currentDateCount();
158 158
159 /** returns the currently selected events */ 159 /** returns the currently selected events */
160 virtual QPtrList<Incidence> selectedIncidences(); 160 virtual QPtrList<Incidence> selectedIncidences();
161 161
162 /** returns the currently selected events */ 162 /** returns the currently selected events */
163 virtual DateList selectedDates(); 163 virtual DateList selectedDates();
164 164
165 /** Remove all events from view */ 165 /** Remove all events from view */
166 void clearView(); 166 void clearView();
167 KOAgenda *agenda() { return mAgenda;} 167 KOAgenda *agenda() { return mAgenda;}
168 virtual void printPreview(CalPrinter *calPrinter, 168 virtual void printPreview(CalPrinter *calPrinter,
169 const QDate &, const QDate &); 169 const QDate &, const QDate &);
170 170
171 /** start-datetime of selection */ 171 /** start-datetime of selection */
172 QDateTime selectionStart() {return mTimeSpanBegin;} 172 QDateTime selectionStart() {return mTimeSpanBegin;}
173 /** end-datetime of selection */ 173 /** end-datetime of selection */
174 QDateTime selectionEnd() {return mTimeSpanEnd;} 174 QDateTime selectionEnd() {return mTimeSpanEnd;}
175 /** returns true if selection is for whole day */ 175 /** returns true if selection is for whole day */
176 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 176 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
177 /** make selected start/end invalid */ 177 /** make selected start/end invalid */
178 void deleteSelectedDateTime(); 178 void deleteSelectedDateTime();
179 void repaintAgenda(); 179 void repaintAgenda();
180 public slots: 180 public slots:
181 void setInitStartHour(); 181 void setInitStartHour();
182 virtual void updateView(); 182 virtual void updateView();
183 virtual void updateConfig(); 183 virtual void updateConfig();
184 virtual void showDates(const QDate &start, const QDate &end); 184 virtual void showDates(const QDate &start, const QDate &end);
185 virtual void showEvents(QPtrList<Event> eventList); 185 virtual void showEvents(QPtrList<Event> eventList);
186 186
187 void updateTodo( Todo *, int ); 187 void updateTodo( Todo *, int );
188 void changeEventDisplay(Event *, int); 188 void changeEventDisplay(Event *, int);
189 189
190 void clearSelection(); 190 void clearSelection();
191 191
192 void newTodo(int gx,int gy); 192 void newTodo(int gx,int gy);
193 void newEvent(int gx,int gy); 193 void newEvent(int gx,int gy);
194 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 194 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
195 void newEventAllDay(int gx, int gy); 195 void newEventAllDay(int gx, int gy);
196 void newTodoAllDay(int gx, int gy); 196 void newTodoAllDay(int gx, int gy);
197 197
198 void startDrag(Event *); 198 void startDrag(Event *);
199 199
200 void readSettings(); 200 void readSettings();
201 void readSettings(KConfig *); 201 void readSettings(KConfig *);
202 void writeSettings(KConfig *); 202 void writeSettings(KConfig *);
203 203
204 void setContentsPos(int y); 204 void setContentsPos(int y);
205 205
206 void scrollOneHourUp(); 206 void scrollOneHourUp();
207 void scrollOneHourDown(); 207 void scrollOneHourDown();
208 void addToCalSlot(Incidence *, Incidence *); 208 void addToCalSlot(Incidence *, Incidence *);
209 void slotShowDateView( int, int );
209 210
210 signals: 211 signals:
211 void showDateView( int, QDate ); 212 void showDateView( int, QDate );
212 void newTodoSignal( QDateTime ,bool ); 213 void newTodoSignal( QDateTime ,bool );
213 void toggleExpand(); 214 void toggleExpand();
214 void selectWeekNum( int ); 215 void selectWeekNum( int );
215 void todoMoved( Todo *, int ); 216 void todoMoved( Todo *, int );
216 void incidenceChanged(Incidence * , int ); 217 void incidenceChanged(Incidence * , int );
217 // void cloneIncidenceSignal(Incidence *); 218 // void cloneIncidenceSignal(Incidence *);
218 219
219 protected: 220 protected:
220 KOAgendaButton* getNewDaylabel(); 221 KOAgendaButton* getNewDaylabel();
221 bool mBlockUpdating; 222 bool mBlockUpdating;
222 int mUpcomingWidth; 223 int mUpcomingWidth;
223 /** Fill agenda beginning with date startDate */ 224 /** Fill agenda beginning with date startDate */
224 void fillAgenda(const QDate &startDate); 225 void fillAgenda(const QDate &startDate);
225 void resizeEvent( QResizeEvent* e ); 226 void resizeEvent( QResizeEvent* e );
226 /** Fill agenda using the current set value for the start date */ 227 /** Fill agenda using the current set value for the start date */
227 void fillAgenda(); 228 void fillAgenda();
228 229
229 /** Create labels for the selected dates. */ 230 /** Create labels for the selected dates. */
230 void createDayLabels(); 231 void createDayLabels();
231 232
232 /** 233 /**
233 Set the masks on the agenda widgets indicating, which days are holidays. 234 Set the masks on the agenda widgets indicating, which days are holidays.
234 */ 235 */
235 void setHolidayMasks(); 236 void setHolidayMasks();
236 237
237 protected slots: 238 protected slots:
238 void slotDaylabelClicked( int ); 239 void slotDaylabelClicked( int );
239 /** Update event belonging to agenda item */ 240 /** Update event belonging to agenda item */
240 void updateEventDates(KOAgendaItem *item, int mode = -1); 241 void updateEventDates(KOAgendaItem *item, int mode = -1);
241 //void updateMovedTodo(); 242 //void updateMovedTodo();
242 243
243 void updateEventIndicatorTop(int newY); 244 void updateEventIndicatorTop(int newY);
244 void updateEventIndicatorBottom(int newY); 245 void updateEventIndicatorBottom(int newY);
245 246
246 /** Updates data for selected timespan */ 247 /** Updates data for selected timespan */
247 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 248 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
248 /** Updates data for selected timespan for all day event*/ 249 /** Updates data for selected timespan for all day event*/
249 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 250 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
250 251
251 private: 252 private:
252 // view widgets 253 // view widgets
253 QFrame *mDayLabels; 254 QFrame *mDayLabels;
254 QHBox *mDayLabelsFrame; 255 QHBox *mDayLabelsFrame;
255 QBoxLayout *mLayoutDayLabels; 256 QBoxLayout *mLayoutDayLabels;
256 QFrame *mAllDayFrame; 257 QFrame *mAllDayFrame;
257 KOAgenda *mAllDayAgenda; 258 KOAgenda *mAllDayAgenda;
258 KOAgenda *mAgenda; 259 KOAgenda *mAgenda;
259 TimeLabels *mTimeLabels; 260 TimeLabels *mTimeLabels;
260 QWidget *mDummyAllDayLeft; 261 QWidget *mDummyAllDayLeft;
261 262
262 KDGanttMinimizeSplitter* mSplitterAgenda; 263 KDGanttMinimizeSplitter* mSplitterAgenda;
263 QPushButton *mExpandButton; 264 QPushButton *mExpandButton;
264 265
265 DateList mSelectedDates; // List of dates to be displayed 266 DateList mSelectedDates; // List of dates to be displayed
266 int mViewType; 267 int mViewType;
267 268
268 bool mWeekStartsMonday; 269 bool mWeekStartsMonday;
269 int mStartHour; 270 int mStartHour;
270 271
271 KOEventPopupMenu *mAgendaPopup; 272 KOEventPopupMenu *mAgendaPopup;
272 KOEventPopupMenu *mAllDayAgendaPopup; 273 KOEventPopupMenu *mAllDayAgendaPopup;
273 274
274 EventIndicator *mEventIndicatorTop; 275 EventIndicator *mEventIndicatorTop;
275 EventIndicator *mEventIndicatorBottom; 276 EventIndicator *mEventIndicatorBottom;
276 277
277 QMemArray<int> mMinY; 278 QMemArray<int> mMinY;
278 QMemArray<int> mMaxY; 279 QMemArray<int> mMaxY;
279 280
280 QMemArray<bool> mHolidayMask; 281 QMemArray<bool> mHolidayMask;
281 282
282 QPtrList<KOAgendaButton> mDayLabelsList; 283 QPtrList<KOAgendaButton> mDayLabelsList;
283 QDateTime mTimeSpanBegin; 284 QDateTime mTimeSpanBegin;
284 QDateTime mTimeSpanEnd; 285 QDateTime mTimeSpanEnd;
285 bool mTimeSpanInAllDay; 286 bool mTimeSpanInAllDay;
286 void keyPressEvent ( QKeyEvent * e ); 287 void keyPressEvent ( QKeyEvent * e );
287}; 288};
288 289
289#endif // KOAGENDAVIEW_H 290#endif // KOAGENDAVIEW_H
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index b9ce4f4..ab9a4b6 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -844,193 +844,197 @@ void MonthViewCell::enableScrollBars( bool enabled )
844 int ihei = fi->height( this ); 844 int ihei = fi->height( this );
845 int hei = numRows () * ihei; 845 int hei = numRows () * ihei;
846 if ( hei < height() - horizontalScrollBar()->height () ) { 846 if ( hei < height() - horizontalScrollBar()->height () ) {
847 setVScrollBarMode(QScrollView::AlwaysOff); 847 setVScrollBarMode(QScrollView::AlwaysOff);
848 } 848 }
849 else 849 else
850 setVScrollBarMode(QScrollView::Auto); 850 setVScrollBarMode(QScrollView::Auto);
851 if ( ihei *3 > height() ) 851 if ( ihei *3 > height() )
852 setHScrollBarMode(QScrollView::AlwaysOff); 852 setHScrollBarMode(QScrollView::AlwaysOff);
853 else 853 else
854 setHScrollBarMode(QScrollView::Auto); 854 setHScrollBarMode(QScrollView::Auto);
855 } else { 855 } else {
856 setVScrollBarMode(QScrollView::Auto); 856 setVScrollBarMode(QScrollView::Auto);
857 setHScrollBarMode(QScrollView::Auto); 857 setHScrollBarMode(QScrollView::Auto);
858 } 858 }
859 } else { 859 } else {
860 setVScrollBarMode(QScrollView::AlwaysOff); 860 setVScrollBarMode(QScrollView::AlwaysOff);
861 setHScrollBarMode(QScrollView::AlwaysOff); 861 setHScrollBarMode(QScrollView::AlwaysOff);
862 } 862 }
863} 863}
864 864
865Incidence *MonthViewCell::selectedIncidence() 865Incidence *MonthViewCell::selectedIncidence()
866{ 866{
867 int index = currentItem(); 867 int index = currentItem();
868 if ( index < 0 ) return 0; 868 if ( index < 0 ) return 0;
869 869
870 MonthViewItem *mitem = 870 MonthViewItem *mitem =
871 static_cast<MonthViewItem *>( item( index ) ); 871 static_cast<MonthViewItem *>( item( index ) );
872 872
873 if ( !mitem ) return 0; 873 if ( !mitem ) return 0;
874 874
875 return mitem->incidence(); 875 return mitem->incidence();
876} 876}
877 877
878QDate MonthViewCell::selectedIncidenceDate() 878QDate MonthViewCell::selectedIncidenceDate()
879{ 879{
880 QDate qd; 880 QDate qd;
881 int index = currentItem(); 881 int index = currentItem();
882 if ( index < 0 ) return qd; 882 if ( index < 0 ) return qd;
883 883
884 MonthViewItem *mitem = 884 MonthViewItem *mitem =
885 static_cast<MonthViewItem *>( item( index ) ); 885 static_cast<MonthViewItem *>( item( index ) );
886 886
887 if ( !mitem ) return qd; 887 if ( !mitem ) return qd;
888 888
889 return mitem->incidenceDate(); 889 return mitem->incidenceDate();
890} 890}
891 891
892void MonthViewCell::deselect() 892void MonthViewCell::deselect()
893{ 893{
894 clearSelection(); 894 clearSelection();
895 enableScrollBars( false ); 895 enableScrollBars( false );
896 // updateCell(); 896 // updateCell();
897} 897}
898void MonthViewCell::select() 898void MonthViewCell::select()
899{ 899{
900 ;// updateCell(); 900 ;// updateCell();
901} 901}
902 902
903void MonthViewCell::resizeEvent ( QResizeEvent * e ) 903void MonthViewCell::resizeEvent ( QResizeEvent * e )
904{ 904{
905 if ( !mMonthView->isUpdatePossible() ) 905 if ( !mMonthView->isUpdatePossible() )
906 return; 906 return;
907 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); 907 //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height());
908 deselect(); 908 deselect();
909 mLabel->setMaximumHeight( height() - lineWidth()*2 ); 909 mLabel->setMaximumHeight( height() - lineWidth()*2 );
910 910
911 QString text; 911 QString text;
912 mLabel->setText( text ); 912 mLabel->setText( text );
913 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; 913 bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
914 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) { 914 if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
915 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " "; 915 text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
916 mLabel->resize( mLabelBigSize ); 916 mLabel->resize( mLabelBigSize );
917 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 917 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
918 } else { 918 } else {
919 mLabel->resize( mLabelSize ); 919 mLabel->resize( mLabelSize );
920 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) ); 920 text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
921 } 921 }
922 mLabel->setText( text ); 922 mLabel->setText( text );
923 923
924 int size = height() - mLabel->height() - lineWidth()-1; 924 int size = height() - mLabel->height() - lineWidth()-1;
925 //qDebug("LW %d ", lineWidth()); 925 //qDebug("LW %d ", lineWidth());
926 if ( size > 0 ) 926 if ( size > 0 )
927 verticalScrollBar()->setMaximumHeight( size ); 927 verticalScrollBar()->setMaximumHeight( size );
928 size = width() - mLabel->width() -lineWidth()-1; 928 size = width() - mLabel->width() -lineWidth()-1;
929 if ( size > 0 ) 929 if ( size > 0 )
930 horizontalScrollBar()->setMaximumWidth( size ); 930 horizontalScrollBar()->setMaximumWidth( size );
931 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); 931 mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() );
932 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 932 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
933 // mItemList->resize ( width(), height () ); 933 // mItemList->resize ( width(), height () );
934 if ( e ) 934 if ( e )
935 KNoScrollListBox::resizeEvent ( e ); 935 KNoScrollListBox::resizeEvent ( e );
936} 936}
937 937
938void MonthViewCell::defaultAction( QListBoxItem *item ) 938void MonthViewCell::defaultAction( QListBoxItem *item )
939{ 939{
940 if ( !item ) return; 940 if ( !item ) {
941 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
942 emit newEventSignal( dt );
943 return;
944 }
941 945
942 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 946 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
943 Incidence *incidence = eventItem->incidence(); 947 Incidence *incidence = eventItem->incidence();
944 if ( incidence ) mMonthView->defaultAction( incidence ); 948 if ( incidence ) mMonthView->defaultAction( incidence );
945} 949}
946void MonthViewCell::showDay() 950void MonthViewCell::showDay()
947{ 951{
948 emit showDaySignal( date() ); 952 emit showDaySignal( date() );
949} 953}
950void MonthViewCell::newEvent() 954void MonthViewCell::newEvent()
951{ 955{
952 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 956 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
953 emit newEventSignal( dt ); 957 emit newEventSignal( dt );
954} 958}
955void MonthViewCell::cellClicked( QListBoxItem *item ) 959void MonthViewCell::cellClicked( QListBoxItem *item )
956{ 960{
957 static QListBoxItem * lastClicked = 0; 961 static QListBoxItem * lastClicked = 0;
958 if ( item == 0 ) { 962 if ( item == 0 ) {
959 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); 963 QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
960 emit newEventSignal( dt ); 964 emit newEventSignal( dt );
961 return; 965 return;
962 } 966 }
963 /* 967 /*
964 if ( lastClicked ) 968 if ( lastClicked )
965 if ( ! item ) { 969 if ( ! item ) {
966 if ( lastClicked->listBox() != item->listBox() ) 970 if ( lastClicked->listBox() != item->listBox() )
967 lastClicked->listBox()->clearSelection(); 971 lastClicked->listBox()->clearSelection();
968 } 972 }
969 */ 973 */
970 974
971 mMonthView->setSelectedCell( this ); 975 mMonthView->setSelectedCell( this );
972 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true ); 976 if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
973 select(); 977 select();
974} 978}
975 979
976void MonthViewCell::contextMenu( QListBoxItem *item ) 980void MonthViewCell::contextMenu( QListBoxItem *item )
977{ 981{
978 if ( !item ) return; 982 if ( !item ) return;
979 983
980 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 984 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
981 Incidence *incidence = eventItem->incidence(); 985 Incidence *incidence = eventItem->incidence();
982 if ( incidence ) mMonthView->showContextMenu( incidence ); 986 if ( incidence ) mMonthView->showContextMenu( incidence );
983} 987}
984 988
985void MonthViewCell::selection( QListBoxItem *item ) 989void MonthViewCell::selection( QListBoxItem *item )
986{ 990{
987 if ( !item ) return; 991 if ( !item ) return;
988 992
989 mMonthView->setSelectedCell( this ); 993 mMonthView->setSelectedCell( this );
990} 994}
991 995
992 996
993// ******************************************************************************* 997// *******************************************************************************
994// ******************************************************************************* 998// *******************************************************************************
995// ******************************************************************************* 999// *******************************************************************************
996 1000
997 1001
998KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) 1002KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
999 : KOEventView( calendar, parent, name ), 1003 : KOEventView( calendar, parent, name ),
1000 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), 1004 mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ),
1001 mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) 1005 mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
1002{ 1006{
1003 mFlagKeyPressed = false; 1007 mFlagKeyPressed = false;
1004 mShortDayLabelsM = false; 1008 mShortDayLabelsM = false;
1005 mShortDayLabelsW = false; 1009 mShortDayLabelsW = false;
1006 skipResize = false; 1010 skipResize = false;
1007 clPending = true; 1011 clPending = true;
1008 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" ); 1012 mNavigatorBar = new NavigatorBar( QDate::currentDate(), this, "useBigPixmaps" );
1009 mWidStack = new QWidgetStack( this ); 1013 mWidStack = new QWidgetStack( this );
1010 QVBoxLayout* hb = new QVBoxLayout( this ); 1014 QVBoxLayout* hb = new QVBoxLayout( this );
1011 mMonthView = new QWidget( mWidStack ); 1015 mMonthView = new QWidget( mWidStack );
1012 mWeekView = new QWidget( mWidStack ); 1016 mWeekView = new QWidget( mWidStack );
1013#if QT_VERSION >= 0x030000 1017#if QT_VERSION >= 0x030000
1014 mWidStack->addWidget(mMonthView ); 1018 mWidStack->addWidget(mMonthView );
1015 mWidStack->addWidget(mWeekView ); 1019 mWidStack->addWidget(mWeekView );
1016#else 1020#else
1017 mWidStack->addWidget( mMonthView, 1 ); 1021 mWidStack->addWidget( mMonthView, 1 );
1018 mWidStack->addWidget( mWeekView , 1 ); 1022 mWidStack->addWidget( mWeekView , 1 );
1019#endif 1023#endif
1020 hb->addWidget( mNavigatorBar ); 1024 hb->addWidget( mNavigatorBar );
1021 hb->addWidget( mWidStack ); 1025 hb->addWidget( mWidStack );
1022 mShowWeekView = KOPrefs::instance()->mMonthViewWeek; 1026 mShowWeekView = KOPrefs::instance()->mMonthViewWeek;
1023 updatePossible = false; 1027 updatePossible = false;
1024 //updatePossible = true; 1028 //updatePossible = true;
1025 mCells.setAutoDelete( true ); 1029 mCells.setAutoDelete( true );
1026 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; 1030 mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
1027 mDayLabels.resize( mDaysPerWeek ); 1031 mDayLabels.resize( mDaysPerWeek );
1028 mDayLabelsW.resize( mDaysPerWeek ); 1032 mDayLabelsW.resize( mDaysPerWeek );
1029 QFont bfont = font(); 1033 QFont bfont = font();
1030 if ( QApplication::desktop()->width() < 650 ) { 1034 if ( QApplication::desktop()->width() < 650 ) {
1031 bfont.setPointSize( bfont.pointSize() - 2 ); 1035 bfont.setPointSize( bfont.pointSize() - 2 );
1032 } 1036 }
1033 bfont.setBold( true ); 1037 bfont.setBold( true );
1034 int i; 1038 int i;
1035 1039
1036 for( i = 0; i < mDaysPerWeek; i++ ) { 1040 for( i = 0; i < mDaysPerWeek; i++ ) {
@@ -1278,192 +1282,193 @@ void KOMonthView::updateDayLabels()
1278 for (int i = 0; i < 7; i++) { 1282 for (int i = 0; i < 7; i++) {
1279 { 1283 {
1280 bool show = mShortDayLabelsW; 1284 bool show = mShortDayLabelsW;
1281 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1285 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1282 show = true; 1286 show = true;
1283 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1287 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1284 } 1288 }
1285 } 1289 }
1286 mDayLabelsT = &mDayLabels; 1290 mDayLabelsT = &mDayLabels;
1287 for (int i = 0; i < 7; i++) { 1291 for (int i = 0; i < 7; i++) {
1288 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) { 1292 if (KGlobal::locale()->weekStartsMonday() || KOPrefs::instance()->mMonthViewSatSunTog ) {
1289 bool show = mShortDayLabelsM; 1293 bool show = mShortDayLabelsM;
1290 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() ) 1294 if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > (*mDayLabelsT)[i]->width() )
1291 show = true; 1295 show = true;
1292 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show)); 1296 (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
1293 } else { 1297 } else {
1294 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM)); 1298 if (i==0) (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabelsM));
1295 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM)); 1299 else (*mDayLabelsT)[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabelsM));
1296 1300
1297 } 1301 }
1298 } 1302 }
1299 1303
1300} 1304}
1301 1305
1302void KOMonthView::showDates(const QDate &start, const QDate &) 1306void KOMonthView::showDates(const QDate &start, const QDate &)
1303{ 1307{
1304 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl; 1308 // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
1305 1309
1306 QPtrVector<MonthViewCell> *cells; 1310 QPtrVector<MonthViewCell> *cells;
1307 QPtrVector<QLabel> *dayLabels; 1311 QPtrVector<QLabel> *dayLabels;
1308 QPtrVector<KOWeekButton> *weekLabels; 1312 QPtrVector<KOWeekButton> *weekLabels;
1309 int weekNum = 6; 1313 int weekNum = 6;
1310 mStartDate = start; 1314 mStartDate = start;
1311 if ( mShowWeekView ) { 1315 if ( mShowWeekView ) {
1312 weekNum = 1; 1316 weekNum = 1;
1313 cells = &mCellsW; 1317 cells = &mCellsW;
1314 dayLabels = &mDayLabelsW; 1318 dayLabels = &mDayLabelsW;
1315 weekLabels = &mWeekLabelsW; 1319 weekLabels = &mWeekLabelsW;
1316 if ( !KGlobal::locale()->weekStartsMonday() ) { 1320 if ( !KGlobal::locale()->weekStartsMonday() ) {
1317 mStartDate = mStartDate.addDays( 1 ); 1321 mStartDate = mStartDate.addDays( 1 );
1318 } 1322 }
1319 } else { 1323 } else {
1320 cells = &mCells; 1324 cells = &mCells;
1321 dayLabels = &mDayLabels; 1325 dayLabels = &mDayLabels;
1322 weekLabels = &mWeekLabels; 1326 weekLabels = &mWeekLabels;
1323 } 1327 }
1324 1328
1325 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); 1329 int mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
1326 1330
1327 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) { 1331 if ( mShowWeekView || KOPrefs::instance()->mMonthViewSatSunTog ) {
1328 mWeekStartsMonday = true; 1332 mWeekStartsMonday = true;
1329 } 1333 }
1330 int startWeekDay = mWeekStartsMonday ? 1 : 7; 1334 int startWeekDay = mWeekStartsMonday ? 1 : 7;
1331 1335
1332 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) { 1336 while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
1333 mStartDate = mStartDate.addDays( -1 ); 1337 mStartDate = mStartDate.addDays( -1 );
1334 } 1338 }
1335 bool primary = false; 1339 bool primary = false;
1336 uint i; 1340 uint i;
1337 for( i = 0; i < (*cells).size(); ++i ) { 1341 for( i = 0; i < (*cells).size(); ++i ) {
1338 QDate date = mStartDate.addDays( i ); 1342 QDate date = mStartDate.addDays( i );
1339 (*cells)[i]->setDate( date ); 1343 (*cells)[i]->setDate( date );
1340 1344
1341#ifndef KORG_NOPLUGINS 1345#ifndef KORG_NOPLUGINS
1342 // add holiday, if present 1346 // add holiday, if present
1343 QString hstring(KOCore::self()->holiday(date)); 1347 QString hstring(KOCore::self()->holiday(date));
1344 (*cells)[i]->setHoliday( hstring ); 1348 (*cells)[i]->setHoliday( hstring );
1345#endif 1349#endif
1346 1350
1347 } 1351 }
1348 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 ); 1352 QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
1349 for( i = 0; i < weekNum; ++i ) { 1353 for( i = 0; i < weekNum; ++i ) {
1350 int wno; 1354 int wno;
1351 // remember, according to ISO 8601, the first week of the year is the 1355 // remember, according to ISO 8601, the first week of the year is the
1352 // first week that contains a thursday. Thus we must subtract off 4, 1356 // first week that contains a thursday. Thus we must subtract off 4,
1353 // not just 1. 1357 // not just 1.
1354 int dayOfYear = date.dayOfYear(); 1358 int dayOfYear = date.dayOfYear();
1355 if (dayOfYear % 7 != 0) 1359 if (dayOfYear % 7 != 0)
1356 wno = dayOfYear / 7 + 1; 1360 wno = dayOfYear / 7 + 1;
1357 else 1361 else
1358 wno =dayOfYear / 7; 1362 wno =dayOfYear / 7;
1359 (*weekLabels)[i]->setWeekNum( wno ); 1363 (*weekLabels)[i]->setWeekNum( wno );
1360 date = date.addDays( 7 ); 1364 date = date.addDays( 7 );
1361 } 1365 }
1362 updateView(); 1366 updateView();
1363} 1367}
1364 1368
1365void KOMonthView::showEvents(QPtrList<Event>) 1369void KOMonthView::showEvents(QPtrList<Event>)
1366{ 1370{
1367 qDebug("KOMonthView::selectEvents is not implemented yet. "); 1371 qDebug("KOMonthView::selectEvents is not implemented yet. ");
1368} 1372}
1369 1373
1370void KOMonthView::changeEventDisplay(Event *, int) 1374void KOMonthView::changeEventDisplay(Event *, int)
1371{ 1375{
1372 // this should be re-written to be much more efficient, but this 1376 // this should be re-written to be much more efficient, but this
1373 // quick-and-dirty-hack gets the job done for right now. 1377 // quick-and-dirty-hack gets the job done for right now.
1378 qDebug("KOMonthView::changeEventDisplay ");
1374 updateView(); 1379 updateView();
1375} 1380}
1376 1381
1377void KOMonthView::updateView() 1382void KOMonthView::updateView()
1378{ 1383{
1379 1384
1380 if ( !updatePossible ) 1385 if ( !updatePossible )
1381 return; 1386 return;
1382 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); 1387 //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
1383 //QTime ti; 1388 //QTime ti;
1384 //ti.start(); 1389 //ti.start();
1385 clearSelection(); 1390 clearSelection();
1386 QPtrVector<MonthViewCell> *cells; 1391 QPtrVector<MonthViewCell> *cells;
1387 if ( mShowWeekView ) { 1392 if ( mShowWeekView ) {
1388 cells = &mCellsW; 1393 cells = &mCellsW;
1389 } else { 1394 } else {
1390 cells = &mCells; 1395 cells = &mCells;
1391 } 1396 }
1392#if 1 1397#if 1
1393 int i; 1398 int i;
1394 int timeSpan = (*cells).size()-1; 1399 int timeSpan = (*cells).size()-1;
1395 if ( KOPrefs::instance()->mMonthViewWeek ) 1400 if ( KOPrefs::instance()->mMonthViewWeek )
1396 timeSpan = 6; 1401 timeSpan = 6;
1397 for( i = 0; i < timeSpan + 1; ++i ) { 1402 for( i = 0; i < timeSpan + 1; ++i ) {
1398 (*cells)[i]->startUpdateCell(); 1403 (*cells)[i]->startUpdateCell();
1399 } 1404 }
1400 1405
1401 QPtrList<Event> events = calendar()->events(); 1406 QPtrList<Event> events = calendar()->events();
1402 Event *event; 1407 Event *event;
1403 QDateTime dt; 1408 QDateTime dt;
1404 bool ok; 1409 bool ok;
1405 QDate endDate = mStartDate.addDays( timeSpan ); 1410 QDate endDate = mStartDate.addDays( timeSpan );
1406 for( event = events.first(); event; event = events.next() ) { // for event 1411 for( event = events.first(); event; event = events.next() ) { // for event
1407 if ( event->doesRecur() ) { 1412 if ( event->doesRecur() ) {
1408 bool last; 1413 bool last;
1409 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last ); 1414 QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
1410 QDateTime incidenceEnd; 1415 QDateTime incidenceEnd;
1411 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() ); 1416 int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
1412 bool invalid = false; 1417 bool invalid = false;
1413 while( true ) { 1418 while( true ) {
1414 if ( incidenceStart.isValid() ) { 1419 if ( incidenceStart.isValid() ) {
1415 incidenceEnd = incidenceStart.addDays( eventlen ); 1420 incidenceEnd = incidenceStart.addDays( eventlen );
1416 int st = incidenceStart.date().daysTo( endDate ); 1421 int st = incidenceStart.date().daysTo( endDate );
1417 if ( st >= 0 ) { // start before timeend 1422 if ( st >= 0 ) { // start before timeend
1418 int end = mStartDate.daysTo( incidenceEnd.date() ); 1423 int end = mStartDate.daysTo( incidenceEnd.date() );
1419 if ( end >= 0 ) { // end after timestart --- got one! 1424 if ( end >= 0 ) { // end after timestart --- got one!
1420 //normalize 1425 //normalize
1421 st = timeSpan - st; 1426 st = timeSpan - st;
1422 if ( st < 0 ) st = 0; 1427 if ( st < 0 ) st = 0;
1423 if ( end > timeSpan ) end = timeSpan; 1428 if ( end > timeSpan ) end = timeSpan;
1424 int iii; 1429 int iii;
1425 //qDebug("found %s %d %d ",event->summary().latin1(), st, end ); 1430 //qDebug("found %s %d %d ",event->summary().latin1(), st, end );
1426 for ( iii = st;iii<= end;++iii) 1431 for ( iii = st;iii<= end;++iii)
1427 (*cells)[iii]->insertEvent( event ); 1432 (*cells)[iii]->insertEvent( event );
1428 } 1433 }
1429 } 1434 }
1430 } else { 1435 } else {
1431 if ( invalid ) 1436 if ( invalid )
1432 break; 1437 break;
1433 invalid = true; 1438 invalid = true;
1434 //qDebug("invalid %s", event->summary().latin1()); 1439 //qDebug("invalid %s", event->summary().latin1());
1435 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );; 1440 incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
1436 } 1441 }
1437 if ( last ) 1442 if ( last )
1438 break; 1443 break;
1439 bool ok; 1444 bool ok;
1440 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok ); 1445 incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
1441 if ( ! ok ) 1446 if ( ! ok )
1442 break; 1447 break;
1443 if ( incidenceStart.date() > endDate ) 1448 if ( incidenceStart.date() > endDate )
1444 break; 1449 break;
1445 } 1450 }
1446 } else { // no recur 1451 } else { // no recur
1447 int st = event->dtStart().date().daysTo( endDate ); 1452 int st = event->dtStart().date().daysTo( endDate );
1448 if ( st >= 0 ) { // start before timeend 1453 if ( st >= 0 ) { // start before timeend
1449 int end = mStartDate.daysTo( event->dtEnd().date() ); 1454 int end = mStartDate.daysTo( event->dtEnd().date() );
1450 if ( end >= 0 ) { // end after timestart --- got one! 1455 if ( end >= 0 ) { // end after timestart --- got one!
1451 //normalize 1456 //normalize
1452 st = timeSpan - st; 1457 st = timeSpan - st;
1453 if ( st < 0 ) st = 0; 1458 if ( st < 0 ) st = 0;
1454 if ( end > timeSpan ) end = timeSpan; 1459 if ( end > timeSpan ) end = timeSpan;
1455 int iii; 1460 int iii;
1456 for ( iii = st;iii<= end;++iii) 1461 for ( iii = st;iii<= end;++iii)
1457 (*cells)[iii]->insertEvent( event ); 1462 (*cells)[iii]->insertEvent( event );
1458 } 1463 }
1459 } 1464 }
1460 } 1465 }
1461 } 1466 }
1462 // insert due todos 1467 // insert due todos
1463 QPtrList<Todo> todos = calendar()->todos( ); 1468 QPtrList<Todo> todos = calendar()->todos( );
1464 Todo *todo; 1469 Todo *todo;
1465 for(todo = todos.first(); todo; todo = todos.next()) { 1470 for(todo = todos.first(); todo; todo = todos.next()) {
1466 //insertTodo( todo ); 1471 //insertTodo( todo );
1467 if ( todo->hasDueDate() ) { 1472 if ( todo->hasDueDate() ) {
1468 int day = mStartDate.daysTo( todo->dtDue().date() ); 1473 int day = mStartDate.daysTo( todo->dtDue().date() );
1469 if ( day >= 0 && day < timeSpan + 1) { 1474 if ( day >= 0 && day < timeSpan + 1) {
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index e008625..ccc4b01 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -171,218 +171,232 @@ void KOTodoListView::contentsDropEvent(QDropEvent *e)
171 internalDrop = true; 171 internalDrop = true;
172 if ( destinationEvent ) 172 if ( destinationEvent )
173 reparentTodoSignal( destinationEvent, existingTodo ); 173 reparentTodoSignal( destinationEvent, existingTodo );
174 else 174 else
175 unparentTodoSignal(existingTodo); 175 unparentTodoSignal(existingTodo);
176 delete todo; 176 delete todo;
177 } else { 177 } else {
178 mCalendar->addTodo(todo); 178 mCalendar->addTodo(todo);
179 emit todoDropped(todo, KOGlobals::EVENTADDED); 179 emit todoDropped(todo, KOGlobals::EVENTADDED);
180 if ( destinationEvent ) 180 if ( destinationEvent )
181 reparentTodoSignal( destinationEvent, todo ); 181 reparentTodoSignal( destinationEvent, todo );
182 } 182 }
183 } 183 }
184 else { 184 else {
185 QString text; 185 QString text;
186 if (QTextDrag::decode(e,text)) { 186 if (QTextDrag::decode(e,text)) {
187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) ); 187 //QListViewItem *qlvi = itemAt( contentsToViewport(e->pos()) );
188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) )); 188 KOTodoViewItem *todoi = static_cast<KOTodoViewItem *>(itemAt( contentsToViewport(e->pos()) ));
189 qDebug("Dropped : " + text); 189 qDebug("Dropped : " + text);
190 QStringList emails = QStringList::split(",",text); 190 QStringList emails = QStringList::split(",",text);
191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) { 191 for(QStringList::ConstIterator it = emails.begin();it!=emails.end();++it) {
192 int pos = (*it).find("<"); 192 int pos = (*it).find("<");
193 QString name = (*it).left(pos); 193 QString name = (*it).left(pos);
194 QString email = (*it).mid(pos); 194 QString email = (*it).mid(pos);
195 if (!email.isEmpty() && todoi) { 195 if (!email.isEmpty() && todoi) {
196 todoi->todo()->addAttendee(new Attendee(name,email)); 196 todoi->todo()->addAttendee(new Attendee(name,email));
197 } 197 }
198 } 198 }
199 } 199 }
200 else { 200 else {
201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable "); 201 qDebug("KOTodoListView::contentsDropEvent(): Todo from drop not decodable ");
202 e->ignore(); 202 e->ignore();
203 } 203 }
204 } 204 }
205#endif 205#endif
206} 206}
207 207
208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e) 208void KOTodoListView::contentsMousePressEvent(QMouseEvent* e)
209{ 209{
210#ifndef KORG_NODND 210#ifndef KORG_NODND
211 QPoint p(contentsToViewport(e->pos())); 211 QPoint p(contentsToViewport(e->pos()));
212 QListViewItem *i = itemAt(p); 212 QListViewItem *i = itemAt(p);
213 mMousePressed = false; 213 mMousePressed = false;
214 if (i) { 214 if (i) {
215 // if the user clicked into the root decoration of the item, don't 215 // if the user clicked into the root decoration of the item, don't
216 // try to start a drag! 216 // try to start a drag!
217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) + 217 if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + 218 treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) +
219 itemMargin() || 219 itemMargin() ||
220 p.x() < header()->sectionPos(header()->mapToIndex(0))) { 220 p.x() < header()->sectionPos(header()->mapToIndex(0))) {
221 if (e->button()==Qt::LeftButton) { 221 if (e->button()==Qt::LeftButton) {
222 mPressPos = e->pos(); 222 mPressPos = e->pos();
223 mMousePressed = true; 223 mMousePressed = true;
224 } 224 }
225 } 225 }
226 } 226 }
227#endif 227#endif
228 QListView::contentsMousePressEvent(e); 228 QListView::contentsMousePressEvent(e);
229} 229}
230void KOTodoListView::paintEvent(QPaintEvent* e) 230void KOTodoListView::paintEvent(QPaintEvent* e)
231{ 231{
232 emit paintNeeded(); 232 emit paintNeeded();
233 QListView::paintEvent( e); 233 QListView::paintEvent( e);
234} 234}
235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e) 235void KOTodoListView::contentsMouseMoveEvent(QMouseEvent* e)
236{ 236{
237 237
238#ifndef KORG_NODND 238#ifndef KORG_NODND
239 //QListView::contentsMouseMoveEvent(e); 239 //QListView::contentsMouseMoveEvent(e);
240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() > 240 if (mMousePressed && (mPressPos - e->pos()).manhattanLength() >
241 QApplication::startDragDistance()*3) { 241 QApplication::startDragDistance()*3) {
242 mMousePressed = false; 242 mMousePressed = false;
243 QListViewItem *item = itemAt(contentsToViewport(mPressPos)); 243 QListViewItem *item = itemAt(contentsToViewport(mPressPos));
244 if (item) { 244 if (item) {
245 DndFactory factory( mCalendar ); 245 DndFactory factory( mCalendar );
246 ICalDrag *vd = factory.createDrag( 246 ICalDrag *vd = factory.createDrag(
247 ((KOTodoViewItem *)item)->todo(),viewport()); 247 ((KOTodoViewItem *)item)->todo(),viewport());
248 internalDrop = false; 248 internalDrop = false;
249 // we cannot do any senseful here, because the DnD is still broken in Qt 249 // we cannot do any senseful here, because the DnD is still broken in Qt
250 if (vd->drag()) { 250 if (vd->drag()) {
251 if ( !internalDrop ) { 251 if ( !internalDrop ) {
252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() ); 252 //emit deleteTodo( ((KOTodoViewItem *)item)->todo() );
253 qDebug("Dnd: External move: Delete drag source "); 253 qDebug("Dnd: External move: Delete drag source ");
254 } else 254 } else
255 qDebug("Dnd: Internal move "); 255 qDebug("Dnd: Internal move ");
256 256
257 } else { 257 } else {
258 if ( !internalDrop ) { 258 if ( !internalDrop ) {
259 qDebug("Dnd: External Copy"); 259 qDebug("Dnd: External Copy");
260 } else 260 } else
261 qDebug("DnD: Internal copy: Copy pending"); 261 qDebug("DnD: Internal copy: Copy pending");
262 } 262 }
263 } 263 }
264 } 264 }
265#endif 265#endif
266} 266}
267void KOTodoListView::keyReleaseEvent ( QKeyEvent *e )
268{
269 if ( !e->isAutoRepeat() ) {
270 mFlagKeyPressed = false;
271 }
272}
273
274
267void KOTodoListView::keyPressEvent ( QKeyEvent * e ) 275void KOTodoListView::keyPressEvent ( QKeyEvent * e )
268{ 276{
269 277 qApp->processEvents();
278 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
279 e->ignore();
280 // qDebug(" ignore %d",e->isAutoRepeat() );
281 return;
282 }
283 if (! e->isAutoRepeat() )
284 mFlagKeyPressed = true;
270 QListViewItem* cn; 285 QListViewItem* cn;
271 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) { 286 if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) {
272 cn = currentItem(); 287 cn = currentItem();
273 if ( cn ) { 288 if ( cn ) {
274 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 289 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
275 if ( ci ){ 290 if ( ci ){
276 if ( e->state() == ShiftButton ) 291 if ( e->state() == ShiftButton )
277 ci->setOn( false ); 292 ci->setOn( false );
278 else 293 else
279 ci->setOn( true ); 294 ci->setOn( true );
280 cn = cn->itemBelow(); 295 cn = cn->itemBelow();
281 if ( cn ) { 296 if ( cn ) {
282 setCurrentItem ( cn ); 297 setCurrentItem ( cn );
283 ensureItemVisible ( cn ); 298 ensureItemVisible ( cn );
284 } 299 }
285 300
286 } 301 }
287 } 302 }
288 303
289 return; 304 return;
290 } 305 }
291 306
292 // qDebug("KOTodoListView::keyPressEvent ");
293 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) { 307 if ( e->state() == Qt::ControlButton || e->state() == Qt::ShiftButton || mName != "todolistsmall" ) {
294 switch ( e->key() ) { 308 switch ( e->key() ) {
295 case Qt::Key_Down: 309 case Qt::Key_Down:
296 case Qt::Key_Up: 310 case Qt::Key_Up:
297 QListView::keyPressEvent ( e ); 311 QListView::keyPressEvent ( e );
298 break; 312 break;
299 case Qt::Key_Left: 313 case Qt::Key_Left:
300 case Qt::Key_Right: 314 case Qt::Key_Right:
301 QListView::keyPressEvent ( e ); 315 QListView::keyPressEvent ( e );
302 e->accept(); 316 e->accept();
303 return; 317 return;
304 break; 318 break;
305 default: 319 default:
306 e->ignore(); 320 e->ignore();
307 break; 321 break;
308 } 322 }
309 return; 323 return;
310 } 324 }
311 e->ignore(); 325 e->ignore();
312} 326}
313void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e) 327void KOTodoListView::contentsMouseReleaseEvent(QMouseEvent *e)
314{ 328{
315 QListView::contentsMouseReleaseEvent(e); 329 QListView::contentsMouseReleaseEvent(e);
316 mMousePressed = false; 330 mMousePressed = false;
317} 331}
318 332
319void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e) 333void KOTodoListView::contentsMouseDoubleClickEvent(QMouseEvent *e)
320{ 334{
321 if (!e) return; 335 if (!e) return;
322 336
323 QPoint vp = contentsToViewport(e->pos()); 337 QPoint vp = contentsToViewport(e->pos());
324 338
325 QListViewItem *item = itemAt(vp); 339 QListViewItem *item = itemAt(vp);
326 340
327 emit double_Clicked(item); 341 emit double_Clicked(item);
328 if (!item) return; 342 if (!item) return;
329 343
330 emit doubleClicked(item,vp,0); 344 emit doubleClicked(item,vp,0);
331} 345}
332 346
333///////////////////////////////////////////////////////////////////////////// 347/////////////////////////////////////////////////////////////////////////////
334 348
335KOQuickTodo::KOQuickTodo(QWidget *parent) : 349KOQuickTodo::KOQuickTodo(QWidget *parent) :
336 QLineEdit(parent) 350 QLineEdit(parent)
337{ 351{
338 setText(i18n("Click to add a new Todo")); 352 setText(i18n("Click to add a new Todo"));
339} 353}
340 354
341void KOQuickTodo::focusInEvent(QFocusEvent *ev) 355void KOQuickTodo::focusInEvent(QFocusEvent *ev)
342{ 356{
343 if ( text()==i18n("Click to add a new Todo") ) 357 if ( text()==i18n("Click to add a new Todo") )
344 setText(""); 358 setText("");
345 QLineEdit::focusInEvent(ev); 359 QLineEdit::focusInEvent(ev);
346} 360}
347 361
348void KOQuickTodo::focusOutEvent(QFocusEvent *ev) 362void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
349{ 363{
350 setText(i18n("Click to add a new Todo")); 364 setText(i18n("Click to add a new Todo"));
351 QLineEdit::focusOutEvent(ev); 365 QLineEdit::focusOutEvent(ev);
352} 366}
353 367
354///////////////////////////////////////////////////////////////////////////// 368/////////////////////////////////////////////////////////////////////////////
355 369
356KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) : 370KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
357 KOrg::BaseView(calendar,parent,name) 371 KOrg::BaseView(calendar,parent,name)
358{ 372{
359 mPendingUpdateBeforeRepaint = false; 373 mPendingUpdateBeforeRepaint = false;
360 isFlatDisplay = false; 374 isFlatDisplay = false;
361 mNavigator = 0; 375 mNavigator = 0;
362 QBoxLayout *topLayout = new QVBoxLayout(this); 376 QBoxLayout *topLayout = new QVBoxLayout(this);
363 mName = QString ( name ); 377 mName = QString ( name );
364 mBlockUpdate = false; 378 mBlockUpdate = false;
365 mQuickAdd = new KOQuickTodo(this); 379 mQuickAdd = new KOQuickTodo(this);
366 topLayout->addWidget(mQuickAdd); 380 topLayout->addWidget(mQuickAdd);
367 381
368 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide(); 382 if ( !KOPrefs::instance()->mEnableQuickTodo ) mQuickAdd->hide();
369 383
370 mTodoListView = new KOTodoListView(calendar,this, name ); 384 mTodoListView = new KOTodoListView(calendar,this, name );
371 topLayout->addWidget(mTodoListView); 385 topLayout->addWidget(mTodoListView);
372 //mTodoListView->header()->setMaximumHeight(30); 386 //mTodoListView->header()->setMaximumHeight(30);
373 mTodoListView->setRootIsDecorated(true); 387 mTodoListView->setRootIsDecorated(true);
374 mTodoListView->setAllColumnsShowFocus(true); 388 mTodoListView->setAllColumnsShowFocus(true);
375 389
376 mTodoListView->setShowSortIndicator(true); 390 mTodoListView->setShowSortIndicator(true);
377 391
378 mTodoListView->addColumn(i18n("Todo")); 392 mTodoListView->addColumn(i18n("Todo"));
379 mTodoListView->addColumn(i18n("Prio")); 393 mTodoListView->addColumn(i18n("Prio"));
380 mTodoListView->setColumnAlignment(1,AlignHCenter); 394 mTodoListView->setColumnAlignment(1,AlignHCenter);
381 mTodoListView->addColumn(i18n("Complete")); 395 mTodoListView->addColumn(i18n("Complete"));
382 mTodoListView->setColumnAlignment(2,AlignCenter); 396 mTodoListView->setColumnAlignment(2,AlignCenter);
383 397
384 mTodoListView->addColumn(i18n("Due Date")); 398 mTodoListView->addColumn(i18n("Due Date"));
385 mTodoListView->setColumnAlignment(3,AlignLeft); 399 mTodoListView->setColumnAlignment(3,AlignLeft);
386 mTodoListView->addColumn(i18n("Due Time")); 400 mTodoListView->addColumn(i18n("Due Time"));
387 mTodoListView->setColumnAlignment(4,AlignHCenter); 401 mTodoListView->setColumnAlignment(4,AlignHCenter);
388 402
@@ -505,306 +519,344 @@ KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
505 // Double clicking conflicts with opening/closing the subtree 519 // Double clicking conflicts with opening/closing the subtree
506 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ), 520 connect( mTodoListView, SIGNAL( doubleClicked( QListViewItem *) ),
507 SLOT( editItem( QListViewItem *) ) ); 521 SLOT( editItem( QListViewItem *) ) );
508 /* 522 /*
509 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *, 523 connect( mTodoListView, SIGNAL( rightButtonClicked ( QListViewItem *,
510 const QPoint &,int ) ), 524 const QPoint &,int ) ),
511 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 525 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
512 */ 526 */
513 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *, 527 connect( mTodoListView, SIGNAL( contextRequest ( QListViewItem *,
514 const QPoint &,int ) ), 528 const QPoint &,int ) ),
515 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) ); 529 SLOT( popupMenu( QListViewItem *, const QPoint & ,int) ) );
516 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ), 530 connect( mTodoListView, SIGNAL( clicked( QListViewItem * ) ),
517 SLOT( itemClicked( QListViewItem * ) ) ); 531 SLOT( itemClicked( QListViewItem * ) ) );
518 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ), 532 connect( mTodoListView, SIGNAL( double_Clicked( QListViewItem * ) ),
519 SLOT( itemDoubleClicked( QListViewItem * ) ) ); 533 SLOT( itemDoubleClicked( QListViewItem * ) ) );
520 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 534 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
521 SLOT( updateView() ) ); 535 SLOT( updateView() ) );
522 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ), 536 connect( mTodoListView, SIGNAL( todoDropped( Todo *, int ) ),
523 SLOT( todoModified(Todo *, int) ) ); 537 SLOT( todoModified(Todo *, int) ) );
524 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ), 538 connect( mTodoListView, SIGNAL( expanded( QListViewItem * ) ),
525 SLOT( itemStateChanged( QListViewItem * ) ) ); 539 SLOT( itemStateChanged( QListViewItem * ) ) );
526 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ), 540 connect( mTodoListView, SIGNAL( collapsed( QListViewItem * ) ),
527 SLOT( itemStateChanged( QListViewItem * ) ) ); 541 SLOT( itemStateChanged( QListViewItem * ) ) );
528 connect( mTodoListView, SIGNAL( paintNeeded() ), 542 connect( mTodoListView, SIGNAL( paintNeeded() ),
529 SLOT( paintNeeded()) ); 543 SLOT( paintNeeded()) );
530 544
531#if 0 545#if 0
532 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)), 546 connect(mTodoListView,SIGNAL(selectionChanged(QListViewItem *)),
533 SLOT(selectionChanged(QListViewItem *))); 547 SLOT(selectionChanged(QListViewItem *)));
534 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)), 548 connect(mTodoListView,SIGNAL(clicked(QListViewItem *)),
535 SLOT(selectionChanged(QListViewItem *))); 549 SLOT(selectionChanged(QListViewItem *)));
536 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)), 550 connect(mTodoListView,SIGNAL(pressed(QListViewItem *)),
537 SLOT(selectionChanged(QListViewItem *))); 551 SLOT(selectionChanged(QListViewItem *)));
538#endif 552#endif
539 553
540 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) )); 554 connect( mTodoListView, SIGNAL(reparentTodoSignal( Todo *,Todo * ) ), SIGNAL(reparentTodoSignal( Todo *,Todo * ) ));
541 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) )); 555 connect( mTodoListView, SIGNAL(unparentTodoSignal(Todo *) ), SIGNAL(unparentTodoSignal(Todo *) ));
542 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) )); 556 connect( mTodoListView, SIGNAL( deleteTodo(Todo *) ), SIGNAL(deleteTodoSignal(Todo *) ));
543 557
544 connect( mTodoListView, SIGNAL(selectionChanged() ), 558 connect( mTodoListView, SIGNAL(selectionChanged() ),
545 SLOT( processSelectionChange() ) ); 559 SLOT( processSelectionChange() ) );
546 connect( mQuickAdd, SIGNAL( returnPressed () ), 560 connect( mQuickAdd, SIGNAL( returnPressed () ),
547 SLOT( addQuickTodo() ) ); 561 SLOT( addQuickTodo() ) );
548 562
549} 563}
550 564
551KOTodoView::~KOTodoView() 565KOTodoView::~KOTodoView()
552{ 566{
553 // delete mKOTodoViewWhatsThis; 567 // delete mKOTodoViewWhatsThis;
554 delete mDocPrefs; 568 delete mDocPrefs;
555} 569}
556QString KOTodoView::getWhatsThisText(QPoint p) 570QString KOTodoView::getWhatsThisText(QPoint p)
557{ 571{
558 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p ); 572 KOTodoViewItem* item = ( KOTodoViewItem* ) mTodoListView->itemAt( p );
559 if ( item ) 573 if ( item )
560 return KIncidenceFormatter::instance()->getFormattedText( item->todo(), 574 return KIncidenceFormatter::instance()->getFormattedText( item->todo(),
561 KOPrefs::instance()->mWTshowDetails, 575 KOPrefs::instance()->mWTshowDetails,
562 KOPrefs::instance()->mWTshowCreated, 576 KOPrefs::instance()->mWTshowCreated,
563 KOPrefs::instance()->mWTshowChanged); 577 KOPrefs::instance()->mWTshowChanged);
564 return i18n("That is the todo view" ); 578 return i18n("That is the todo view" );
565 579
566} 580}
567 581
568void KOTodoView::jumpToDate () 582void KOTodoView::jumpToDate ()
569{ 583{
570 // if (mActiveItem) { 584 // if (mActiveItem) {
571// mActiveItem->todo()); 585// mActiveItem->todo());
572// if ( mActiveItem->todo()->hasDueDate() ) 586// if ( mActiveItem->todo()->hasDueDate() )
573// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() ); 587// emit mActiveItem->todo()jumpToTime( mTodo->dtDue().date() );
574} 588}
575void KOTodoView::paintNeeded() 589void KOTodoView::paintNeeded()
576{ 590{
577 if ( mPendingUpdateBeforeRepaint ) { 591 if ( mPendingUpdateBeforeRepaint ) {
578 updateView(); 592 updateView();
579 mPendingUpdateBeforeRepaint = false; 593 mPendingUpdateBeforeRepaint = false;
580 } 594 }
581} 595}
582void KOTodoView::paintEvent(QPaintEvent * pevent) 596void KOTodoView::paintEvent(QPaintEvent * pevent)
583{ 597{
584 if ( mPendingUpdateBeforeRepaint ) { 598 if ( mPendingUpdateBeforeRepaint ) {
585 updateView(); 599 updateView();
586 mPendingUpdateBeforeRepaint = false; 600 mPendingUpdateBeforeRepaint = false;
587 } 601 }
588 KOrg::BaseView::paintEvent( pevent); 602 KOrg::BaseView::paintEvent( pevent);
589} 603}
590 604
591void KOTodoView::updateView() 605void KOTodoView::updateView()
592{ 606{
593 pendingSubtodo = 0; 607 pendingSubtodo = 0;
594 if ( mBlockUpdate ) { 608 if ( mBlockUpdate ) {
595 return; 609 return;
596 } 610 }
597 if ( !isVisible() ) { 611 if ( !isVisible() ) {
598 mPendingUpdateBeforeRepaint = true; 612 mPendingUpdateBeforeRepaint = true;
599 return; 613 return;
600 } 614 }
615 storeCurrentItem();
601 //qDebug("KOTodoView::updateView() %x", this); 616 //qDebug("KOTodoView::updateView() %x", this);
602 if ( isFlatDisplay ) { 617 if ( isFlatDisplay ) {
603 displayAllFlat(); 618 displayAllFlat();
619 resetCurrentItem();
604 return; 620 return;
605 } 621 }
606 //qDebug("update "); 622 //qDebug("update ");
607// kdDebug() << "KOTodoView::updateView()" << endl; 623// kdDebug() << "KOTodoView::updateView()" << endl;
608 QFont fo = KOPrefs::instance()->mTodoViewFont; 624 QFont fo = KOPrefs::instance()->mTodoViewFont;
609 Incidence* oldInc = 0; 625
610 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
611 if (mActiveItem)
612 oldInc = mActiveItem->todo();
613 626
614 mTodoListView->clear(); 627 mTodoListView->clear();
615 if ( mName == "todolistsmall" ) { 628 if ( mName == "todolistsmall" ) {
616 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { 629 if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
617 int ps = fo.pointSize() -2; 630 int ps = fo.pointSize() -2;
618 if ( ps > 12 ) 631 if ( ps > 12 )
619 ps -= 2; 632 ps -= 2;
620 fo.setPointSize( ps ); 633 fo.setPointSize( ps );
621 } 634 }
622 } 635 }
623 636
624 mTodoListView->setFont( fo ); 637 mTodoListView->setFont( fo );
625 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); 638 // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont );
626 //mTodoListView->header()->setMaximumHeight(fm.height()); 639 //mTodoListView->header()->setMaximumHeight(fm.height());
627 QPtrList<Todo> todoList = calendar()->todos(); 640 QPtrList<Todo> todoList = calendar()->todos();
628 641
629/* 642/*
630 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl; 643 kdDebug() << "KOTodoView::updateView(): Todo List:" << endl;
631 Event *t; 644 Event *t;
632 for(t = todoList.first(); t; t = todoList.next()) { 645 for(t = todoList.first(); t; t = todoList.next()) {
633 kdDebug() << " " << t->getSummary() << endl; 646 kdDebug() << " " << t->getSummary() << endl;
634 647
635 if (t->getRelatedTo()) { 648 if (t->getRelatedTo()) {
636 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl; 649 kdDebug() << " (related to " << t->getRelatedTo()->getSummary() << ")" << endl;
637 } 650 }
638 651
639 QPtrList<Event> l = t->getRelations(); 652 QPtrList<Event> l = t->getRelations();
640 Event *c; 653 Event *c;
641 for(c=l.first();c;c=l.next()) { 654 for(c=l.first();c;c=l.next()) {
642 kdDebug() << " - relation: " << c->getSummary() << endl; 655 kdDebug() << " - relation: " << c->getSummary() << endl;
643 } 656 }
644 } 657 }
645*/ 658*/
646 659
647 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a 660 // Put for each Event a KOTodoViewItem in the list view. Don't rely on a
648 // specific order of events. That means that we have to generate parent items 661 // specific order of events. That means that we have to generate parent items
649 // recursively for proper hierarchical display of Todos. 662 // recursively for proper hierarchical display of Todos.
650 mTodoMap.clear(); 663 mTodoMap.clear();
651 Todo *todo; 664 Todo *todo;
652 todo = todoList.first();// todo; todo = todoList.next()) { 665 todo = todoList.first();// todo; todo = todoList.next()) {
653 while ( todo ) { 666 while ( todo ) {
654 bool next = true; 667 bool next = true;
655 // qDebug("todo %s ", todo->summary().latin1()); 668 // qDebug("todo %s ", todo->summary().latin1());
656 Incidence *incidence = todo->relatedTo(); 669 Incidence *incidence = todo->relatedTo();
657 while ( incidence ) { 670 while ( incidence ) {
658 if ( incidence->type() == "Todo") { 671 if ( incidence->type() == "Todo") {
659 //qDebug("related %s ",incidence->summary().latin1() ); 672 //qDebug("related %s ",incidence->summary().latin1() );
660 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) { 673 if ( !(todoList.contains ( ((Todo* )incidence ) ) )) {
661 //qDebug("related not found "); 674 //qDebug("related not found ");
662 todoList.remove( ); 675 todoList.remove( );
663 todo = todoList.current(); 676 todo = todoList.current();
664 next = false; 677 next = false;
665 incidence = 0; 678 incidence = 0;
666 679
667 } else { 680 } else {
668 //qDebug("related found "); 681 //qDebug("related found ");
669 incidence = incidence->relatedTo(); 682 incidence = incidence->relatedTo();
670 } 683 }
671 } else 684 } else
672 incidence = 0; 685 incidence = 0;
673 } 686 }
674 if ( next ) 687 if ( next )
675 todo = todoList.next(); 688 todo = todoList.next();
676 } 689 }
677// qDebug("again .... "); 690// qDebug("again .... ");
678// for(todo = todoList.first(); todo; todo = todoList.next()) { 691// for(todo = todoList.first(); todo; todo = todoList.next()) {
679 692
680// qDebug("yytodo %s ", todo->summary().latin1()); 693// qDebug("yytodo %s ", todo->summary().latin1());
681// } 694// }
682 //qDebug("for "); 695 //qDebug("for ");
683 for(todo = todoList.first(); todo; todo = todoList.next()) { 696 for(todo = todoList.first(); todo; todo = todoList.next()) {
684 if (!mTodoMap.contains(todo) && checkTodo( todo ) ) 697 if (!mTodoMap.contains(todo) && checkTodo( todo ) )
685 { 698 {
686 insertTodoItem(todo); 699 insertTodoItem(todo);
687 } 700 }
688 } 701 }
689 //qDebug("for end "); 702 //qDebug("for end ");
690 // Restore opened/closed state 703 // Restore opened/closed state
691 mTodoListView->blockSignals( true ); 704 mTodoListView->blockSignals( true );
692 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); 705 if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
693 mTodoListView->blockSignals( false ); 706 mTodoListView->blockSignals( false );
694 mTodoListView->setFocus(); 707 resetCurrentItem();
695 if ( mTodoListView->firstChild () ) {
696 if ( oldInc ) {
697 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
698 while ( item ) {
699 if ( item->todo() == oldInc ) {
700 mTodoListView->setCurrentItem( item );
701 mTodoListView->ensureItemVisible( item );
702 break;
703 }
704 item = (KOTodoViewItem*)item->itemBelow();
705 }
706 if ( ! item )
707 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
708 } else {
709 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
710 }
711 }
712 processSelectionChange(); 708 processSelectionChange();
713} 709}
714 710
711void KOTodoView::storeCurrentItem()
712{
713 mCurItem = 0;
714 mCurItemRootParent = 0;
715 mCurItemAbove = 0;
716 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
717 if (mActiveItem) {
718 mCurItem = mActiveItem->todo();
719 KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
720 if ( activeItemAbove )
721 mCurItemAbove = activeItemAbove->todo();
722 while ( mActiveItem->parent() != 0 )
723 mActiveItem = (KOTodoViewItem*)mActiveItem->parent();
724 mCurItemRootParent = mActiveItem->todo();
725 }
726 mActiveItem = 0;
727}
728
729void KOTodoView::resetCurrentItem()
730{
731 mTodoListView->setFocus();
732 KOTodoViewItem* foundItem = 0;
733 KOTodoViewItem* foundItemRoot = 0;
734 KOTodoViewItem* foundItemAbove = 0;
735 if ( mTodoListView->firstChild () ) {
736 if ( mCurItem ) {
737 KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
738 while ( item ) {
739 if ( item->todo() == mCurItem ) {
740 foundItem = item;
741 break;
742 } else if ( item->todo() == mCurItemAbove ) {
743 foundItemAbove = item;
744
745 } else if ( item->todo() == mCurItemRootParent ) {
746 foundItemRoot = item;
747 }
748 item = (KOTodoViewItem*)item->itemBelow();
749 }
750 if ( ! foundItem ) {
751 if ( foundItemAbove )
752 foundItem = foundItemAbove;
753 else
754 foundItem = foundItemRoot;
755 }
756 }
757 if ( foundItem ) {
758 mTodoListView->setCurrentItem( foundItem );
759 mTodoListView->ensureItemVisible( foundItem );
760 } else {
761 mTodoListView->setCurrentItem( mTodoListView->firstChild () );
762 }
763 }
764 mTodoListView->setFocus();
765}
766//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
715bool KOTodoView::checkTodo( Todo * todo ) 767bool KOTodoView::checkTodo( Todo * todo )
716{ 768{
717 769
718 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) 770 if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
719 return false; 771 return false;
720 if ( !todo->isCompleted() ) { 772 if ( !todo->isCompleted() ) {
721 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() ) 773 if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
722 return true; 774 return true;
723 } 775 }
724 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) { 776 if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
725 if ( todo->hasStartDate() ) 777 if ( todo->hasStartDate() )
726 if ( mNavigator->selectedDates().last() < todo->dtStart().date() ) 778 if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
727 return false; 779 return false;
728 if ( todo->hasDueDate() ) 780 if ( todo->hasDueDate() )
729 if ( mNavigator->selectedDates().first() > todo->dtDue().date() ) 781 if ( mNavigator->selectedDates().first() > todo->dtDue().date() )
730 return false; 782 return false;
731 } 783 }
732 return true; 784 return true;
733} 785}
734 786
735void KOTodoView::restoreItemState( QListViewItem *item ) 787void KOTodoView::restoreItemState( QListViewItem *item )
736{ 788{
737 pendingSubtodo = 0; 789 pendingSubtodo = 0;
738 while( item ) { 790 while( item ) {
739 KOTodoViewItem *todoItem = (KOTodoViewItem *)item; 791 KOTodoViewItem *todoItem = (KOTodoViewItem *)item;
740 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) ); 792 todoItem->setOpen( mDocPrefs->readBoolEntry( todoItem->todo()->uid() ) );
741 if( item->childCount() > 0 ) restoreItemState( item->firstChild() ); 793 if( item->childCount() > 0 ) restoreItemState( item->firstChild() );
742 item = item->nextSibling(); 794 item = item->nextSibling();
743 } 795 }
744} 796}
745 797
746 798
747QMap<Todo *,KOTodoViewItem *>::ConstIterator 799QMap<Todo *,KOTodoViewItem *>::ConstIterator
748 KOTodoView::insertTodoItem(Todo *todo) 800 KOTodoView::insertTodoItem(Todo *todo)
749{ 801{
750 802
751// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl; 803// kdDebug() << "KOTodoView::insertTodoItem(): " << todo->getSummary() << endl;
752 // TODO: Check, if dynmaic cast is necessary 804 // TODO: Check, if dynmaic cast is necessary
753 805
754 pendingSubtodo = 0; 806 pendingSubtodo = 0;
755 Incidence *incidence = todo->relatedTo(); 807 Incidence *incidence = todo->relatedTo();
756 if (incidence && incidence->type() == "Todo") { 808 if (incidence && incidence->type() == "Todo") {
757 Todo *relatedTodo = static_cast<Todo *>(incidence); 809 Todo *relatedTodo = static_cast<Todo *>(incidence);
758 810
759// kdDebug() << " has Related" << endl; 811// kdDebug() << " has Related" << endl;
760 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 812 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
761 itemIterator = mTodoMap.find(relatedTodo); 813 itemIterator = mTodoMap.find(relatedTodo);
762 if (itemIterator == mTodoMap.end()) { 814 if (itemIterator == mTodoMap.end()) {
763// kdDebug() << " related not yet in list" << endl; 815// kdDebug() << " related not yet in list" << endl;
764 itemIterator = insertTodoItem (relatedTodo); 816 itemIterator = insertTodoItem (relatedTodo);
765 } 817 }
766 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem 818 // isn't this pretty stupid? We give one Todo to the KOTodoViewItem
767 // and one into the map. Sure finding is more easy but why? -zecke 819 // and one into the map. Sure finding is more easy but why? -zecke
768 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this); 820 KOTodoViewItem *todoItem = new KOTodoViewItem(*itemIterator,todo,this);
769 return mTodoMap.insert(todo,todoItem); 821 return mTodoMap.insert(todo,todoItem);
770 } else { 822 } else {
771// kdDebug() << " no Related" << endl; 823// kdDebug() << " no Related" << endl;
772 // see above -zecke 824 // see above -zecke
773 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 825 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
774 return mTodoMap.insert(todo,todoItem); 826 return mTodoMap.insert(todo,todoItem);
775 } 827 }
776} 828}
777 829
778 830
779void KOTodoView::updateConfig() 831void KOTodoView::updateConfig()
780{ 832{
781 updateView(); 833 updateView();
782 mTodoListView->repaintContents(); 834 mTodoListView->repaintContents();
783} 835}
784 836
785QPtrList<Incidence> KOTodoView::selectedIncidences() 837QPtrList<Incidence> KOTodoView::selectedIncidences()
786{ 838{
787 QPtrList<Incidence> selected; 839 QPtrList<Incidence> selected;
788 840
789 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 841 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
790// if (!item) item = mActiveItem; 842// if (!item) item = mActiveItem;
791 if (item) selected.append(item->todo()); 843 if (item) selected.append(item->todo());
792 844
793 return selected; 845 return selected;
794} 846}
795 847
796QPtrList<Todo> KOTodoView::selectedTodos() 848QPtrList<Todo> KOTodoView::selectedTodos()
797{ 849{
798 QPtrList<Todo> selected; 850 QPtrList<Todo> selected;
799 851
800 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem()); 852 KOTodoViewItem *item = (KOTodoViewItem *)(mTodoListView->selectedItem());
801// if (!item) item = mActiveItem; 853// if (!item) item = mActiveItem;
802 if (item) selected.append(item->todo()); 854 if (item) selected.append(item->todo());
803 855
804 return selected; 856 return selected;
805} 857}
806 858
807void KOTodoView::changeEventDisplay(Event *, int) 859void KOTodoView::changeEventDisplay(Event *, int)
808{ 860{
809 updateView(); 861 updateView();
810} 862}
@@ -1146,194 +1198,195 @@ void KOTodoView::setAllClose()
1146 } 1198 }
1147 setOpen(mTodoListView->firstChild(), false); 1199 setOpen(mTodoListView->firstChild(), false);
1148} 1200}
1149void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) 1201void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
1150{ 1202{
1151 1203
1152 while ( item ) { 1204 while ( item ) {
1153 setOpen( item->firstChild(), setOpenI ); 1205 setOpen( item->firstChild(), setOpenI );
1154 item->setOpen( setOpenI ); 1206 item->setOpen( setOpenI );
1155 item = item->nextSibling(); 1207 item = item->nextSibling();
1156 } 1208 }
1157} 1209}
1158 1210
1159void KOTodoView::displayAllFlat() 1211void KOTodoView::displayAllFlat()
1160{ 1212{
1161 pendingSubtodo = 0; 1213 pendingSubtodo = 0;
1162 if ( mBlockUpdate ) { 1214 if ( mBlockUpdate ) {
1163 return; 1215 return;
1164 } 1216 }
1165 mPopupMenu->setItemChecked( 8,true ); 1217 mPopupMenu->setItemChecked( 8,true );
1166 isFlatDisplay = true; 1218 isFlatDisplay = true;
1167 QPtrList<Todo> todoList = calendar()->todos(); 1219 QPtrList<Todo> todoList = calendar()->todos();
1168 mTodoMap.clear(); 1220 mTodoMap.clear();
1169 mTodoListView->clear(); 1221 mTodoListView->clear();
1170 Todo *todo; 1222 Todo *todo;
1171 for(todo = todoList.first(); todo; todo = todoList.next()) { 1223 for(todo = todoList.first(); todo; todo = todoList.next()) {
1172 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this); 1224 KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
1173 mTodoMap.insert(todo,todoItem); 1225 mTodoMap.insert(todo,todoItem);
1174 } 1226 }
1175 mTodoListView->setFocus(); 1227 mTodoListView->setFocus();
1176 processSelectionChange(); 1228 processSelectionChange();
1177} 1229}
1178 1230
1179void KOTodoView::setAllFlat() 1231void KOTodoView::setAllFlat()
1180{ 1232{
1181 if ( isFlatDisplay ) { 1233 if ( isFlatDisplay ) {
1182 isFlatDisplay = false; 1234 isFlatDisplay = false;
1183 mPopupMenu->setItemChecked( 8,false ); 1235 mPopupMenu->setItemChecked( 8,false );
1184 updateView(); 1236 updateView();
1185 return; 1237 return;
1186 } 1238 }
1187 displayAllFlat(); 1239 displayAllFlat();
1188} 1240}
1189 1241
1190void KOTodoView::purgeCompleted() 1242void KOTodoView::purgeCompleted()
1191{ 1243{
1192 emit purgeCompletedSignal(); 1244 emit purgeCompletedSignal();
1193} 1245}
1194void KOTodoView::toggleQuickTodo() 1246void KOTodoView::toggleQuickTodo()
1195{ 1247{
1196 if ( mQuickAdd->isVisible() ) { 1248 if ( mQuickAdd->isVisible() ) {
1197 mQuickAdd->hide(); 1249 mQuickAdd->hide();
1198 KOPrefs::instance()->mEnableQuickTodo = false; 1250 KOPrefs::instance()->mEnableQuickTodo = false;
1199 } 1251 }
1200 else { 1252 else {
1201 mQuickAdd->show(); 1253 mQuickAdd->show();
1202 KOPrefs::instance()->mEnableQuickTodo = true; 1254 KOPrefs::instance()->mEnableQuickTodo = true;
1203 } 1255 }
1204 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo); 1256 mPopupMenu->setItemChecked(4,KOPrefs::instance()->mEnableQuickTodo);
1205 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo ); 1257 mItemPopupMenu->setItemChecked( 34 , KOPrefs::instance()->mEnableQuickTodo );
1206} 1258}
1207 1259
1208void KOTodoView::toggleRunning() 1260void KOTodoView::toggleRunning()
1209{ 1261{
1210 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos; 1262 KOPrefs::instance()->mHideNonStartedTodos = !KOPrefs::instance()->mHideNonStartedTodos;
1211 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos); 1263 mPopupMenu->setItemChecked(5,KOPrefs::instance()->mHideNonStartedTodos);
1212 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos ); 1264 mItemPopupMenu->setItemChecked( 35 , KOPrefs::instance()->mHideNonStartedTodos );
1213 updateView(); 1265 updateView();
1214} 1266}
1215 1267
1216void KOTodoView::toggleCompleted() 1268void KOTodoView::toggleCompleted()
1217{ 1269{
1218 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo; 1270 KOPrefs::instance()->mShowCompletedTodo = !KOPrefs::instance()->mShowCompletedTodo;
1219 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo ); 1271 mPopupMenu->setItemChecked( 3,KOPrefs::instance()->mShowCompletedTodo );
1220 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo ); 1272 mItemPopupMenu->setItemChecked( 33 , KOPrefs::instance()->mShowCompletedTodo );
1221 updateView(); 1273 updateView();
1222} 1274}
1223 1275
1224void KOTodoView::addQuickTodo() 1276void KOTodoView::addQuickTodo()
1225{ 1277{
1226 Todo *todo = new Todo(); 1278 Todo *todo = new Todo();
1227 todo->setSummary(mQuickAdd->text()); 1279 todo->setSummary(mQuickAdd->text());
1228 todo->setOrganizer(KOPrefs::instance()->email()); 1280 todo->setOrganizer(KOPrefs::instance()->email());
1229 CalFilter * cf = mCalendar->filter(); 1281 CalFilter * cf = mCalendar->filter();
1230 if ( cf ) { 1282 if ( cf ) {
1231 if ( cf->isEnabled()&& cf->showCategories()) { 1283 if ( cf->isEnabled()&& cf->showCategories()) {
1232 todo->setCategories(cf->categoryList()); 1284 todo->setCategories(cf->categoryList());
1233 } 1285 }
1234 if ( cf->isEnabled() ) 1286 if ( cf->isEnabled() )
1235 todo->setSecrecy( cf->getSecrecy()); 1287 todo->setSecrecy( cf->getSecrecy());
1236 } 1288 }
1237 mCalendar->addTodo(todo); 1289 mCalendar->addTodo(todo);
1238 mQuickAdd->setText(""); 1290 mQuickAdd->setText("");
1239 todoModified (todo, KOGlobals::EVENTADDED ); 1291 todoModified (todo, KOGlobals::EVENTADDED );
1240 updateView(); 1292 updateView();
1241} 1293}
1294
1242void KOTodoView::keyPressEvent ( QKeyEvent * e ) 1295void KOTodoView::keyPressEvent ( QKeyEvent * e )
1243{ 1296{
1244 // e->ignore(); 1297 // e->ignore();
1245 //return; 1298 //return;
1246 //qDebug("KOTodoView::keyPressEvent "); 1299 //qDebug("KOTodoView::keyPressEvent ");
1247 switch ( e->key() ) { 1300 switch ( e->key() ) {
1248 case Qt::Key_Down: 1301 case Qt::Key_Down:
1249 case Qt::Key_Up: 1302 case Qt::Key_Up:
1250 QWidget::keyPressEvent ( e ); 1303 QWidget::keyPressEvent ( e );
1251 break; 1304 break;
1252 1305
1253 case Qt::Key_Q: 1306 case Qt::Key_Q:
1254 toggleQuickTodo(); 1307 toggleQuickTodo();
1255 break; 1308 break;
1256 case Qt::Key_U: 1309 case Qt::Key_U:
1257 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1310 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1258 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1311 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1259 unparentTodo(); 1312 unparentTodo();
1260 e->accept(); 1313 e->accept();
1261 } else 1314 } else
1262 e->ignore(); 1315 e->ignore();
1263 break; 1316 break;
1264 case Qt::Key_S: 1317 case Qt::Key_S:
1265 if ( e->state() == Qt::ControlButton ) { 1318 if ( e->state() == Qt::ControlButton ) {
1266 e->ignore(); 1319 e->ignore();
1267 break; 1320 break;
1268 } 1321 }
1269 if ( e->state() == Qt::ShiftButton ) { 1322 if ( e->state() == Qt::ShiftButton ) {
1270 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1323 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1271 reparentTodo(); 1324 reparentTodo();
1272 e->accept(); 1325 e->accept();
1273 } else 1326 } else
1274 e->ignore(); 1327 e->ignore();
1275 break; 1328 break;
1276 case Qt::Key_P: 1329 case Qt::Key_P:
1277 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { 1330 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) {
1278 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); 1331 mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
1279 if ( pendingSubtodo ) 1332 if ( pendingSubtodo )
1280 itemClicked(mActiveItem); 1333 itemClicked(mActiveItem);
1281 e->accept(); 1334 e->accept();
1282 } else 1335 } else
1283 e->ignore(); 1336 e->ignore();
1284 break; 1337 break;
1285 case Qt::Key_Escape: 1338 case Qt::Key_Escape:
1286 if ( pendingSubtodo ) { 1339 if ( pendingSubtodo ) {
1287 itemClicked(0); 1340 itemClicked(0);
1288 e->accept(); 1341 e->accept();
1289 } else 1342 } else
1290 e->ignore(); 1343 e->ignore();
1291 break; 1344 break;
1292 default: 1345 default:
1293 e->ignore(); 1346 e->ignore();
1294 } 1347 }
1295 1348
1296 if ( true ) { 1349 if ( true ) {
1297 if ( e->key() == Qt::Key_I ) { 1350 if ( e->key() == Qt::Key_I ) {
1298 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem(); 1351 KOTodoViewItem*cn = (KOTodoViewItem*)mTodoListView->currentItem();
1299 if ( cn ) { 1352 if ( cn ) {
1300 mActiveItem = cn; 1353 mActiveItem = cn;
1301 KOTodoViewItem* ci = (KOTodoViewItem*)( cn ); 1354 KOTodoViewItem* ci = (KOTodoViewItem*)( cn );
1302 if ( ci ){ 1355 if ( ci ){
1303 showTodo(); 1356 showTodo();
1304 cn = (KOTodoViewItem*)cn->itemBelow(); 1357 cn = (KOTodoViewItem*)cn->itemBelow();
1305 if ( cn ) { 1358 if ( cn ) {
1306 mTodoListView->setCurrentItem ( cn ); 1359 mTodoListView->setCurrentItem ( cn );
1307 mTodoListView->ensureItemVisible ( cn ); 1360 mTodoListView->ensureItemVisible ( cn );
1308 } 1361 }
1309 1362
1310 } 1363 }
1311 } 1364 }
1312 e->accept(); 1365 e->accept();
1313 1366
1314 } 1367 }
1315 1368
1316 } 1369 }
1317 1370
1318} 1371}
1319void KOTodoView::updateTodo( Todo * t, int type ) 1372void KOTodoView::updateTodo( Todo * t, int type )
1320{ 1373{
1321 if ( mBlockUpdate) 1374 if ( mBlockUpdate)
1322 return; 1375 return;
1323 1376
1324 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; 1377 QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator;
1325 itemIterator = mTodoMap.find(t); 1378 itemIterator = mTodoMap.find(t);
1326 if (itemIterator != mTodoMap.end()) { 1379 if (itemIterator != mTodoMap.end()) {
1327 (*itemIterator)->construct(); 1380 (*itemIterator)->construct();
1328 } else { 1381 } else {
1329 if ( type == KOGlobals::EVENTADDED ) { 1382 if ( type == KOGlobals::EVENTADDED ) {
1330 insertTodoItem( t ); 1383 insertTodoItem( t );
1331 } 1384 }
1332 } 1385 }
1333 1386
1334} 1387}
1335 1388
1336void KOTodoView::todoModified(Todo * t , int p ) 1389void KOTodoView::todoModified(Todo * t , int p )
1337{ 1390{
1338 mBlockUpdate = true; 1391 mBlockUpdate = true;
1339 emit todoModifiedSignal ( t, p ); 1392 emit todoModifiedSignal ( t, p );
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index eab0754..e553d0e 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -1,257 +1,262 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000, 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23#ifndef KOTODOVIEW_H 23#ifndef KOTODOVIEW_H
24#define KOTODOVIEW_H 24#define KOTODOVIEW_H
25 25
26#include <qfont.h> 26#include <qfont.h>
27#include <qfontmetrics.h> 27#include <qfontmetrics.h>
28#include <qlineedit.h> 28#include <qlineedit.h>
29#include <qptrlist.h> 29#include <qptrlist.h>
30#include <qstrlist.h> 30#include <qstrlist.h>
31#include <qlistbox.h> 31#include <qlistbox.h>
32#include <qpopupmenu.h> 32#include <qpopupmenu.h>
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qmap.h> 34#include <qmap.h>
35#include <qlistview.h> 35#include <qlistview.h>
36#include <klistview.h> 36#include <klistview.h>
37 37
38#include <libkcal/calendar.h> 38#include <libkcal/calendar.h>
39#include <libkcal/todo.h> 39#include <libkcal/todo.h>
40 40
41#include <korganizer/baseview.h> 41#include <korganizer/baseview.h>
42 42
43#include "kotodoviewitem.h" 43#include "kotodoviewitem.h"
44#include "koprefs.h" 44#include "koprefs.h"
45#include "koglobals.h" 45#include "koglobals.h"
46#include "datenavigator.h" 46#include "datenavigator.h"
47 47
48class QDragEnterEvent; 48class QDragEnterEvent;
49class QDragMoveEvent; 49class QDragMoveEvent;
50class QDragLeaveEvent; 50class QDragLeaveEvent;
51class QDropEvent; 51class QDropEvent;
52class KOTodoViewWhatsThis; 52class KOTodoViewWhatsThis;
53 53
54class DocPrefs; 54class DocPrefs;
55 55
56class KOTodoListView : public KListView 56class KOTodoListView : public KListView
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 public: 59 public:
60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0); 60 KOTodoListView(Calendar *,QWidget *parent=0,const char *name=0);
61 virtual ~KOTodoListView() {} 61 virtual ~KOTodoListView() {}
62 62
63 signals: 63 signals:
64 void paintNeeded(); 64 void paintNeeded();
65 void todoDropped(Todo *, int); 65 void todoDropped(Todo *, int);
66 void double_Clicked(QListViewItem *item); 66 void double_Clicked(QListViewItem *item);
67 void reparentTodoSignal( Todo *,Todo * ); 67 void reparentTodoSignal( Todo *,Todo * );
68 void unparentTodoSignal(Todo *); 68 void unparentTodoSignal(Todo *);
69 void deleteTodo( Todo * ); 69 void deleteTodo( Todo * );
70 protected: 70 protected:
71 void contentsDragEnterEvent(QDragEnterEvent *); 71 void contentsDragEnterEvent(QDragEnterEvent *);
72 void contentsDragMoveEvent(QDragMoveEvent *); 72 void contentsDragMoveEvent(QDragMoveEvent *);
73 void contentsDragLeaveEvent(QDragLeaveEvent *); 73 void contentsDragLeaveEvent(QDragLeaveEvent *);
74 void contentsDropEvent(QDropEvent *); 74 void contentsDropEvent(QDropEvent *);
75 75
76 void contentsMousePressEvent(QMouseEvent *); 76 void contentsMousePressEvent(QMouseEvent *);
77 void contentsMouseMoveEvent(QMouseEvent *); 77 void contentsMouseMoveEvent(QMouseEvent *);
78 void contentsMouseReleaseEvent(QMouseEvent *); 78 void contentsMouseReleaseEvent(QMouseEvent *);
79 void contentsMouseDoubleClickEvent(QMouseEvent *); 79 void contentsMouseDoubleClickEvent(QMouseEvent *);
80 80
81 private: 81 private:
82 void paintEvent(QPaintEvent * pevent); 82 void paintEvent(QPaintEvent * pevent);
83 bool internalDrop; 83 bool internalDrop;
84 QString mName; 84 QString mName;
85 Calendar *mCalendar; 85 Calendar *mCalendar;
86 QPoint mPressPos; 86 QPoint mPressPos;
87 bool mMousePressed; 87 bool mMousePressed;
88 QListViewItem *mOldCurrent; 88 QListViewItem *mOldCurrent;
89 bool mFlagKeyPressed;
89 void keyPressEvent ( QKeyEvent * ) ; 90 void keyPressEvent ( QKeyEvent * ) ;
91 void keyReleaseEvent ( QKeyEvent * ) ;
90}; 92};
91 93
92 94
93/** 95/**
94 This is the line-edit on top of the todoview for fast addition of new todos 96 This is the line-edit on top of the todoview for fast addition of new todos
95*/ 97*/
96class KOQuickTodo : public QLineEdit 98class KOQuickTodo : public QLineEdit
97{ 99{
98 public: 100 public:
99 KOQuickTodo(QWidget *parent=0); 101 KOQuickTodo(QWidget *parent=0);
100 protected: 102 protected:
101 void focusInEvent(QFocusEvent *ev); 103 void focusInEvent(QFocusEvent *ev);
102 void focusOutEvent(QFocusEvent *ev); 104 void focusOutEvent(QFocusEvent *ev);
103}; 105};
104 106
105 107
106/** 108/**
107 This class provides a multi-column list view of todo events. 109 This class provides a multi-column list view of todo events.
108 110
109 @short multi-column list view of todo events. 111 @short multi-column list view of todo events.
110 @author Cornelius Schumacher <schumacher@kde.org> 112 @author Cornelius Schumacher <schumacher@kde.org>
111*/ 113*/
112class KOTodoView : public KOrg::BaseView 114class KOTodoView : public KOrg::BaseView
113{ 115{
114 Q_OBJECT 116 Q_OBJECT
115 public: 117 public:
116 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 ); 118 KOTodoView(Calendar *, QWidget* parent=0, const char* name=0 );
117 ~KOTodoView(); 119 ~KOTodoView();
118 120
119 QPtrList<Incidence> selectedIncidences(); 121 QPtrList<Incidence> selectedIncidences();
120 QPtrList<Todo> selectedTodos(); 122 QPtrList<Todo> selectedTodos();
121 123
122 DateList selectedDates() 124 DateList selectedDates()
123 {DateList q; 125 {DateList q;
124 return q;} 126 return q;}
125 127
126 /** Return number of shown dates. TodoView does not show dates, */ 128 /** Return number of shown dates. TodoView does not show dates, */
127 int currentDateCount() { return 0; } 129 int currentDateCount() { return 0; }
128 130
129 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); 131 void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td);
130 132
131 void setDocumentId( const QString & ); 133 void setDocumentId( const QString & );
132 134
133 void saveLayout(KConfig *config, const QString &group) const; 135 void saveLayout(KConfig *config, const QString &group) const;
134 void restoreLayout(KConfig *config, const QString &group); 136 void restoreLayout(KConfig *config, const QString &group);
135 /** Create a popup menu to set categories */ 137 /** Create a popup menu to set categories */
136 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem); 138 QPopupMenu *getCategoryPopupMenu (KOTodoViewItem *todoItem);
137 void setNavigator( DateNavigator* nav ) {mNavigator = nav;} 139 void setNavigator( DateNavigator* nav ) {mNavigator = nav;}
138 QString getWhatsThisText(QPoint p); 140 QString getWhatsThisText(QPoint p);
139 141
140 public slots: 142 public slots:
141 void updateView(); 143 void updateView();
142 void updateConfig(); 144 void updateConfig();
143 145
144 void changeEventDisplay(Event *, int); 146 void changeEventDisplay(Event *, int);
145 147
146 void showDates(const QDate &start, const QDate &end); 148 void showDates(const QDate &start, const QDate &end);
147 void showEvents(QPtrList<Event> eventList); 149 void showEvents(QPtrList<Event> eventList);
148 150
149 void clearSelection(); 151 void clearSelection();
150 void jumpToDate (); 152 void jumpToDate ();
151 153
152 void editItem(QListViewItem *item); 154 void editItem(QListViewItem *item);
153 void showItem(QListViewItem *item,const QPoint &,int); 155 void showItem(QListViewItem *item,const QPoint &,int);
154 void popupMenu(QListViewItem *item,const QPoint &,int); 156 void popupMenu(QListViewItem *item,const QPoint &,int);
155 void newTodo(); 157 void newTodo();
156 void newSubTodo(); 158 void newSubTodo();
157 void unparentTodo(); 159 void unparentTodo();
158 void reparentTodo(); 160 void reparentTodo();
159 void showTodo(); 161 void showTodo();
160 void editTodo(); 162 void editTodo();
161 void cloneTodo(); 163 void cloneTodo();
162 void cancelTodo(); 164 void cancelTodo();
163 void moveTodo(); 165 void moveTodo();
164 void beamTodo(); 166 void beamTodo();
165 void deleteTodo(); 167 void deleteTodo();
166 168
167 void setNewPriority(int); 169 void setNewPriority(int);
168 void setNewPercentage(int); 170 void setNewPercentage(int);
169 void changedCategories(int); 171 void changedCategories(int);
170 172
171 void setAllOpen(); 173 void setAllOpen();
172 void setAllClose(); 174 void setAllClose();
173 void setAllFlat(); 175 void setAllFlat();
174 void displayAllFlat(); 176 void displayAllFlat();
175 177
176 void purgeCompleted(); 178 void purgeCompleted();
177 void toggleCompleted(); 179 void toggleCompleted();
178 void toggleRunning(); 180 void toggleRunning();
179 void toggleQuickTodo(); 181 void toggleQuickTodo();
180 void updateTodo( Todo *, int ); 182 void updateTodo( Todo *, int );
181 183
182 void itemClicked(QListViewItem *); 184 void itemClicked(QListViewItem *);
183 void itemStateChanged(QListViewItem *); 185 void itemStateChanged(QListViewItem *);
184 void modified(bool); 186 void modified(bool);
185 void itemDoubleClicked(QListViewItem *item); 187 void itemDoubleClicked(QListViewItem *item);
186 188
187 signals: 189 signals:
188 void newTodoSignal(); 190 void newTodoSignal();
189 void newSubTodoSignal(Todo *); 191 void newSubTodoSignal(Todo *);
190 void unparentTodoSignal(Todo *); 192 void unparentTodoSignal(Todo *);
191 void reparentTodoSignal( Todo *,Todo * ); 193 void reparentTodoSignal( Todo *,Todo * );
192 void showTodoSignal(Todo *); 194 void showTodoSignal(Todo *);
193 195
194 void editTodoSignal(Todo *); 196 void editTodoSignal(Todo *);
195 void deleteTodoSignal(Todo *); 197 void deleteTodoSignal(Todo *);
196 void todoModifiedSignal (Todo *, int); 198 void todoModifiedSignal (Todo *, int);
197 199
198 void isModified(bool); 200 void isModified(bool);
199 void cloneTodoSignal( Incidence * ); 201 void cloneTodoSignal( Incidence * );
200 void cancelTodoSignal( Incidence * ); 202 void cancelTodoSignal( Incidence * );
201 void moveTodoSignal( Incidence * ); 203 void moveTodoSignal( Incidence * );
202 void beamTodoSignal( Incidence * ); 204 void beamTodoSignal( Incidence * );
203 void purgeCompletedSignal(); 205 void purgeCompletedSignal();
204 206
205 protected slots: 207 protected slots:
206 void paintNeeded(); 208 void paintNeeded();
207 void processSelectionChange(); 209 void processSelectionChange();
208 void addQuickTodo(); 210 void addQuickTodo();
209 void setTodoModified( Todo* ); 211 void setTodoModified( Todo* );
210 void todoModified(Todo *, int ); 212 void todoModified(Todo *, int );
211 213
212 private: 214 private:
213 /* 215 /*
214 * the TodoEditor approach is rather unscaling in the long 216 * the TodoEditor approach is rather unscaling in the long
215 * run. 217 * run.
216 * Korganizer keeps it in memory and we need to update 218 * Korganizer keeps it in memory and we need to update
217 * 1. make KOTodoViewItem a QObject again? 219 * 1. make KOTodoViewItem a QObject again?
218 * 2. add a public method for setting one todo modified? 220 * 2. add a public method for setting one todo modified?
219 * 3. add a private method for setting a todo modified + friend here? 221 * 3. add a private method for setting a todo modified + friend here?
220 * -- zecke 2002-07-08 222 * -- zecke 2002-07-08
221 */ 223 */
222 KOTodoViewWhatsThis* mKOTodoViewWhatsThis; 224 KOTodoViewWhatsThis* mKOTodoViewWhatsThis;
223 friend class KOTodoListView; 225 friend class KOTodoListView;
224 void paintEvent(QPaintEvent * pevent); 226 void paintEvent(QPaintEvent * pevent);
225 bool mPendingUpdateBeforeRepaint; 227 bool mPendingUpdateBeforeRepaint;
226 friend class KOTodoViewItem; 228 friend class KOTodoViewItem;
227 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo); 229 QMap<Todo *,KOTodoViewItem *>::ConstIterator insertTodoItem(Todo *todo);
228 void restoreItemState( QListViewItem * ); 230 void restoreItemState( QListViewItem * );
229 231
230 bool checkTodo( Todo * ); 232 bool checkTodo( Todo * );
231 bool isFlatDisplay; 233 bool isFlatDisplay;
232 void setOpen( QListViewItem*, bool setOpen); 234 void setOpen( QListViewItem*, bool setOpen);
233 KOTodoListView *mTodoListView; 235 KOTodoListView *mTodoListView;
234 QPopupMenu *mItemPopupMenu; 236 QPopupMenu *mItemPopupMenu;
235 QPopupMenu *mPopupMenu; 237 QPopupMenu *mPopupMenu;
236 QPopupMenu *mPriorityPopupMenu; 238 QPopupMenu *mPriorityPopupMenu;
237 QPopupMenu *mPercentageCompletedPopupMenu; 239 QPopupMenu *mPercentageCompletedPopupMenu;
238 QPopupMenu *mCategoryPopupMenu; 240 QPopupMenu *mCategoryPopupMenu;
239 241
240 QMap<int, int> mPercentage; 242 QMap<int, int> mPercentage;
241 QMap<int, int> mPriority; 243 QMap<int, int> mPriority;
242 QMap<int, QString> mCategory; 244 QMap<int, QString> mCategory;
243 KOTodoViewItem *mActiveItem; 245 KOTodoViewItem *mActiveItem;
244 246
245 QMap<Todo *,KOTodoViewItem *> mTodoMap; 247 QMap<Todo *,KOTodoViewItem *> mTodoMap;
246 QString mName; 248 QString mName;
247 249
248 DocPrefs *mDocPrefs; 250 DocPrefs *mDocPrefs;
249 QString mCurrentDoc; 251 QString mCurrentDoc;
250 KOQuickTodo *mQuickAdd; 252 KOQuickTodo *mQuickAdd;
251 bool mBlockUpdate; 253 bool mBlockUpdate;
252 void keyPressEvent ( QKeyEvent * ) ; 254 void keyPressEvent ( QKeyEvent * ) ;
253 KOTodoViewItem * pendingSubtodo; 255 KOTodoViewItem * pendingSubtodo;
254 DateNavigator* mNavigator; 256 DateNavigator* mNavigator;
257 void storeCurrentItem();
258 void resetCurrentItem();
259 Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
255}; 260};
256 261
257#endif 262#endif
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index f97aa98..c442d0b 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -45,193 +45,193 @@
45#include "kotimespanview.h" 45#include "kotimespanview.h"
46#include "koprefs.h" 46#include "koprefs.h"
47#include "navigatorbar.h" 47#include "navigatorbar.h"
48#include "kdatenavigator.h" 48#include "kdatenavigator.h"
49 49
50#include "koviewmanager.h" 50#include "koviewmanager.h"
51//extern bool externFlagMonthviewBlockPainting; 51//extern bool externFlagMonthviewBlockPainting;
52 52
53//bool globalFlagBlockPainting = false; 53//bool globalFlagBlockPainting = false;
54int globalFlagBlockAgenda = 0; 54int globalFlagBlockAgenda = 0;
55int globalFlagBlockLabel = 0; 55int globalFlagBlockLabel = 0;
56int globalFlagBlockAgendaItemPaint = 1; 56int globalFlagBlockAgendaItemPaint = 1;
57int globalFlagBlockAgendaItemUpdate = 1; 57int globalFlagBlockAgendaItemUpdate = 1;
58 58
59 59
60KOViewManager::KOViewManager( CalendarView *mainView ) : 60KOViewManager::KOViewManager( CalendarView *mainView ) :
61 QObject(), mMainView( mainView ) 61 QObject(), mMainView( mainView )
62{ 62{
63 mCurrentView = 0; 63 mCurrentView = 0;
64 flagResetViewChangeDate = 0; 64 flagResetViewChangeDate = 0;
65 mWhatsNextView = 0; 65 mWhatsNextView = 0;
66 mTodoView = 0; 66 mTodoView = 0;
67 mAgendaView = 0; 67 mAgendaView = 0;
68 mMonthView = 0; 68 mMonthView = 0;
69 mListView = 0; 69 mListView = 0;
70 mJournalView = 0; 70 mJournalView = 0;
71 mTimeSpanView = 0; 71 mTimeSpanView = 0;
72 mCurrentAgendaView = 0 ; 72 mCurrentAgendaView = 0 ;
73 mFlagShowNextxDays = false; 73 mFlagShowNextxDays = false;
74} 74}
75 75
76KOViewManager::~KOViewManager() 76KOViewManager::~KOViewManager()
77{ 77{
78} 78}
79 79
80 80
81KOrg::BaseView *KOViewManager::currentView() 81KOrg::BaseView *KOViewManager::currentView()
82{ 82{
83 return mCurrentView; 83 return mCurrentView;
84} 84}
85 85
86void KOViewManager::readSettings(KConfig *config) 86void KOViewManager::readSettings(KConfig *config)
87{ 87{
88 config->setGroup("General"); 88 config->setGroup("General");
89 QString view = config->readEntry("Current View"); 89 QString view = config->readEntry("Current View");
90 if (view == "WhatsNext") showWhatsNextView(); 90 if (view == "WhatsNext") showWhatsNextView();
91 else if (view == "Month") { 91 else if (view == "Month") {
92 if ( !KOPrefs::instance()->mMonthViewWeek ) 92 if ( !KOPrefs::instance()->mMonthViewWeek )
93 showMonthView(); 93 showMonthView();
94 else 94 else
95 showMonthViewWeek(); 95 showMonthViewWeek();
96 } 96 }
97 else if (view == "List") showListView(); 97 else if (view == "List") showListView();
98 else if (view == "Journal") showJournalView(); 98 else if (view == "Journal") showJournalView();
99 else if (view == "TimeSpan") showTimeSpanView(); 99 else if (view == "TimeSpan") showTimeSpanView();
100 else if (view == "Todo") showTodoView(); 100 else if (view == "Todo") showTodoView();
101 else { 101 else {
102 config->setGroup( "Views" ); 102 config->setGroup( "Views" );
103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 ); 103 int dateCount = config->readNumEntry( "ShownDatesCount", 7 );
104 mCurrentAgendaView = dateCount; 104 mCurrentAgendaView = dateCount;
105 showAgendaView(); 105 showAgendaView();
106 mCurrentAgendaView = dateCount; 106 mCurrentAgendaView = dateCount;
107#ifdef DESKTOP_VERSION 107#ifdef DESKTOP_VERSION
108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) ); 108 QTimer::singleShot( 1000, mAgendaView, SLOT ( setInitStartHour() ) );
109#endif 109#endif
110 } 110 }
111} 111}
112 112
113void KOViewManager::showDateView( int view, QDate date) 113void KOViewManager::showDateView( int view, QDate date)
114{ 114{
115 static int lastMode = 0; 115 static int lastMode = 0;
116 static int lastCount = 0; 116 static int lastCount = 0;
117 static bool lastNDMode = false; 117 static bool lastNDMode = false;
118 static QDate lastDate; 118 static QDate lastDate;
119 //qDebug("date %d %s", view, date.toString().latin1()); 119 //qDebug("date %d %s", view, date.toString().latin1());
120 120
121 if (view != 9) 121 if (view != 9)
122 lastMode = 0; 122 lastMode = 0;
123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); 123 //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays );
124 bool savemFlagShowNextxDays = mFlagShowNextxDays; 124 bool savemFlagShowNextxDays = mFlagShowNextxDays;
125 mFlagShowNextxDays = false; 125 mFlagShowNextxDays = false;
126 if ( view == 3 ) { 126 if ( view == 3 ) {
127 //mCurrentAgendaView = 1 ; 127 //mCurrentAgendaView = 1 ;
128 lastDate = mMainView->dateNavigator()->selectedDates().first(); 128 lastDate = mMainView->dateNavigator()->selectedDates().first();
129 lastCount = mMainView->dateNavigator()->selectedDates().count(); 129 lastCount = mMainView->dateNavigator()->selectedDates().count();
130 lastNDMode = savemFlagShowNextxDays; 130 lastNDMode = savemFlagShowNextxDays;
131 mMainView->dateNavigator()->selectDate( date ); 131 mMainView->dateNavigator()->selectDate( date );
132 lastMode = 1; 132 lastMode = 1;
133 mCurrentAgendaView = 1 ; 133 mCurrentAgendaView = 1 ;
134 } else if (view == 4 ) { 134 } else if (view == 4 ) {
135 mCurrentAgendaView = 7 ; 135 mCurrentAgendaView = 7 ;
136 mMainView->dateNavigator()->selectDates( date, 7 ); 136 mMainView->dateNavigator()->selectDates( date, 7 );
137 } else if (view == 5 ) { 137 } else if (view == 5 ) {
138 mCurrentAgendaView = 14 ; 138 mCurrentAgendaView = 14 ;
139 mMainView->dateNavigator()->selectDates( date, 14); 139 mMainView->dateNavigator()->selectDates( date, 14);
140 } else if (view == 6 ) { 140 } else if (view == 6 ) {
141 //mMainView->dateNavigator()->selectDates( date, 7 ); 141 resetDateSilent( date,1);
142 showMonthView(); 142 showMonthView();
143 } else if (view == 7 ) { 143 } else if (view == 7 ) {
144 mMainView->dateNavigator()->selectDate( date ); 144 mMainView->dateNavigator()->selectDate( date );
145 showJournalView(); 145 showJournalView();
146 } else if (view == 8 ) { 146 } else if (view == 8 ) {
147 globalFlagBlockAgenda = 1; 147 globalFlagBlockAgenda = 1;
148 if ( mCurrentAgendaView != 3 ) 148 if ( mCurrentAgendaView != 3 )
149 mCurrentAgendaView = -1; 149 mCurrentAgendaView = -1;
150 showAgendaView(KOPrefs::instance()->mFullViewMonth); 150 showAgendaView(KOPrefs::instance()->mFullViewMonth);
151 globalFlagBlockAgenda = 2; 151 globalFlagBlockAgenda = 2;
152 mMainView->dateNavigator()->selectDates( date , 152 mMainView->dateNavigator()->selectDates( date ,
153 KOPrefs::instance()->mNextXDays ); 153 KOPrefs::instance()->mNextXDays );
154 mFlagShowNextxDays = true; 154 mFlagShowNextxDays = true;
155 mCurrentAgendaView = 3 ; 155 mCurrentAgendaView = 3 ;
156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) 156 } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode )
157 if ( lastMode ) { 157 if ( lastMode ) {
158 mCurrentAgendaView = lastCount ; 158 mCurrentAgendaView = lastCount ;
159 mMainView->dateNavigator()->selectDates( lastDate, lastCount); 159 mMainView->dateNavigator()->selectDates( lastDate, lastCount);
160 mFlagShowNextxDays = lastNDMode; 160 mFlagShowNextxDays = lastNDMode;
161 if ( mFlagShowNextxDays ) { 161 if ( mFlagShowNextxDays ) {
162 mCurrentAgendaView = 3 ; 162 mCurrentAgendaView = 3 ;
163 } 163 }
164 } else 164 } else
165 showWeekView(); 165 showWeekView();
166 } else if (view == 10) { 166 } else if (view == 10) {
167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); 167 mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
168 } 168 }
169} 169}
170 170
171 171
172 172
173void KOViewManager::writeSettings(KConfig *config) 173void KOViewManager::writeSettings(KConfig *config)
174{ 174{
175 config->setGroup("General"); 175 config->setGroup("General");
176 176
177 QString view; 177 QString view;
178 if (mCurrentView == mWhatsNextView) view = "WhatsNext"; 178 if (mCurrentView == mWhatsNextView) view = "WhatsNext";
179 else if (mCurrentView == mMonthView) view = "Month"; 179 else if (mCurrentView == mMonthView) view = "Month";
180 else if (mCurrentView == mListView) view = "List"; 180 else if (mCurrentView == mListView) view = "List";
181 else if (mCurrentView == mJournalView) view = "Journal"; 181 else if (mCurrentView == mJournalView) view = "Journal";
182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; 182 else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
183 else if (mCurrentView == mTodoView) view = "Todo"; 183 else if (mCurrentView == mTodoView) view = "Todo";
184 else view = "Agenda"; 184 else view = "Agenda";
185 185
186 config->writeEntry("Current View",view); 186 config->writeEntry("Current View",view);
187 187
188 if (mAgendaView) { 188 if (mAgendaView) {
189 mAgendaView->writeSettings(config); 189 mAgendaView->writeSettings(config);
190 } 190 }
191 if (mTimeSpanView) { 191 if (mTimeSpanView) {
192 mTimeSpanView->writeSettings(config); 192 mTimeSpanView->writeSettings(config);
193 } 193 }
194 if (mListView) { 194 if (mListView) {
195 mListView->writeSettings(config); 195 mListView->writeSettings(config);
196 } 196 }
197 if (mTodoView) { 197 if (mTodoView) {
198 mTodoView->saveLayout(config,"Todo View"); 198 mTodoView->saveLayout(config,"Todo View");
199 } 199 }
200} 200}
201void KOViewManager::showNextView() 201void KOViewManager::showNextView()
202{ 202{
203 static int selecteddatescount = 0; 203 static int selecteddatescount = 0;
204 static QDate selecteddate = QDate ( 2000, 1, 1 ); 204 static QDate selecteddate = QDate ( 2000, 1, 1 );
205 static QDate baseCycleDate = QDate ( 2000, 1, 1 ); 205 static QDate baseCycleDate = QDate ( 2000, 1, 1 );
206 int newCount = mMainView->dateNavigator()->selectedDates().count(); 206 int newCount = mMainView->dateNavigator()->selectedDates().count();
207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) { 207 if ( selecteddatescount != newCount && flagResetViewChangeDate == 0 ) {
208 flagResetViewChangeDate = 1; 208 flagResetViewChangeDate = 1;
209 } 209 }
210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() ) 210 if ( selecteddate != mMainView->dateNavigator()->selectedDates().first() )
211 flagResetViewChangeDate = 1; 211 flagResetViewChangeDate = 1;
212 if ( flagResetViewChangeDate > 0 ) { 212 if ( flagResetViewChangeDate > 0 ) {
213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first(); 213 baseCycleDate = mMainView->dateNavigator()->selectedDates().first();
214 //qDebug("newCycle "); 214 //qDebug("newCycle ");
215 } 215 }
216 if (mCurrentView == mWhatsNextView) goto NEXT_X; 216 if (mCurrentView == mWhatsNextView) goto NEXT_X;
217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL; 217 if (mCurrentView == mAgendaView && mFlagShowNextxDays) goto JOURNAL;
218 if (mCurrentView == mJournalView ) goto DAY_1; 218 if (mCurrentView == mJournalView ) goto DAY_1;
219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5; 219 if (mCurrentView == mAgendaView && mCurrentAgendaView == 1 ) goto DAY_5;
220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7; 220 if (mCurrentView == mAgendaView && mCurrentAgendaView == 5 ) goto DAY_7;
221 if (mCurrentView == mAgendaView ) goto DAY_6; 221 if (mCurrentView == mAgendaView ) goto DAY_6;
222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH; 222 if (mCurrentView == mMonthView && KOPrefs::instance()->mMonthViewWeek) goto MONTH;
223 if (mCurrentView == mMonthView ) goto LIST; 223 if (mCurrentView == mMonthView ) goto LIST;
224 if (mCurrentView == mListView ) goto TODO; 224 if (mCurrentView == mListView ) goto TODO;
225 // if (mCurrentView == mTodoView ) goto NEXT; 225 // if (mCurrentView == mTodoView ) goto NEXT;
226 NEXT: 226 NEXT:
227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;} 227 if ( KOPrefs::instance()->mShowIconNext ) { showWhatsNextView();goto ENTE ;}
228 NEXT_X: 228 NEXT_X:
229 if ( KOPrefs::instance()->mShowIconNextDays ) { 229 if ( KOPrefs::instance()->mShowIconNextDays ) {
230 globalFlagBlockAgenda = 1; 230 globalFlagBlockAgenda = 1;
231 if ( mCurrentAgendaView != 3 ) 231 if ( mCurrentAgendaView != 3 )
232 mCurrentAgendaView = -1; 232 mCurrentAgendaView = -1;
233 showAgendaView(KOPrefs::instance()->mFullViewMonth); 233 showAgendaView(KOPrefs::instance()->mFullViewMonth);
234 globalFlagBlockAgenda = 2; 234 globalFlagBlockAgenda = 2;
235 mMainView->dateNavigator()->selectDates( baseCycleDate , 235 mMainView->dateNavigator()->selectDates( baseCycleDate ,
236 KOPrefs::instance()->mNextXDays ); 236 KOPrefs::instance()->mNextXDays );
237 mFlagShowNextxDays = true; 237 mFlagShowNextxDays = true;
@@ -296,192 +296,194 @@ void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
296 ++flagResetViewChangeDate; 296 ++flagResetViewChangeDate;
297 //mFlagShowNextxDays = false; 297 //mFlagShowNextxDays = false;
298 //if(view == mCurrentView) return; 298 //if(view == mCurrentView) return;
299 if ( view == 0 ) { 299 if ( view == 0 ) {
300 view = mCurrentView; 300 view = mCurrentView;
301 if ( view == 0 ) 301 if ( view == 0 )
302 return; 302 return;
303 } 303 }
304 bool callupdate = !(view == mCurrentView); 304 bool callupdate = !(view == mCurrentView);
305 bool full = fullScreen; 305 bool full = fullScreen;
306 if(view == mCurrentView && view != mWhatsNextView ) { 306 if(view == mCurrentView && view != mWhatsNextView ) {
307 if ( mCurrentAgendaView < 0 ) 307 if ( mCurrentAgendaView < 0 )
308 return; 308 return;
309 if ( view != mMonthView ) 309 if ( view != mMonthView )
310 full = mMainView->leftFrame()->isVisible(); 310 full = mMainView->leftFrame()->isVisible();
311 } else { 311 } else {
312 if ( view == mMonthView && mMonthView) 312 if ( view == mMonthView && mMonthView)
313 ;//mMonthView->skipResize = true ; 313 ;//mMonthView->skipResize = true ;
314 mCurrentView = view; 314 mCurrentView = view;
315 // bool full = fullScreen; 315 // bool full = fullScreen;
316 bool isFull = !mMainView->leftFrame()->isVisible(); 316 bool isFull = !mMainView->leftFrame()->isVisible();
317 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen ) 317 if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
318 full = true; 318 full = true;
319 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen ) 319 if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
320 full = false; 320 full = false;
321 } 321 }
322 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime(); 322 if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
323 //raiseCurrentView( full ); 323 //raiseCurrentView( full );
324 mMainView->processIncidenceSelection( 0 ); 324 mMainView->processIncidenceSelection( 0 );
325 //mMainView->updateView(); 325 //mMainView->updateView();
326 raiseCurrentView( full, callupdate ); 326 raiseCurrentView( full, callupdate );
327 mMainView->adaptNavigationUnits(); 327 mMainView->adaptNavigationUnits();
328} 328}
329 329
330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView ) 330void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
331{ 331{
332 mCurrentAgendaView = 0; 332 mCurrentAgendaView = 0;
333 if ( fullScreen ) { 333 if ( fullScreen ) {
334 mMainView->leftFrame()->hide(); 334 mMainView->leftFrame()->hide();
335 } else { 335 } else {
336 mMainView->leftFrame()->show(); 336 mMainView->leftFrame()->show();
337 } 337 }
338 //if ( mCurrentView == mMonthView ) qApp->processEvents(); 338 //if ( mCurrentView == mMonthView ) qApp->processEvents();
339 emit signalFullScreen( !fullScreen ); 339 emit signalFullScreen( !fullScreen );
340 if ( callUpdateView ) 340 if ( callUpdateView )
341 mMainView->updateView(); 341 mMainView->updateView();
342 342
343 if ( globalFlagBlockAgenda == 5 ) { 343 if ( globalFlagBlockAgenda == 5 ) {
344 globalFlagBlockAgenda = 4; 344 globalFlagBlockAgenda = 4;
345 globalFlagBlockAgendaItemPaint = 1; 345 globalFlagBlockAgendaItemPaint = 1;
346 } 346 }
347 mMainView->viewStack()->raiseWidget(mCurrentView); 347 mMainView->viewStack()->raiseWidget(mCurrentView);
348 if ( globalFlagBlockAgenda == 4 ) { 348 if ( globalFlagBlockAgenda == 4 ) {
349 if ( mCurrentView == mAgendaView ) { 349 if ( mCurrentView == mAgendaView ) {
350 //globalFlagBlockAgenda =1 ; 350 //globalFlagBlockAgenda =1 ;
351 if ( KOPrefs::instance()->mSetTimeToDayStartAt ) 351 if ( KOPrefs::instance()->mSetTimeToDayStartAt )
352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins ); 352 mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
353 else if ( KOPrefs::instance()->mCenterOnCurrentTime ) 353 else if ( KOPrefs::instance()->mCenterOnCurrentTime )
354 mAgendaView->setStartHour( QTime::currentTime ().hour() ); 354 mAgendaView->setStartHour( QTime::currentTime ().hour() );
355 qApp->processEvents(); 355 qApp->processEvents();
356 //qDebug("qApp->processEvents() "); 356 //qDebug("qApp->processEvents() ");
357 globalFlagBlockAgenda = 0; 357 globalFlagBlockAgenda = 0;
358 mAgendaView->repaintAgenda(); 358 mAgendaView->repaintAgenda();
359 359
360 } 360 }
361 globalFlagBlockAgenda = 0; 361 globalFlagBlockAgenda = 0;
362 } 362 }
363 emit signalAgendaView( mCurrentView == mAgendaView ); 363 emit signalAgendaView( mCurrentView == mAgendaView );
364 //qDebug("raiseCurrentView ende "); 364 //qDebug("raiseCurrentView ende ");
365 365
366} 366}
367 367
368void KOViewManager::updateView() 368void KOViewManager::updateView()
369{ 369{
370 // qDebug("KOViewManager::updateView() "); 370 // qDebug("KOViewManager::updateView() ");
371 // if we are updating mTodoView, we get endless recursion 371 // if we are updating mTodoView, we get endless recursion
372 if ( mTodoView == mCurrentView ) 372 if ( mTodoView == mCurrentView )
373 return; 373 return;
374 if ( mCurrentView ) mCurrentView->updateView(); 374 if ( mCurrentView ) mCurrentView->updateView();
375 375
376} 376}
377 377
378void KOViewManager::updateView(const QDate &start, const QDate &end) 378void KOViewManager::updateView(const QDate &start, const QDate &end)
379{ 379{
380 // kdDebug() << "KOViewManager::updateView()" << endl; 380 // kdDebug() << "KOViewManager::updateView()" << endl;
381 381
382 if (mCurrentView) mCurrentView->showDates(start, end); 382 if (mCurrentView) mCurrentView->showDates(start, end);
383 383
384 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView(); 384 if (mTodoView && mTodoView == mCurrentView ) mTodoView->updateView();
385} 385}
386 386
387 387
388void KOViewManager::updateWNview() 388void KOViewManager::updateWNview()
389{ 389{
390 if ( mCurrentView == mWhatsNextView && mWhatsNextView ) 390 if ( mCurrentView == mWhatsNextView && mWhatsNextView )
391 mWhatsNextView->updateView(); 391 mWhatsNextView->updateView();
392 if ( mCurrentView == mMonthView && mMonthView )
393 mMonthView->updateView();
392 394
393} 395}
394void KOViewManager::showWhatsNextView() 396void KOViewManager::showWhatsNextView()
395{ 397{
396 if (!mWhatsNextView) { 398 if (!mWhatsNextView) {
397 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(), 399 mWhatsNextView = new KOWhatsNextView(mMainView->calendar(),mMainView->viewStack(),
398 "KOViewManager::WhatsNextView"); 400 "KOViewManager::WhatsNextView");
399 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog()); 401 mWhatsNextView->setEventViewer( mMainView->getEventViewerDialog());
400 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig())); 402 connect(mMainView, SIGNAL(configChanged()), mWhatsNextView, SLOT(updateConfig()));
401 addView(mWhatsNextView); 403 addView(mWhatsNextView);
402 connect(this, SIGNAL( printWNV() ), 404 connect(this, SIGNAL( printWNV() ),
403 mWhatsNextView, SLOT( printMe() ) ); 405 mWhatsNextView, SLOT( printMe() ) );
404 } 406 }
405 globalFlagBlockAgenda = 1; 407 globalFlagBlockAgenda = 1;
406 showView(mWhatsNextView, true ); 408 showView(mWhatsNextView, true );
407 //mWhatsNextView->updateView(); 409 //mWhatsNextView->updateView();
408 410
409} 411}
410 412
411void KOViewManager::slotprintWNV() 413void KOViewManager::slotprintWNV()
412{ 414{
413 if (!mWhatsNextView) 415 if (!mWhatsNextView)
414 showWhatsNextView(); 416 showWhatsNextView();
415 emit printWNV(); 417 emit printWNV();
416 418
417} 419}
418void KOViewManager::showListView() 420void KOViewManager::showListView()
419{ 421{
420 if (!mListView) { 422 if (!mListView) {
421 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView"); 423 mListView = new KOListView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::ListView");
422 addView(mListView); 424 addView(mListView);
423 425
424 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)), 426 connect(mListView, SIGNAL(showIncidenceSignal(Incidence *)),
425 mMainView, SLOT(showIncidence(Incidence *))); 427 mMainView, SLOT(showIncidence(Incidence *)));
426 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)), 428 connect(mListView, SIGNAL(editIncidenceSignal(Incidence *)),
427 mMainView, SLOT(editIncidence(Incidence *))); 429 mMainView, SLOT(editIncidence(Incidence *)));
428 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)), 430 connect(mListView, SIGNAL(deleteIncidenceSignal(Incidence *)),
429 mMainView, SLOT(deleteIncidence(Incidence *))); 431 mMainView, SLOT(deleteIncidence(Incidence *)));
430 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ), 432 connect( mListView, SIGNAL( incidenceSelected( Incidence * ) ),
431 mMainView, SLOT( processMainViewSelection( Incidence * ) ) ); 433 mMainView, SLOT( processMainViewSelection( Incidence * ) ) );
432 connect( mListView, SIGNAL( signalNewEvent() ), 434 connect( mListView, SIGNAL( signalNewEvent() ),
433 mMainView, SLOT( newEvent() ) ); 435 mMainView, SLOT( newEvent() ) );
434 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig())); 436 connect(mMainView, SIGNAL(configChanged()), mListView, SLOT(updateConfig()));
435 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ), 437 connect( mListView, SIGNAL( cloneIncidenceSignal( Incidence * ) ),
436 mMainView, SLOT ( cloneIncidence( Incidence * ) ) ); 438 mMainView, SLOT ( cloneIncidence( Incidence * ) ) );
437 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ), 439 connect( mListView, SIGNAL( cancelIncidenceSignal( Incidence * ) ),
438 mMainView, SLOT ( cancelIncidence( Incidence * ) ) ); 440 mMainView, SLOT ( cancelIncidence( Incidence * ) ) );
439 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ), 441 connect( mListView, SIGNAL( moveIncidenceSignal( Incidence * ) ),
440 mMainView, SLOT ( moveIncidence( Incidence * ) ) ); 442 mMainView, SLOT ( moveIncidence( Incidence * ) ) );
441 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ), 443 connect( mListView, SIGNAL( beamIncidenceSignal( Incidence * ) ),
442 mMainView, SLOT ( beamIncidence( Incidence * ) ) ); 444 mMainView, SLOT ( beamIncidence( Incidence * ) ) );
443 } 445 }
444 // bool temp = mFlagShowNextxDays; 446 // bool temp = mFlagShowNextxDays;
445 //globalFlagBlockPainting = true; 447 //globalFlagBlockPainting = true;
446 globalFlagBlockAgenda = 1; 448 globalFlagBlockAgenda = 1;
447 if ( KOPrefs::instance()->mListViewMonthTimespan ) { 449 if ( KOPrefs::instance()->mListViewMonthTimespan ) {
448 mMainView->setBlockShowDates( true ); 450 mMainView->setBlockShowDates( true );
449 mMainView->dateNavigator()->selectMonth(); 451 mMainView->dateNavigator()->selectMonth();
450 mMainView->setBlockShowDates( false ); 452 mMainView->setBlockShowDates( false );
451 } 453 }
452 showView(mListView, KOPrefs::instance()->mFullViewTodo); 454 showView(mListView, KOPrefs::instance()->mFullViewTodo);
453 //mFlagShowNextxDays = temp; 455 //mFlagShowNextxDays = temp;
454} 456}
455 457
456void KOViewManager::showAgendaView( bool fullScreen ) 458void KOViewManager::showAgendaView( bool fullScreen )
457{ 459{
458 460
459 mMainView->dialogManager()->hideSearchDialog(); 461 mMainView->dialogManager()->hideSearchDialog();
460 // qDebug("KOViewManager::showAgendaView "); 462 // qDebug("KOViewManager::showAgendaView ");
461 bool full; 463 bool full;
462 full = fullScreen; 464 full = fullScreen;
463 if (!mAgendaView) { 465 if (!mAgendaView) {
464 full = false; 466 full = false;
465 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView"); 467 mAgendaView = new KOAgendaView(mMainView->calendar(), mMainView->viewStack(), "KOViewManager::AgendaView");
466 addView(mAgendaView); 468 addView(mAgendaView);
467#ifndef DESKTOP_VERSION 469#ifndef DESKTOP_VERSION
468 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold ); 470 QPEApplication::setStylusOperation( mAgendaView, QPEApplication::RightOnHold );
469#endif 471#endif
470 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )), 472 connect( mAgendaView, SIGNAL( incidenceChanged(Incidence *, int )),
471 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) )); 473 mMainView, SLOT( changeIncidenceDisplay( Incidence *, int ) ));
472 474
473 // SIGNALS/SLOTS FOR DAY/WEEK VIEW 475 // SIGNALS/SLOTS FOR DAY/WEEK VIEW
474 476
475 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate ))); 477 connect(mAgendaView,SIGNAL(showDateView( int, QDate )),SLOT(showDateView( int, QDate )));
476 478
477 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)), 479 connect(mAgendaView,SIGNAL(newTodoSignal(QDateTime,bool)),
478 mMainView, SLOT(newTodoDateTime(QDateTime,bool))); 480 mMainView, SLOT(newTodoDateTime(QDateTime,bool)));
479 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)), 481 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime)),
480 mMainView, SLOT(newEvent(QDateTime))); 482 mMainView, SLOT(newEvent(QDateTime)));
481 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)), 483 connect(mAgendaView,SIGNAL(newEventSignal(QDateTime,QDateTime)),
482 mMainView, SLOT(newEvent(QDateTime,QDateTime))); 484 mMainView, SLOT(newEvent(QDateTime,QDateTime)));
483 connect(mAgendaView,SIGNAL(newEventSignal(QDate)), 485 connect(mAgendaView,SIGNAL(newEventSignal(QDate)),
484 mMainView, SLOT(newEvent(QDate))); 486 mMainView, SLOT(newEvent(QDate)));
485 487
486 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)), 488 connect(mAgendaView, SIGNAL(editIncidenceSignal(Incidence *)),
487 mMainView, SLOT(editIncidence(Incidence *))); 489 mMainView, SLOT(editIncidence(Incidence *)));