summaryrefslogtreecommitdiffabout
path: root/korganizer
Unidiff
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/koagendaview.cpp45
-rw-r--r--korganizer/koagendaview.h33
2 files changed, 50 insertions, 28 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp
index d3db89a..c8cef44 100644
--- a/korganizer/koagendaview.cpp
+++ b/korganizer/koagendaview.cpp
@@ -31,96 +31,98 @@
31#endif 31#endif
32#include <qfont.h> 32#include <qfont.h>
33#include <qfontmetrics.h> 33#include <qfontmetrics.h>
34#include <qpopupmenu.h> 34#include <qpopupmenu.h>
35#include <qtooltip.h> 35#include <qtooltip.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qpushbutton.h> 37#include <qpushbutton.h>
38#include <qapplication.h> 38#include <qapplication.h>
39 39
40#include <kapplication.h> 40#include <kapplication.h>
41#include <KDGanttMinimizeSplitter.h> 41#include <KDGanttMinimizeSplitter.h>
42#include <kdebug.h> 42#include <kdebug.h>
43#include <kstandarddirs.h> 43#include <kstandarddirs.h>
44#include <kiconloader.h> 44#include <kiconloader.h>
45#include <klocale.h> 45#include <klocale.h>
46#include <kconfig.h> 46#include <kconfig.h>
47#include <kglobal.h> 47#include <kglobal.h>
48#include "calendarview.h" 48#include "calendarview.h"
49#include "koviewmanager.h" 49#include "koviewmanager.h"
50 50
51#include <libkcal/calendar.h> 51#include <libkcal/calendar.h>
52#include <libkcal/icaldrag.h> 52#include <libkcal/icaldrag.h>
53#include <libkcal/dndfactory.h> 53#include <libkcal/dndfactory.h>
54 54
55#include <kcalendarsystem.h> 55#include <kcalendarsystem.h>
56 56
57#include "koglobals.h" 57#include "koglobals.h"
58#ifndef KORG_NOPLUGINS 58#ifndef KORG_NOPLUGINS
59#include "kocore.h" 59#include "kocore.h"
60#endif 60#endif
61#include "koprefs.h" 61#include "koprefs.h"
62#include "koagenda.h" 62#include "koagenda.h"
63#include "koagendaitem.h" 63#include "koagendaitem.h"
64#ifndef KORG_NOPRINTER 64#ifndef KORG_NOPRINTER
65#include "calprinter.h" 65#include "calprinter.h"
66#endif 66#endif
67 67
68#include "koagendaview.h" 68#include "koagendaview.h"
69//#include "koagendaview.moc" 69//#include "koagendaview.moc"
70 70
71//extern bool globalFlagBlockPainting; 71//extern bool globalFlagBlockPainting;
72extern int globalFlagBlockAgenda; 72extern int globalFlagBlockAgenda;
73extern int globalFlagBlockStartup; 73extern int globalFlagBlockStartup;
74extern int globalFlagBlockAgendaItemPaint; 74extern int globalFlagBlockAgendaItemPaint;
75extern int globalFlagBlockAgendaItemUpdate; 75extern int globalFlagBlockAgendaItemUpdate;
76extern int globalFlagBlockLabel; 76extern int globalFlagBlockLabel;
77using namespace KOrg; 77using namespace KOrg;
78 78
79
80
79TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : 81TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) :
80 QScrollView(parent,name,f) 82 QScrollView(parent,name,f)
81{ 83{
82 mRows = rows; 84 mRows = rows;
83 85
84 setMinimumHeight( 20 ); 86 setMinimumHeight( 20 );
85 mCellHeight = KOPrefs::instance()->mHourSize*4; 87 mCellHeight = KOPrefs::instance()->mHourSize*4;
86 88
87 enableClipper(true); 89 enableClipper(true);
88 90
89 setHScrollBarMode(AlwaysOff); 91 setHScrollBarMode(AlwaysOff);
90 setVScrollBarMode(AlwaysOff); 92 setVScrollBarMode(AlwaysOff);
91 93
92 resizeContents(50,mRows * mCellHeight); 94 resizeContents(50,mRows * mCellHeight);
93 95
94 viewport()->setBackgroundMode( PaletteBackground ); 96 viewport()->setBackgroundMode( PaletteBackground );
95} 97}
96 98
97void TimeLabels::setCellHeight(int height) 99void TimeLabels::setCellHeight(int height)
98{ 100{
99 mCellHeight = height; 101 mCellHeight = height;
100} 102}
101 103
102/* 104/*
103 Optimization so that only the "dirty" portion of the scroll view 105 Optimization so that only the "dirty" portion of the scroll view
104 is redrawn. Unfortunately, this is not called by default paintEvent() method. 106 is redrawn. Unfortunately, this is not called by default paintEvent() method.
105*/ 107*/
106void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch) 108void TimeLabels::drawContents(QPainter *p,int cx, int cy, int cw, int ch)
107{ 109{
108 110
109 // if ( globalFlagBlockAgenda ) 111 // if ( globalFlagBlockAgenda )
110 // return; 112 // return;
111 // bug: the parameters cx, cy, cw, ch are the areas that need to be 113 // bug: the parameters cx, cy, cw, ch are the areas that need to be
112 // redrawn, not the area of the widget. unfortunately, this 114 // redrawn, not the area of the widget. unfortunately, this
113 // code assumes the latter... 115 // code assumes the latter...
114 116
115 // now, for a workaround... 117 // now, for a workaround...
116 // these two assignments fix the weird redraw bug 118 // these two assignments fix the weird redraw bug
117 cx = contentsX() + 2; 119 cx = contentsX() + 2;
118 cw = contentsWidth() - 2; 120 cw = contentsWidth() - 2;
119 // end of workaround 121 // end of workaround
120 122
121 int cell = ((int)(cy/mCellHeight)); 123 int cell = ((int)(cy/mCellHeight));
122 int y = cell * mCellHeight; 124 int y = cell * mCellHeight;
123 QFontMetrics fm = fontMetrics(); 125 QFontMetrics fm = fontMetrics();
124 QString hour; 126 QString hour;
125 QString suffix; 127 QString suffix;
126 QString fullTime; 128 QString fullTime;
@@ -564,312 +566,307 @@ void KOAgendaView::toggleAllDay()
564 if ( mSplitterAgenda->firstHandle() ) 566 if ( mSplitterAgenda->firstHandle() )
565 mSplitterAgenda->firstHandle()->toggle(); 567 mSplitterAgenda->firstHandle()->toggle();
566} 568}
567void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) 569void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld )
568{ 570{
569 calendar()->addIncidence( inc ); 571 calendar()->addIncidence( inc );
570 572
571 if ( incOld ) { 573 if ( incOld ) {
572 if ( incOld->type() == "Todo" ) 574 if ( incOld->type() == "Todo" )
573 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); 575 emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED );
574 else 576 else
575 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); 577 emit incidenceChanged(incOld, KOGlobals::EVENTEDITED);
576 } 578 }
577 579
578} 580}
579 581
580KOAgendaView::~KOAgendaView() 582KOAgendaView::~KOAgendaView()
581{ 583{
582 delete mAgendaPopup; 584 delete mAgendaPopup;
583 delete mAllDayAgendaPopup; 585 delete mAllDayAgendaPopup;
584 delete KOAgendaItem::paintPix(); 586 delete KOAgendaItem::paintPix();
585 delete KOAgendaItem::paintPixSel(); 587 delete KOAgendaItem::paintPixSel();
586} 588}
587void KOAgendaView::resizeEvent( QResizeEvent* e ) 589void KOAgendaView::resizeEvent( QResizeEvent* e )
588{ 590{
589 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); 591 //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width());
590 bool uc = false; 592 bool uc = false;
591 int ow = e->oldSize().width(); 593 int ow = e->oldSize().width();
592 int oh = e->oldSize().height(); 594 int oh = e->oldSize().height();
593 int w = e->size().width(); 595 int w = e->size().width();
594 int h = e->size().height(); 596 int h = e->size().height();
595 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { 597 if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) {
596 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) 598 if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda )
597 uc = true; 599 uc = true;
598 //qDebug("view changed %d %d %d %d ", ow, oh , w , h); 600 //qDebug("view changed %d %d %d %d ", ow, oh , w , h);
599 } 601 }
600 mUpcomingWidth = e->size().width() ; 602 mUpcomingWidth = e->size().width() ;
601 if ( mBlockUpdating || uc ) { 603 if ( mBlockUpdating || uc ) {
602 mBlockUpdating = false; 604 mBlockUpdating = false;
603 //mAgenda->setMinimumSize(800 , 600 ); 605 //mAgenda->setMinimumSize(800 , 600 );
604 //qDebug("mAgenda->resize+++++++++++++++ "); 606 //qDebug("mAgenda->resize+++++++++++++++ ");
605 updateConfig(); 607 updateConfig();
606 //qDebug("KOAgendaView::Updating now possible "); 608 //qDebug("KOAgendaView::Updating now possible ");
607 } else 609 } else
608 createDayLabels(); 610 createDayLabels();
609 //qDebug("resizeEvent end "); 611 //qDebug("resizeEvent end ");
610 612
611} 613}
612void KOAgendaView::slotDaylabelClicked() 614void KOAgendaView::slotDaylabelClicked( int num )
613{ 615{
614 QString cap = ((QPushButton*) sender() )->caption(); 616
615
616 QDate firstDate = mSelectedDates.first(); 617 QDate firstDate = mSelectedDates.first();
617 if ( cap == "0" ) 618 if ( num == -1 )
618 emit showDateView( 6, firstDate ); 619 emit showDateView( 6, firstDate );
619 else if ( cap != "last" ) { 620 else if (num >= 0 ) {
620 if ( mSelectedDates.count() == 1) 621 if ( mSelectedDates.count() == 1)
621 emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); 622 emit showDateView( 9, firstDate.addDays( num ) );
622 else 623 else
623 emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); 624 emit showDateView( 3, firstDate.addDays( num ) );
624 } 625 }
625 else 626 else
626 showDateView( 10, firstDate.addDays(1) ); 627 showDateView( 10, firstDate.addDays(1) );
627} 628}
628 629
629QPushButton* KOAgendaView::getNewDaylabel() 630KOAgendaButton* KOAgendaView::getNewDaylabel()
630{ 631{
631 632
632 QPushButton * dayLabel = new QPushButton(mDayLabels); 633 KOAgendaButton * dayLabel = new KOAgendaButton(mDayLabels);
633 dayLabel->setFlat( true ); 634 connect( dayLabel, SIGNAL( numClicked(int) ), this, SLOT ( slotDaylabelClicked(int) ) );
634 connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) );
635 dayLabel->setFocusPolicy(NoFocus);
636 dayLabel->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
637 mDayLabelsList.append( dayLabel ); 635 mDayLabelsList.append( dayLabel );
638 mLayoutDayLabels->addWidget(dayLabel); 636 mLayoutDayLabels->addWidget(dayLabel);
639 //mLayoutDayLabels->setStretchFactor(dayLabel, 100);
640 return dayLabel ; 637 return dayLabel ;
641} 638}
642 639
643void KOAgendaView::createDayLabels() 640void KOAgendaView::createDayLabels()
644{ 641{
645 642
646 if ( mBlockUpdating || globalFlagBlockLabel == 1) { 643 if ( mBlockUpdating || globalFlagBlockLabel == 1) {
647 // qDebug(" KOAgendaView::createDayLabels() blocked "); 644 // qDebug(" KOAgendaView::createDayLabels() blocked ");
648 return; 645 return;
649 646
650 } 647 }
651 int newHight; 648 int newHight;
652 649
653 // ### Before deleting and recreating we could check if mSelectedDates changed... 650 // ### Before deleting and recreating we could check if mSelectedDates changed...
654 // It would remove some flickering and gain speed (since this is called by 651 // It would remove some flickering and gain speed (since this is called by
655 // each updateView() call) 652 // each updateView() call)
656 653
657 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; 654 int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2;
658 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); 655 mDayLabelsFrame->setMaximumWidth( mUpcomingWidth );
659 if ( maxWid < 0 ) 656 if ( maxWid < 0 )
660 maxWid = 20; 657 maxWid = 20;
661 658
662 QFont dlf = KOPrefs::instance()->mTimeLabelsFont; 659 QFont dlf = KOPrefs::instance()->mTimeLabelsFont;
663 QFontMetrics fm ( dlf ); 660 QFontMetrics fm ( dlf );
664 int selCount = mSelectedDates.count(); 661 int selCount = mSelectedDates.count();
665 QString dayTest = "Won 20"; 662 QString dayTest = "Mon 20";
666 //QString dayTest = "Mon 20"; 663 //QString dayTest = "Mon 20";
667 int wid = fm.width( dayTest ); 664 int wid = fm.width( dayTest );
668 //maxWid -= ( selCount * 3 ); //working for QLabels 665 //maxWid -= ( selCount * 3 ); //working for QLabels
669 maxWid -= ( selCount * 5 ); //working for QPushButton 666 maxWid -= ( selCount * 3 ); //working for QPushButton
670 if ( maxWid < 0 ) 667 if ( maxWid < 0 )
671 maxWid = 20; 668 maxWid = 20;
672 int needWid = wid * selCount; 669 int needWid = wid * selCount;
673 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); 670 //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid );
674 //if ( needWid > maxWid ) 671 //if ( needWid > maxWid )
675 // qDebug("DAYLABELS TOOOOOOO BIG "); 672 // qDebug("DAYLABELS TOOOOOOO BIG ");
676 while ( needWid > maxWid ) { 673 while ( needWid > maxWid ) {
677 dayTest = dayTest.left( dayTest.length() - 1 ); 674 dayTest = dayTest.left( dayTest.length() - 1 );
678 wid = fm.width( dayTest )+1; 675 wid = fm.width( dayTest );
679 needWid = wid * selCount; 676 needWid = wid * selCount;
680 } 677 }
681 int maxLen = dayTest.length(); 678 int maxLen = dayTest.length();
682 int fontPoint = dlf.pointSize(); 679 int fontPoint = dlf.pointSize();
683 if ( maxLen < 2 ) { 680 if ( maxLen < 2 ) {
684 int fontPoint = dlf.pointSize(); 681 int fontPoint = dlf.pointSize();
685 while ( fontPoint > 4 ) { 682 while ( fontPoint > 4 ) {
686 --fontPoint; 683 --fontPoint;
687 dlf.setPointSize( fontPoint ); 684 dlf.setPointSize( fontPoint );
688 QFontMetrics f( dlf ); 685 QFontMetrics f( dlf );
689 wid = f.width( "30" )+3; 686 wid = f.width( "30" );
690 needWid = wid * selCount; 687 needWid = wid * selCount;
691 if ( needWid < maxWid ) 688 if ( needWid < maxWid )
692 break; 689 break;
693 } 690 }
694 maxLen = 2; 691 maxLen = 2;
695 } 692 }
696 //qDebug("Max len %d ", dayTest.length() ); 693 //qDebug("Max len %d ", dayTest.length() );
697 694
698 QFontMetrics tempF( dlf ); 695 QFontMetrics tempF( dlf );
699 newHight = tempF.height(); 696 newHight = tempF.height();
700 mDayLabels->setFont( dlf ); 697 mDayLabels->setFont( dlf );
701 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; 698 // mLayoutDayLabels = new QHBoxLayout(mDayLabels);;
702 // mLayoutDayLabels->addSpacing(mTimeLabels->width()); 699 // mLayoutDayLabels->addSpacing(mTimeLabels->width());
703 //mLayoutDayLabels->addSpacing( 2 ); 700 //mLayoutDayLabels->addSpacing( 2 );
704 // QFont lFont = dlf; 701 // QFont lFont = dlf;
705 bool appendLabels = false; 702 bool appendLabels = false;
706 QPushButton *dayLabel; 703 KOAgendaButton *dayLabel;
707 dayLabel = mDayLabelsList.first(); 704 dayLabel = mDayLabelsList.first();
708 if ( !dayLabel ) { 705 if ( !dayLabel ) {
709 appendLabels = true; 706 appendLabels = true;
710 dayLabel = getNewDaylabel(); 707 dayLabel = getNewDaylabel();
711 } 708 }
712 dayLabel->setFixedWidth( mTimeLabels->width()+2 ); 709 dayLabel->setFixedWidth( mTimeLabels->width()+2 );
713 dayLabel->setFont( dlf ); 710 dayLabel->setFont( dlf );
714 dayLabel->setCaption("0"); 711 dayLabel->setNum( -1 );
715 //dayLabel->setAlignment(QLabel::AlignHCenter); 712 //dayLabel->setAlignment(QLabel::AlignHCenter);
716 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); 713 dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) );
717 dayLabel->show(); 714 dayLabel->show();
718 DateList::ConstIterator dit; 715 DateList::ConstIterator dit;
719 bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); 716 bool oneday = (mSelectedDates.first() == mSelectedDates.last() );
720 int counter = 0; 717 int counter = -1;
721 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { 718 for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) {
722 ++counter; 719 ++counter;
723 QDate date = *dit; 720 QDate date = *dit;
724 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); 721 // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels);
725 if ( ! appendLabels ) { 722 if ( ! appendLabels ) {
726 dayLabel = mDayLabelsList.next(); 723 dayLabel = mDayLabelsList.next();
727 if ( !dayLabel ) 724 if ( !dayLabel )
728 appendLabels = true; 725 appendLabels = true;
729 } 726 }
730 if ( appendLabels ) { 727 if ( appendLabels ) {
731 dayLabel = getNewDaylabel(); 728 dayLabel = getNewDaylabel();
732 } 729 }
733 dayLabel->setMinimumWidth( 1 ); 730 dayLabel->setMinimumWidth( 1 );
734 dayLabel->setMaximumWidth( 2048 ); 731 dayLabel->setMaximumWidth( 1024 );
735 dayLabel->setFont( dlf ); 732 dayLabel->setFont( dlf );
736 dayLabel->show(); 733 dayLabel->show();
737 dayLabel->setCaption(QString::number( counter )); 734 dayLabel->setNum( counter );
738 QString str; 735 QString str;
739 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); 736 int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date);
740 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); 737 QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true );
741 switch ( maxLen ) { 738 switch ( maxLen ) {
742 case 2: 739 case 2:
743 str = QString::number( date.day() ); 740 str = QString::number( date.day() );
744 break; 741 break;
745 742
746 case 3: 743 case 3:
747 str = dayName.left( 1 ) +QString::number( date.day()); 744 str = dayName.left( 1 ) +QString::number( date.day());
748 745
749 break; 746 break;
750 case 4: 747 case 4:
751 str = dayName.left( 1 ) + " " +QString::number( date.day()); 748 str = dayName.left( 1 ) + " " +QString::number( date.day());
752 749
753 break; 750 break;
754 case 5: 751 case 5:
755 str = dayName.left( 2 ) + " " +QString::number( date.day()); 752 str = dayName.left( 2 ) + " " +QString::number( date.day());
756 753
757 break; 754 break;
758 case 6: 755 case 6:
759 str = dayName.left( 3 ) + " " +QString::number( date.day()); 756 str = dayName.left( 3 ) + " " +QString::number( date.day());
760 break; 757 break;
761 758
762 default: 759 default:
763 break; 760 break;
764 } 761 }
765 if ( oneday ) { 762 if ( oneday ) {
766 QString addString; 763 QString addString;
767 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) 764 if ( mSelectedDates.first() == QDateTime::currentDateTime().date() )
768 addString = i18n("Today"); 765 addString = i18n("Today");
769 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) 766 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) )
770 addString = i18n("Tomorrow"); 767 addString = i18n("Tomorrow");
771 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) 768 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) )
772 addString = i18n("Yesterday"); 769 addString = i18n("Yesterday");
773 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) 770 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) )
774 addString = i18n("Day before yesterday"); 771 addString = i18n("Day before yesterday");
775 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) 772 else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) )
776 addString = i18n("Day after tomorrow"); 773 addString = i18n("Day after tomorrow");
777 if ( !addString.isEmpty() ) { 774 if ( !addString.isEmpty() ) {
778 str = addString+", " + str; 775 str = addString+", " + str;
779 } 776 }
780 } 777 }
781 dayLabel->setText(str); 778 dayLabel->setText(str);
782 //dayLabel->setAlignment(QLabel::AlignHCenter); 779 //dayLabel->setAlignment(QLabel::AlignHCenter);
783 if (date == QDate::currentDate()) { 780 if (date == QDate::currentDate()) {
784 QFont bFont = dlf; 781 QFont bFont = dlf;
785 bFont.setBold( true ); 782 bFont.setBold( true );
786 dayLabel->setFont(bFont); 783 dayLabel->setFont(bFont);
787 } 784 }
788 //dayLayout->addWidget(dayLabel); 785 //dayLayout->addWidget(dayLabel);
789 786
790#ifndef KORG_NOPLUGINS 787#ifndef KORG_NOPLUGINS
791 CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); 788 CalendarDecoration::List cds = KOCore::self()->calendarDecorations();
792 CalendarDecoration *it; 789 CalendarDecoration *it;
793 for(it = cds.first(); it; it = cds.next()) { 790 for(it = cds.first(); it; it = cds.next()) {
794 QString text = it->shortText( date ); 791 QString text = it->shortText( date );
795 if ( !text.isEmpty() ) { 792 if ( !text.isEmpty() ) {
796 QLabel *label = new QLabel(text,mDayLabels); 793 QLabel *label = new QLabel(text,mDayLabels);
797 label->setAlignment(AlignCenter); 794 label->setAlignment(AlignCenter);
798 dayLayout->addWidget(label); 795 dayLayout->addWidget(label);
799 } 796 }
800 } 797 }
801 798
802 for(it = cds.first(); it; it = cds.next()) { 799 for(it = cds.first(); it; it = cds.next()) {
803 QWidget *wid = it->smallWidget(mDayLabels,date); 800 QWidget *wid = it->smallWidget(mDayLabels,date);
804 if ( wid ) { 801 if ( wid ) {
805 // wid->setHeight(20); 802 // wid->setHeight(20);
806 dayLayout->addWidget(wid); 803 dayLayout->addWidget(wid);
807 } 804 }
808 } 805 }
809#endif 806#endif
810 } 807 }
811 if ( ! appendLabels ) { 808 if ( ! appendLabels ) {
812 dayLabel = mDayLabelsList.next(); 809 dayLabel = mDayLabelsList.next();
813 if ( !dayLabel ) 810 if ( !dayLabel )
814 appendLabels = true; 811 appendLabels = true;
815 } 812 }
816 if ( appendLabels ) { 813 if ( appendLabels ) {
817 dayLabel = getNewDaylabel(); 814 dayLabel = getNewDaylabel();
818 } 815 }
819 //dayLabel->hide();//test only 816 //dayLabel->hide();//test only
820 817
821 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; 818 int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ;
822 if ( offset < 0 ) offset = 0; 819 if ( offset < 0 ) offset = 0;
823 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); 820 //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 );
824 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); 821 dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) );
825 dayLabel->setFont( dlf ); 822 dayLabel->setFont( dlf );
826 dayLabel->show(); 823 dayLabel->show();
827 dayLabel->setCaption("last"); 824 dayLabel->setNum( -2 );
828 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); 825 dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset );
829 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); 826 //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2);
830 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); 827 //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2);
831 if ( !appendLabels ) { 828 if ( !appendLabels ) {
832 dayLabel = mDayLabelsList.next(); 829 dayLabel = mDayLabelsList.next();
833 while ( dayLabel ) { 830 while ( dayLabel ) {
834 //qDebug("!dayLabel %d",dayLabel ); 831 //qDebug("!dayLabel %d",dayLabel );
835 dayLabel->hide(); 832 dayLabel->hide();
836 dayLabel = mDayLabelsList.next(); 833 dayLabel = mDayLabelsList.next();
837 } 834 }
838 } 835 }
839 //mDayLabelsFrame->show(); 836 //mDayLabelsFrame->show();
840 //mDayLabels->show(); 837 //mDayLabels->show();
841 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); 838 //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight);
842 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); 839 //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight );
843 mDayLabelsFrame->setFixedHeight( newHight ); 840 mDayLabelsFrame->setFixedHeight( newHight );
844} 841}
845 842
846int KOAgendaView::maxDatesHint() 843int KOAgendaView::maxDatesHint()
847{ 844{
848 // Not sure about the max number of events, so return 0 for now. 845 // Not sure about the max number of events, so return 0 for now.
849 return 0; 846 return 0;
850} 847}
851 848
852int KOAgendaView::currentDateCount() 849int KOAgendaView::currentDateCount()
853{ 850{
854 return mSelectedDates.count(); 851 return mSelectedDates.count();
855} 852}
856 853
857QPtrList<Incidence> KOAgendaView::selectedIncidences() 854QPtrList<Incidence> KOAgendaView::selectedIncidences()
858{ 855{
859 QPtrList<Incidence> selected; 856 QPtrList<Incidence> selected;
860 Incidence *incidence; 857 Incidence *incidence;
861 858
862 incidence = mAgenda->selectedIncidence(); 859 incidence = mAgenda->selectedIncidence();
863 if (incidence) selected.append(incidence); 860 if (incidence) selected.append(incidence);
864 861
865 incidence = mAllDayAgenda->selectedIncidence(); 862 incidence = mAllDayAgenda->selectedIncidence();
866 if (incidence) selected.append(incidence); 863 if (incidence) selected.append(incidence);
867 864
868 return selected; 865 return selected;
869} 866}
870 867
871DateList KOAgendaView::selectedDates() 868DateList KOAgendaView::selectedDates()
872{ 869{
873 DateList selected; 870 DateList selected;
874 QDate qd; 871 QDate qd;
875 872
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h
index cbe86b6..e9e85cc 100644
--- a/korganizer/koagendaview.h
+++ b/korganizer/koagendaview.h
@@ -1,95 +1,120 @@
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 KOAGENDAVIEW_H 23#ifndef KOAGENDAVIEW_H
24#define KOAGENDAVIEW_H 24#define KOAGENDAVIEW_H
25 25
26#include <qscrollview.h> 26#include <qscrollview.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qpushbutton.h>
28#include <qlayout.h> 29#include <qlayout.h>
29#ifndef DESKTOP_VERSION 30#ifndef DESKTOP_VERSION
30#include <qksplitter.h> 31#include <qksplitter.h>
31#else 32#else
32#include <qsplitter.h> 33#include <qsplitter.h>
33#endif 34#endif
34#include <qmemarray.h> 35#include <qmemarray.h>
35 36
36#include "koeventview.h" 37#include "koeventview.h"
37 38
38
39class QHBox; 39class QHBox;
40class QFrame; 40class QFrame;
41class QLabel; 41class QLabel;
42class QPushButton; 42class QPushButton;
43class CalendarView; 43class CalendarView;
44class KOAgenda; 44class KOAgenda;
45class KOAgendaItem; 45class KOAgendaItem;
46class KConfig; 46class KConfig;
47class KDGanttMinimizeSplitter; 47class KDGanttMinimizeSplitter;
48
49class KOAgendaButton : public QPushButton
50{
51 Q_OBJECT
52 public:
53 KOAgendaButton( QWidget *parent=0, const char *name=0 ) :
54 QPushButton( parent, name )
55 {
56 mNum = -3;
57 setFlat( true );
58 setFocusPolicy(NoFocus);
59 setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding ));
60 connect( this, SIGNAL( clicked() ), this, SLOT ( bClicked() ) );
61 };
62
63 QSize sizeHint () const { return QSize( 5,5) ;}
64 void setNum( int n) { mNum = n; }
65private slots:
66 void bClicked() {emit numClicked( mNum);}
67signals:
68 void numClicked( int );
69private:
70 int mNum;
71};
72
48class TimeLabels : public QScrollView { 73class TimeLabels : public QScrollView {
49 Q_OBJECT 74 Q_OBJECT
50 public: 75 public:
51 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0); 76 TimeLabels(int rows,QWidget *parent=0,const char *name=0,WFlags f=0);
52 77
53 void setCellHeight(int height); 78 void setCellHeight(int height);
54 79
55 /** Calculates the minimum width */ 80 /** Calculates the minimum width */
56 virtual int minimumWidth() const; 81 virtual int minimumWidth() const;
57 82
58 /** updates widget's internal state */ 83 /** updates widget's internal state */
59 void updateConfig(); 84 void updateConfig();
60 85
61 /** */ 86 /** */
62 void setAgenda(KOAgenda* agenda); 87 void setAgenda(KOAgenda* agenda);
63 88
64 /** */ 89 /** */
65 virtual void paintEvent(QPaintEvent* e); 90 virtual void paintEvent(QPaintEvent* e);
66 void contentsMousePressEvent ( QMouseEvent * ) ; 91 void contentsMousePressEvent ( QMouseEvent * ) ;
67 void contentsMouseReleaseEvent ( QMouseEvent * ); 92 void contentsMouseReleaseEvent ( QMouseEvent * );
68 void contentsMouseMoveEvent ( QMouseEvent * ); 93 void contentsMouseMoveEvent ( QMouseEvent * );
69 94
70 public slots: 95 public slots:
71 /** update time label positions */ 96 /** update time label positions */
72 void positionChanged(); 97 void positionChanged();
73 signals: 98 signals:
74 void scaleChanged(); 99 void scaleChanged();
75 protected: 100 protected:
76 void drawContents(QPainter *p,int cx, int cy, int cw, int ch); 101 void drawContents(QPainter *p,int cx, int cy, int cw, int ch);
77 102
78 private: 103 private:
79 int mMouseDownY; 104 int mMouseDownY;
80 QString mOrgCap; 105 QString mOrgCap;
81 int mRows; 106 int mRows;
82 int mCellHeight; 107 int mCellHeight;
83 108
84 /** */ 109 /** */
85 KOAgenda* mAgenda; 110 KOAgenda* mAgenda;
86}; 111};
87 112
88class EventIndicator : public QFrame { 113class EventIndicator : public QFrame {
89 Q_OBJECT 114 Q_OBJECT
90 public: 115 public:
91 enum Location { Top, Bottom }; 116 enum Location { Top, Bottom };
92 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0); 117 EventIndicator(Location loc=Top,QWidget *parent=0,const char *name=0);
93 virtual ~EventIndicator(); 118 virtual ~EventIndicator();
94 119
95 void changeColumns(int columns); 120 void changeColumns(int columns);
@@ -145,120 +170,120 @@ class KOAgendaView : public KOEventView {
145 /** start-datetime of selection */ 170 /** start-datetime of selection */
146 QDateTime selectionStart() {return mTimeSpanBegin;} 171 QDateTime selectionStart() {return mTimeSpanBegin;}
147 /** end-datetime of selection */ 172 /** end-datetime of selection */
148 QDateTime selectionEnd() {return mTimeSpanEnd;} 173 QDateTime selectionEnd() {return mTimeSpanEnd;}
149 /** returns true if selection is for whole day */ 174 /** returns true if selection is for whole day */
150 bool selectedIsAllDay() {return mTimeSpanInAllDay;} 175 bool selectedIsAllDay() {return mTimeSpanInAllDay;}
151 /** make selected start/end invalid */ 176 /** make selected start/end invalid */
152 void deleteSelectedDateTime(); 177 void deleteSelectedDateTime();
153 void repaintAgenda(); 178 void repaintAgenda();
154 public slots: 179 public slots:
155 virtual void updateView(); 180 virtual void updateView();
156 virtual void updateConfig(); 181 virtual void updateConfig();
157 virtual void showDates(const QDate &start, const QDate &end); 182 virtual void showDates(const QDate &start, const QDate &end);
158 virtual void showEvents(QPtrList<Event> eventList); 183 virtual void showEvents(QPtrList<Event> eventList);
159 184
160 void updateTodo( Todo *, int ); 185 void updateTodo( Todo *, int );
161 void changeEventDisplay(Event *, int); 186 void changeEventDisplay(Event *, int);
162 187
163 void clearSelection(); 188 void clearSelection();
164 189
165 void newTodo(int gx,int gy); 190 void newTodo(int gx,int gy);
166 void newEvent(int gx,int gy); 191 void newEvent(int gx,int gy);
167 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd); 192 void newEvent(int gxStart, int gyStart, int gxEnd, int gyEnd);
168 void newEventAllDay(int gx, int gy); 193 void newEventAllDay(int gx, int gy);
169 void newTodoAllDay(int gx, int gy); 194 void newTodoAllDay(int gx, int gy);
170 195
171 void startDrag(Event *); 196 void startDrag(Event *);
172 197
173 void readSettings(); 198 void readSettings();
174 void readSettings(KConfig *); 199 void readSettings(KConfig *);
175 void writeSettings(KConfig *); 200 void writeSettings(KConfig *);
176 201
177 void setContentsPos(int y); 202 void setContentsPos(int y);
178 203
179 void setExpandedButton( bool expanded ); 204 void setExpandedButton( bool expanded );
180 void scrollOneHourUp(); 205 void scrollOneHourUp();
181 void scrollOneHourDown(); 206 void scrollOneHourDown();
182 void addToCalSlot(Incidence *, Incidence *); 207 void addToCalSlot(Incidence *, Incidence *);
183 208
184 signals: 209 signals:
185 void showDateView( int, QDate ); 210 void showDateView( int, QDate );
186 void newTodoSignal( QDateTime ,bool ); 211 void newTodoSignal( QDateTime ,bool );
187 void toggleExpand(); 212 void toggleExpand();
188 void todoMoved( Todo *, int ); 213 void todoMoved( Todo *, int );
189 void incidenceChanged(Incidence * , int ); 214 void incidenceChanged(Incidence * , int );
190 // void cloneIncidenceSignal(Incidence *); 215 // void cloneIncidenceSignal(Incidence *);
191 216
192 protected: 217 protected:
193 QPushButton* getNewDaylabel(); 218 KOAgendaButton* getNewDaylabel();
194 bool mBlockUpdating; 219 bool mBlockUpdating;
195 int mUpcomingWidth; 220 int mUpcomingWidth;
196 /** Fill agenda beginning with date startDate */ 221 /** Fill agenda beginning with date startDate */
197 void fillAgenda(const QDate &startDate); 222 void fillAgenda(const QDate &startDate);
198 void resizeEvent( QResizeEvent* e ); 223 void resizeEvent( QResizeEvent* e );
199 /** Fill agenda using the current set value for the start date */ 224 /** Fill agenda using the current set value for the start date */
200 void fillAgenda(); 225 void fillAgenda();
201 226
202 /** Create labels for the selected dates. */ 227 /** Create labels for the selected dates. */
203 void createDayLabels(); 228 void createDayLabels();
204 229
205 /** 230 /**
206 Set the masks on the agenda widgets indicating, which days are holidays. 231 Set the masks on the agenda widgets indicating, which days are holidays.
207 */ 232 */
208 void setHolidayMasks(); 233 void setHolidayMasks();
209 234
210 protected slots: 235 protected slots:
211 void slotDaylabelClicked(); 236 void slotDaylabelClicked( int );
212 /** Update event belonging to agenda item */ 237 /** Update event belonging to agenda item */
213 void updateEventDates(KOAgendaItem *item, int mode = -1); 238 void updateEventDates(KOAgendaItem *item, int mode = -1);
214 //void updateMovedTodo(); 239 //void updateMovedTodo();
215 240
216 void updateEventIndicatorTop(int newY); 241 void updateEventIndicatorTop(int newY);
217 void updateEventIndicatorBottom(int newY); 242 void updateEventIndicatorBottom(int newY);
218 243
219 /** Updates data for selected timespan */ 244 /** Updates data for selected timespan */
220 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd); 245 void newTimeSpanSelected(int gxStart, int gyStart, int gxEnd, int gyEnd);
221 /** Updates data for selected timespan for all day event*/ 246 /** Updates data for selected timespan for all day event*/
222 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd); 247 void newTimeSpanSelectedAllDay(int gxStart, int gyStart, int gxEnd, int gyEnd);
223 248
224 private: 249 private:
225 // view widgets 250 // view widgets
226 QFrame *mDayLabels; 251 QFrame *mDayLabels;
227 QHBox *mDayLabelsFrame; 252 QHBox *mDayLabelsFrame;
228 QBoxLayout *mLayoutDayLabels; 253 QBoxLayout *mLayoutDayLabels;
229 QFrame *mAllDayFrame; 254 QFrame *mAllDayFrame;
230 KOAgenda *mAllDayAgenda; 255 KOAgenda *mAllDayAgenda;
231 KOAgenda *mAgenda; 256 KOAgenda *mAgenda;
232 TimeLabels *mTimeLabels; 257 TimeLabels *mTimeLabels;
233 QWidget *mDummyAllDayLeft; 258 QWidget *mDummyAllDayLeft;
234 259
235 KDGanttMinimizeSplitter* mSplitterAgenda; 260 KDGanttMinimizeSplitter* mSplitterAgenda;
236 QPushButton *mExpandButton; 261 QPushButton *mExpandButton;
237 262
238 DateList mSelectedDates; // List of dates to be displayed 263 DateList mSelectedDates; // List of dates to be displayed
239 int mViewType; 264 int mViewType;
240 265
241 bool mWeekStartsMonday; 266 bool mWeekStartsMonday;
242 int mStartHour; 267 int mStartHour;
243 268
244 KOEventPopupMenu *mAgendaPopup; 269 KOEventPopupMenu *mAgendaPopup;
245 KOEventPopupMenu *mAllDayAgendaPopup; 270 KOEventPopupMenu *mAllDayAgendaPopup;
246 271
247 EventIndicator *mEventIndicatorTop; 272 EventIndicator *mEventIndicatorTop;
248 EventIndicator *mEventIndicatorBottom; 273 EventIndicator *mEventIndicatorBottom;
249 274
250 QMemArray<int> mMinY; 275 QMemArray<int> mMinY;
251 QMemArray<int> mMaxY; 276 QMemArray<int> mMaxY;
252 277
253 QMemArray<bool> mHolidayMask; 278 QMemArray<bool> mHolidayMask;
254 279
255 QPixmap mExpandedPixmap; 280 QPixmap mExpandedPixmap;
256 QPixmap mNotExpandedPixmap; 281 QPixmap mNotExpandedPixmap;
257 QPtrList<QPushButton> mDayLabelsList; 282 QPtrList<KOAgendaButton> mDayLabelsList;
258 QDateTime mTimeSpanBegin; 283 QDateTime mTimeSpanBegin;
259 QDateTime mTimeSpanEnd; 284 QDateTime mTimeSpanEnd;
260 bool mTimeSpanInAllDay; 285 bool mTimeSpanInAllDay;
261 void keyPressEvent ( QKeyEvent * e ); 286 void keyPressEvent ( QKeyEvent * e );
262}; 287};
263 288
264#endif // KOAGENDAVIEW_H 289#endif // KOAGENDAVIEW_H