-rw-r--r-- | korganizer/koagendaview.cpp | 45 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 33 |
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 | |||
@@ -75,8 +75,10 @@ extern int globalFlagBlockAgendaItemPaint; | |||
75 | extern int globalFlagBlockAgendaItemUpdate; | 75 | extern int globalFlagBlockAgendaItemUpdate; |
76 | extern int globalFlagBlockLabel; | 76 | extern int globalFlagBlockLabel; |
77 | using namespace KOrg; | 77 | using namespace KOrg; |
78 | 78 | ||
79 | |||
80 | |||
79 | TimeLabels::TimeLabels(int rows,QWidget *parent,const char *name,WFlags f) : | 81 | TimeLabels::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; |
@@ -608,36 +610,31 @@ void KOAgendaView::resizeEvent( QResizeEvent* e ) | |||
608 | createDayLabels(); | 610 | createDayLabels(); |
609 | //qDebug("resizeEvent end "); | 611 | //qDebug("resizeEvent end "); |
610 | 612 | ||
611 | } | 613 | } |
612 | void KOAgendaView::slotDaylabelClicked() | 614 | void 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 | ||
629 | QPushButton* KOAgendaView::getNewDaylabel() | 630 | KOAgendaButton* 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 | ||
643 | void KOAgendaView::createDayLabels() | 640 | void KOAgendaView::createDayLabels() |
@@ -661,22 +658,22 @@ void KOAgendaView::createDayLabels() | |||
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(); |
@@ -685,9 +682,9 @@ void KOAgendaView::createDayLabels() | |||
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 | } |
@@ -702,23 +699,23 @@ void KOAgendaView::createDayLabels() | |||
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); |
@@ -730,12 +727,12 @@ void KOAgendaView::createDayLabels() | |||
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 ) { |
@@ -823,9 +820,9 @@ void KOAgendaView::createDayLabels() | |||
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 ) { |
diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index cbe86b6..e9e85cc 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h | |||
@@ -24,8 +24,9 @@ | |||
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 |
@@ -34,9 +35,8 @@ | |||
34 | #include <qmemarray.h> | 35 | #include <qmemarray.h> |
35 | 36 | ||
36 | #include "koeventview.h" | 37 | #include "koeventview.h" |
37 | 38 | ||
38 | |||
39 | class QHBox; | 39 | class QHBox; |
40 | class QFrame; | 40 | class QFrame; |
41 | class QLabel; | 41 | class QLabel; |
42 | class QPushButton; | 42 | class QPushButton; |
@@ -44,8 +44,33 @@ class CalendarView; | |||
44 | class KOAgenda; | 44 | class KOAgenda; |
45 | class KOAgendaItem; | 45 | class KOAgendaItem; |
46 | class KConfig; | 46 | class KConfig; |
47 | class KDGanttMinimizeSplitter; | 47 | class KDGanttMinimizeSplitter; |
48 | |||
49 | class 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; } | ||
65 | private slots: | ||
66 | void bClicked() {emit numClicked( mNum);} | ||
67 | signals: | ||
68 | void numClicked( int ); | ||
69 | private: | ||
70 | int mNum; | ||
71 | }; | ||
72 | |||
48 | class TimeLabels : public QScrollView { | 73 | class 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); |
@@ -189,9 +214,9 @@ class KOAgendaView : public KOEventView { | |||
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); |
@@ -207,9 +232,9 @@ class KOAgendaView : public KOEventView { | |||
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 | ||
@@ -253,9 +278,9 @@ class KOAgendaView : public KOEventView { | |||
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 ); |