summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Unidiff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9888566..6294b98 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -669,53 +669,49 @@ QDate MonthViewCell::selectedIncidenceDate()
669 669
670 MonthViewItem *item = 670 MonthViewItem *item =
671 static_cast<MonthViewItem *>( mItemList->item( index ) ); 671 static_cast<MonthViewItem *>( mItemList->item( index ) );
672 672
673 if ( !item ) return qd; 673 if ( !item ) return qd;
674 674
675 return item->incidenceDate(); 675 return item->incidenceDate();
676} 676}
677 677
678void MonthViewCell::deselect() 678void MonthViewCell::deselect()
679{ 679{
680 mItemList->clearSelection(); 680 mItemList->clearSelection();
681 enableScrollBars( false ); 681 enableScrollBars( false );
682 // updateCell(); 682 // updateCell();
683} 683}
684void MonthViewCell::select() 684void MonthViewCell::select()
685{ 685{
686 ;// updateCell(); 686 ;// updateCell();
687} 687}
688 688
689void MonthViewCell::resizeEvent ( QResizeEvent * ) 689void MonthViewCell::resizeEvent ( QResizeEvent * )
690{ 690{
691 if ( !mMonthView->isUpdatePossible() ) 691 if ( !mMonthView->isUpdatePossible() )
692 return; 692 return;
693#ifndef DESKTOP_VERSION 693
694 if ( !isVisible() ){
695 return;
696 }
697#endif
698 int size = height() - mLabel->height() - 2; 694 int size = height() - mLabel->height() - 2;
699 if ( size > 0 ) 695 if ( size > 0 )
700 mItemList->verticalScrollBar()->setMaximumHeight( size ); 696 mItemList->verticalScrollBar()->setMaximumHeight( size );
701 size = width() - mLabel->width() -2; 697 size = width() - mLabel->width() -2;
702 if ( size > 0 ) 698 if ( size > 0 )
703 mItemList->horizontalScrollBar()->setMaximumWidth( size ); 699 mItemList->horizontalScrollBar()->setMaximumWidth( size );
704 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); 700 mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() );
705 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); 701 //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
706} 702}
707 703
708void MonthViewCell::defaultAction( QListBoxItem *item ) 704void MonthViewCell::defaultAction( QListBoxItem *item )
709{ 705{
710 if ( !item ) return; 706 if ( !item ) return;
711 707
712 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); 708 MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
713 Incidence *incidence = eventItem->incidence(); 709 Incidence *incidence = eventItem->incidence();
714 if ( incidence ) mMonthView->defaultAction( incidence ); 710 if ( incidence ) mMonthView->defaultAction( incidence );
715} 711}
716void MonthViewCell::showDay() 712void MonthViewCell::showDay()
717{ 713{
718 emit showDaySignal( date() ); 714 emit showDaySignal( date() );
719} 715}
720void MonthViewCell::newEvent() 716void MonthViewCell::newEvent()
721{ 717{
@@ -820,48 +816,50 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
820 816
821 connect( cell, SIGNAL( defaultAction( Incidence * ) ), 817 connect( cell, SIGNAL( defaultAction( Incidence * ) ),
822 SLOT( defaultAction( Incidence * ) ) ); 818 SLOT( defaultAction( Incidence * ) ) );
823 connect( cell, SIGNAL( newEventSignal( QDateTime ) ), 819 connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
824 SIGNAL( newEventSignal( QDateTime ) ) ); 820 SIGNAL( newEventSignal( QDateTime ) ) );
825 connect( cell, SIGNAL( showDaySignal( QDate ) ), 821 connect( cell, SIGNAL( showDaySignal( QDate ) ),
826 SIGNAL( showDaySignal( QDate ) ) ); 822 SIGNAL( showDaySignal( QDate ) ) );
827 } 823 }
828 } 824 }
829 825
830 connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), 826 connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ),
831 SLOT( switchView() ) ); 827 SLOT( switchView() ) );
832 mContextMenu = eventPopup(); 828 mContextMenu = eventPopup();
833 // updateConfig(); //useless here 829 // updateConfig(); //useless here
834 830
835 emit incidenceSelected( 0 ); 831 emit incidenceSelected( 0 );
836} 832}
837 833
838KOMonthView::~KOMonthView() 834KOMonthView::~KOMonthView()
839{ 835{
840 delete mContextMenu; 836 delete mContextMenu;
841} 837}
842void KOMonthView::switchView() 838void KOMonthView::switchView()
843{ 839{
840 if ( selectedCell( ) )
841 selectedCell()->deselect();
844 mShowWeekView = !mShowWeekView; 842 mShowWeekView = !mShowWeekView;
845 KOPrefs::instance()->mMonthViewWeek = mShowWeekView; 843 KOPrefs::instance()->mMonthViewWeek = mShowWeekView;
846 emit showNavigator( !mShowWeekView ); 844 emit showNavigator( !mShowWeekView );
847 computeLayout(); 845 computeLayout();
848 updateConfig(); 846 updateConfig();
849} 847}
850 848
851int KOMonthView::maxDatesHint() 849int KOMonthView::maxDatesHint()
852{ 850{
853 return mNumCells; 851 return mNumCells;
854} 852}
855 853
856int KOMonthView::currentDateCount() 854int KOMonthView::currentDateCount()
857{ 855{
858 return mNumCells; 856 return mNumCells;
859} 857}
860 858
861QPtrList<Incidence> KOMonthView::selectedIncidences() 859QPtrList<Incidence> KOMonthView::selectedIncidences()
862{ 860{
863 QPtrList<Incidence> selected; 861 QPtrList<Incidence> selected;
864 862
865 if ( mSelectedCell ) { 863 if ( mSelectedCell ) {
866 Incidence *incidence = mSelectedCell->selectedIncidence(); 864 Incidence *incidence = mSelectedCell->selectedIncidence();
867 if ( incidence ) selected.append( incidence ); 865 if ( incidence ) selected.append( incidence );
@@ -1138,53 +1136,54 @@ void KOMonthView::computeLayoutWeek()
1138 combinedSatSun = true; 1136 combinedSatSun = true;
1139 1137
1140 //qDebug("KOMonthView::computeLayout()------------------------------------ "); 1138 //qDebug("KOMonthView::computeLayout()------------------------------------ ");
1141 QFontMetrics fm ( mWeekLabels[0]->font() ); 1139 QFontMetrics fm ( mWeekLabels[0]->font() );
1142 int weeklabelwid = fm.width( "888" ); 1140 int weeklabelwid = fm.width( "888" );
1143 wid -= weeklabelwid; 1141 wid -= weeklabelwid;
1144 1142
1145 int colWid = wid / daysToShow; 1143 int colWid = wid / daysToShow;
1146 int lastCol = wid - ( colWid*6 ); 1144 int lastCol = wid - ( colWid*6 );
1147 int dayLabelHei = mDayLabels[0]->sizeHint().height(); 1145 int dayLabelHei = mDayLabels[0]->sizeHint().height();
1148 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow ); 1146 int cellHei = (hei - (5- daysToShow )*dayLabelHei) /(5- daysToShow );
1149 int colModulo = wid % daysToShow; 1147 int colModulo = wid % daysToShow;
1150 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1; 1148 int rowModulo = (hei- (5- daysToShow )*dayLabelHei) % daysToShow-1;
1151 //qDebug("rowmod %d ", rowModulo); 1149 //qDebug("rowmod %d ", rowModulo);
1152 int i; 1150 int i;
1153 int x,y,w,h; 1151 int x,y,w,h;
1154 x= 0; 1152 x= 0;
1155 y= 0; 1153 y= 0;
1156 w = colWid; 1154 w = colWid;
1157 h = dayLabelHei ; 1155 h = dayLabelHei ;
1158 for ( i = 0; i < 7; i++) { 1156 for ( i = 0; i < 7; i++) {
1159 if ( i && !( i % daysToShow) && i < 6) { 1157 if ( i && !( i % daysToShow) && i < 6) {
1160 y += hei/(5-daysToShow); 1158 y += hei/(5-daysToShow);
1161 x = 0; 1159 x = 0;
1160 w = colWid;
1162 } 1161 }
1163 if ( i == daysToShow-colModulo ) 1162 if ( i == daysToShow-colModulo )
1164 ++w; 1163 ++w;
1165 if ( i >= 5 ) { 1164 if ( i >= 5 ) {
1166 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2,h); 1165 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w/2+1,h);
1167 x -= w/2 ; 1166 x -= w/2 ;
1168 } 1167 }
1169 else 1168 else
1170 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h); 1169 mDayLabels[i]->setGeometry( x+weeklabelwid,y,w,h);
1171 x += w; 1170 x += w;
1172 } 1171 }
1173 x= 0; 1172 x= 0;
1174 y= dayLabelHei; 1173 y= dayLabelHei;
1175 w = colWid; 1174 w = colWid;
1176 h = cellHei; 1175 h = cellHei;
1177 for ( i = 0; i < mCells.count(); ++i) { 1176 for ( i = 0; i < mCells.count(); ++i) {
1178 if ( i > 6 ) { 1177 if ( i > 6 ) {
1179 mCells[i]->hide(); 1178 mCells[i]->hide();
1180 continue; 1179 continue;
1181 } 1180 }
1182 1181
1183 w = colWid; 1182 w = colWid;
1184 if ( ((i) % daysToShow) >= daysToShow-colModulo ) { 1183 if ( ((i) % daysToShow) >= daysToShow-colModulo ) {
1185 ++w; 1184 ++w;
1186 } 1185 }
1187 if ( i == (daysToShow-1-rowModulo)*7) 1186 if ( i == (daysToShow-1-rowModulo)*7)
1188 ++h; 1187 ++h;
1189 1188
1190 if ( i >= 5 ) { 1189 if ( i >= 5 ) {