summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-02-04 22:22:10 (UTC)
committer zautrix <zautrix>2005-02-04 22:22:10 (UTC)
commit936b4b2aa37e699052a2517dc2d928d717398cf6 (patch) (unidiff)
tree964ac33783c2126ecbaea0a2ee72b83ae6475b52 /korganizer
parent4659ee80518c7d5108c21ba04a12a25eab783113 (diff)
downloadkdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.zip
kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.gz
kdepimpi-936b4b2aa37e699052a2517dc2d928d717398cf6.tar.bz2
fifi
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp2
-rw-r--r--korganizer/komonthview.cpp52
-rw-r--r--korganizer/komonthview.h4
3 files changed, 46 insertions, 12 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index f31e50a..c08f44f 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -55,13 +55,13 @@ KDateNavigator::KDateNavigator( QWidget *parent, Calendar *calendar,
55 55
56 setFrameStyle(QFrame::NoFrame); 56 setFrameStyle(QFrame::NoFrame);
57 57
58 QGridLayout *topLayout = new QGridLayout(this,8,8); 58 QGridLayout *topLayout = new QGridLayout(this,8,8);
59 59
60 if (! startDate.isValid()) { 60 if (! startDate.isValid()) {
61 kdDebug() << "KDateNavigator::KDateNavigator(): an invalid date was passed as a parameter!" << endl; 61 qDebug("KDateNavigator::invalid startdate ");
62 startDate = QDate::currentDate(); 62 startDate = QDate::currentDate();
63 } 63 }
64 64
65 mSelectedDates.append(startDate); 65 mSelectedDates.append(startDate);
66 m_MthYr = startDate; 66 m_MthYr = startDate;
67 m_bShowWeekNums = show_week_nums; 67 m_bShowWeekNums = show_week_nums;
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index dfa89e2..df5e060 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -97,29 +97,29 @@ QString KNoScrollListBox::getWhatsThisText(QPoint p)
97} 97}
98void KNoScrollListBox::keyPressEvent(QKeyEvent *e) 98void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
99{ 99{
100 100
101 switch(e->key()) { 101 switch(e->key()) {
102 case Key_Right: 102 case Key_Right:
103 // if ( e->state() == Qt::ControlButton ) 103 if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
104 { 104 {
105 e->ignore(); 105 e->ignore();
106 return; 106 return;
107 } 107 }
108 scrollBy(4,0); 108 scrollBy(10,0);
109 break; 109 break;
110 case Key_Left: 110 case Key_Left:
111 // if ( e->state() == Qt::ControlButton ) 111 if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
112 { 112 {
113 e->ignore(); 113 e->ignore();
114 return; 114 return;
115 } 115 }
116 scrollBy(-4,0); 116 scrollBy(-10,0);
117 break; 117 break;
118 case Key_Up: 118 case Key_Up:
119 if(count() < 2) { 119 if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
120 e->ignore(); 120 e->ignore();
121 break; 121 break;
122 } 122 }
123 setCurrentItem((currentItem()+count()-1)%count()); 123 setCurrentItem((currentItem()+count()-1)%count());
124 if(!itemVisible(currentItem())) { 124 if(!itemVisible(currentItem())) {
125 if((unsigned int) currentItem() == (count()-1)) { 125 if((unsigned int) currentItem() == (count()-1)) {
@@ -127,34 +127,49 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
127 } else { 127 } else {
128 setTopItem(topItem()-1); 128 setTopItem(topItem()-1);
129 } 129 }
130 } 130 }
131 break; 131 break;
132 case Key_Down: 132 case Key_Down:
133 if(count() < 2) { 133 if(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
134 e->ignore(); 134 e->ignore();
135 break; 135 break;
136 } 136 }
137 setCurrentItem((currentItem()+1)%count()); 137 setCurrentItem((currentItem()+1)%count());
138 if(!itemVisible(currentItem())) { 138 if(!itemVisible(currentItem())) {
139 if(currentItem() == 0) { 139 if(currentItem() == 0) {
140 setTopItem(0); 140 setTopItem(0);
141 } else { 141 } else {
142 setTopItem(topItem()+1); 142 setTopItem(topItem()+1);
143 } 143 }
144 } 144 }
145 break; 145 break;
146 case Key_I:
147 QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
148 e->ignore();
149 break;
146 case Key_Shift: 150 case Key_Shift:
147 emit shiftDown(); 151 emit shiftDown();
148 break; 152 break;
149 default: 153 default:
150 e->ignore(); 154 e->ignore();
151 break; 155 break;
152 } 156 }
153} 157}
154 158
159void KNoScrollListBox::oneDown()
160{
161 setCurrentItem((currentItem()+1)%count());
162 if(!itemVisible(currentItem())) {
163 if(currentItem() == 0) {
164 setTopItem(0);
165 } else {
166 setTopItem(topItem()+1);
167 }
168 }
169}
155void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e) 170void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
156{ 171{
157 switch(e->key()) { 172 switch(e->key()) {
158 case Key_Shift: 173 case Key_Shift:
159 emit shiftUp(); 174 emit shiftUp();
160 break; 175 break;
@@ -279,12 +294,13 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
279 // mLabel = new QLabel( this );QPushButton 294 // mLabel = new QLabel( this );QPushButton
280 mLabel = new QPushButton( this ); 295 mLabel = new QPushButton( this );
281 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); 296 //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
282 //mLabel->setLineWidth( 1 ); 297 //mLabel->setLineWidth( 1 );
283 //mLabel->setAlignment( AlignCenter ); 298 //mLabel->setAlignment( AlignCenter );
284 mLabel->setFlat( true ); 299 mLabel->setFlat( true );
300 mLabel->setFocusPolicy(NoFocus);
285 mItemList = new KNoScrollListBox( this ); 301 mItemList = new KNoScrollListBox( this );
286 mItemList->setMinimumSize( 10, 10 ); 302 mItemList->setMinimumSize( 10, 10 );
287 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); 303 mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
288 mItemList->setLineWidth( 1 ); 304 mItemList->setLineWidth( 1 );
289 topLayout->addWidget( mItemList ); 305 topLayout->addWidget( mItemList );
290 mLabel->raise(); 306 mLabel->raise();
@@ -398,14 +414,16 @@ void MonthViewCell::clear()
398 QApplication::removePostedEvents ( this ); 414 QApplication::removePostedEvents ( this );
399} 415}
400 416
401void MonthViewCell::startUpdateCell() 417void MonthViewCell::startUpdateCell()
402{ 418{
403 419
420 mItemList->setFocusPolicy(NoFocus);
404 if ( !mMonthView->isUpdatePossible() ) 421 if ( !mMonthView->isUpdatePossible() )
405 return; 422 return;
423
406 /* 424 /*
407 if ( !isVisible() ){ 425 if ( !isVisible() ){
408 return; 426 return;
409 } 427 }
410 */ 428 */
411 // qDebug("MonthViewCell::updateCell() "); 429 // qDebug("MonthViewCell::updateCell() ");
@@ -430,12 +448,14 @@ void MonthViewCell::startUpdateCell()
430 mToolTip += mHolidayString+"\n"; 448 mToolTip += mHolidayString+"\n";
431 } 449 }
432} 450}
433 451
434void MonthViewCell::insertEvent(Event *event) 452void MonthViewCell::insertEvent(Event *event)
435{ 453{
454
455 mItemList->setFocusPolicy(WheelFocus);
436 if ( !(event->doesRecur() == Recurrence::rNone) ) { 456 if ( !(event->doesRecur() == Recurrence::rNone) ) {
437 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) 457 if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily )
438 return; 458 return;
439 else 459 else
440 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) 460 if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
441 return; 461 return;
@@ -535,13 +555,13 @@ void MonthViewCell::insertTodo(Todo *todo)
535 if (todo->hasDueDate()) { 555 if (todo->hasDueDate()) {
536 if (!todo->doesFloat()) { 556 if (!todo->doesFloat()) {
537 text += KGlobal::locale()->formatTime(todo->dtDue().time()); 557 text += KGlobal::locale()->formatTime(todo->dtDue().time());
538 text += " "; 558 text += " ";
539 } 559 }
540 } 560 }
541 text += i18n("To-Do: %1").arg(todo->summary()); 561 text += i18n("Td: %1").arg(todo->summary());
542 562
543 MonthViewItem *item = new MonthViewItem( todo, mDate, text ); 563 MonthViewItem *item = new MonthViewItem( todo, mDate, text );
544 //item->setPalette( mStandardPalette ); 564 //item->setPalette( mStandardPalette );
545 QPalette pal; 565 QPalette pal;
546 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { 566 if (KOPrefs::instance()->mMonthViewUsesCategoryColor) {
547 QStringList categories = todo->categories(); 567 QStringList categories = todo->categories();
@@ -823,12 +843,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
823 843
824 bfont.setBold( false ); 844 bfont.setBold( false );
825 mWeekLabels.resize( mNumWeeks+1 ); 845 mWeekLabels.resize( mNumWeeks+1 );
826 mWeekLabelsW.resize( 2 ); 846 mWeekLabelsW.resize( 2 );
827 for( i = 0; i < mNumWeeks+1; i++ ) { 847 for( i = 0; i < mNumWeeks+1; i++ ) {
828 KOWeekButton *label = new KOWeekButton( mMonthView ); 848 KOWeekButton *label = new KOWeekButton( mMonthView );
849 label->setFocusPolicy(NoFocus);
829 label->setFont(bfont); 850 label->setFont(bfont);
830 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 851 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
831 label->setFlat(true); 852 label->setFlat(true);
832 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 853 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
833 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 854 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
834 //label->setLineWidth(1); 855 //label->setLineWidth(1);
@@ -837,12 +858,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
837 } 858 }
838 mWeekLabels[mNumWeeks]->setText( i18n("W")); 859 mWeekLabels[mNumWeeks]->setText( i18n("W"));
839 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); 860 QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number"));
840 861
841 for( i = 0; i < 1+1; i++ ) { 862 for( i = 0; i < 1+1; i++ ) {
842 KOWeekButton *label = new KOWeekButton( mWeekView ); 863 KOWeekButton *label = new KOWeekButton( mWeekView );
864 label->setFocusPolicy(NoFocus);
843 label->setFont(bfont); 865 label->setFont(bfont);
844 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); 866 connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) );
845 label->setFlat(true); 867 label->setFlat(true);
846 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); 868 QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed"));
847 //label->setFrameStyle(QFrame::Panel|QFrame::Raised); 869 //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
848 //label->setLineWidth(1); 870 //label->setLineWidth(1);
@@ -900,22 +922,25 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
900} 922}
901 923
902KOMonthView::~KOMonthView() 924KOMonthView::~KOMonthView()
903{ 925{
904 delete mContextMenu; 926 delete mContextMenu;
905} 927}
906void KOMonthView::selectDateWeekNum ( int )
907{
908 928
909}
910void KOMonthView::selectInternalWeekNum ( int n ) 929void KOMonthView::selectInternalWeekNum ( int n )
911{ 930{
912 switchView(); 931 switchView();
913 emit selectWeekNum ( n ); 932 emit selectWeekNum ( n );
914} 933}
915 934
935int KOMonthView::currentWeek()
936{
937 if ( mShowWeekView )
938 return mWeekLabelsW[0]->getWeekNum();
939 return mWeekLabels[0]->getWeekNum();
940}
916void KOMonthView::switchView() 941void KOMonthView::switchView()
917{ 942{
918 943
919 if ( selectedCell( ) ) 944 if ( selectedCell( ) )
920 selectedCell()->deselect(); 945 selectedCell()->deselect();
921 mShowWeekView = !mShowWeekView; 946 mShowWeekView = !mShowWeekView;
@@ -1536,11 +1561,18 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e )
1536 emit nextMonth(); 1561 emit nextMonth();
1537 mCells[0]->setFocus(); 1562 mCells[0]->setFocus();
1538 1563
1539 } 1564 }
1540 e->accept(); 1565 e->accept();
1541 break; 1566 break;
1567 case Key_Return:
1568 case Key_Enter:
1569 {
1570 selectInternalWeekNum ( currentWeek() );
1571 }
1572 e->accept();
1573 break;
1542 default: 1574 default:
1543 e->ignore(); 1575 e->ignore();
1544 break; 1576 break;
1545 } 1577 }
1546} 1578}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 700f098..51eb9e6 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -51,12 +51,13 @@ class KOWeekButton : public QPushButton
51 { 51 {
52 connect( this, SIGNAL( clicked() ), 52 connect( this, SIGNAL( clicked() ),
53 SLOT( bottonClicked() )); 53 SLOT( bottonClicked() ));
54 mNumber = -1; 54 mNumber = -1;
55 } 55 }
56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} 56 void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
57 int getWeekNum() { return mNumber;}
57 signals: 58 signals:
58 void selectWeekNum ( int ); 59 void selectWeekNum ( int );
59private: 60private:
60 int mNumber; 61 int mNumber;
61private slots : 62private slots :
62 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } 63 void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
@@ -73,12 +74,13 @@ class KNoScrollListBox: public QListBox
73 signals: 74 signals:
74 void shiftDown(); 75 void shiftDown();
75 void shiftUp(); 76 void shiftUp();
76 void rightClick(); 77 void rightClick();
77 78
78 protected slots: 79 protected slots:
80 void oneDown();
79 void keyPressEvent(QKeyEvent *); 81 void keyPressEvent(QKeyEvent *);
80 void keyReleaseEvent(QKeyEvent *); 82 void keyReleaseEvent(QKeyEvent *);
81 void mousePressEvent(QMouseEvent *); 83 void mousePressEvent(QMouseEvent *);
82 84
83 private: 85 private:
84 KNOWhatsThis * mWT; 86 KNOWhatsThis * mWT;
@@ -238,13 +240,12 @@ class KOMonthView: public KOEventView
238 240
239 void showContextMenu( Incidence * ); 241 void showContextMenu( Incidence * );
240 242
241 void setSelectedCell( MonthViewCell * ); 243 void setSelectedCell( MonthViewCell * );
242 244
243 protected slots: 245 protected slots:
244 void selectDateWeekNum ( int );
245 void selectInternalWeekNum ( int ); 246 void selectInternalWeekNum ( int );
246 void switchView(); 247 void switchView();
247 void processSelectionChange(); 248 void processSelectionChange();
248 signals: 249 signals:
249 void nextMonth(); 250 void nextMonth();
250 void prevMonth(); 251 void prevMonth();
@@ -254,12 +255,13 @@ class KOMonthView: public KOEventView
254 protected: 255 protected:
255 void resizeEvent(QResizeEvent *); 256 void resizeEvent(QResizeEvent *);
256 void viewChanged(); 257 void viewChanged();
257 void updateDayLabels(); 258 void updateDayLabels();
258 259
259 private: 260 private:
261 int currentWeek();
260 bool clPending; 262 bool clPending;
261 QWidgetStack * mWidStack; 263 QWidgetStack * mWidStack;
262 QWidget* mMonthView; 264 QWidget* mMonthView;
263 QWidget* mWeekView; 265 QWidget* mWeekView;
264 bool mShowWeekView; 266 bool mShowWeekView;
265 bool updatePossible; 267 bool updatePossible;