author | zautrix <zautrix> | 2005-02-02 11:55:36 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-02 11:55:36 (UTC) |
commit | e770226d68f5fdb8484003bbb9898848cec901a8 (patch) (unidiff) | |
tree | ecf8f795d6f8673405c22010c82fb167a41a7aa3 /korganizer/komonthview.cpp | |
parent | 2a184b0d9095c6175e7bdf2f5d5561470b8d6307 (diff) | |
download | kdepimpi-e770226d68f5fdb8484003bbb9898848cec901a8.zip kdepimpi-e770226d68f5fdb8484003bbb9898848cec901a8.tar.gz kdepimpi-e770226d68f5fdb8484003bbb9898848cec901a8.tar.bz2 |
jepp
-rw-r--r-- | korganizer/komonthview.cpp | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 00b1e92..f2cfb75 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp | |||
@@ -753,141 +753,156 @@ void MonthViewCell::selection( QListBoxItem *item ) | |||
753 | if ( !item ) return; | 753 | if ( !item ) return; |
754 | 754 | ||
755 | mMonthView->setSelectedCell( this ); | 755 | mMonthView->setSelectedCell( this ); |
756 | } | 756 | } |
757 | 757 | ||
758 | 758 | ||
759 | // ******************************************************************************* | 759 | // ******************************************************************************* |
760 | // ******************************************************************************* | 760 | // ******************************************************************************* |
761 | // ******************************************************************************* | 761 | // ******************************************************************************* |
762 | 762 | ||
763 | 763 | ||
764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) | 764 | KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) |
765 | : KOEventView( calendar, parent, name ), | 765 | : KOEventView( calendar, parent, name ), |
766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), | 766 | mDaysPerWeek( 7 ), mNumWeeks( 6 ), mNumCells( mDaysPerWeek * mNumWeeks ), |
767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) | 767 | mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 ) |
768 | { | 768 | { |
769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); | 769 | mWeekStartsMonday = KGlobal::locale()->weekStartsMonday(); |
770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; | 770 | mShowWeekView = KOPrefs::instance()->mMonthViewWeek; |
771 | if ( mShowWeekView ) | 771 | if ( mShowWeekView ) |
772 | mWeekStartsMonday = true; | 772 | mWeekStartsMonday = true; |
773 | updatePossible = false; | 773 | updatePossible = false; |
774 | mCells.setAutoDelete( true ); | 774 | mCells.setAutoDelete( true ); |
775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; | 775 | mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ; |
776 | // mDayLayout = new QGridLayout( this ); | 776 | // mDayLayout = new QGridLayout( this ); |
777 | // create the day of the week labels (Sun, Mon, etc) and add them to | 777 | // create the day of the week labels (Sun, Mon, etc) and add them to |
778 | // the layout. | 778 | // the layout. |
779 | mDayLabels.resize( mDaysPerWeek ); | 779 | mDayLabels.resize( mDaysPerWeek ); |
780 | QFont bfont = font(); | 780 | QFont bfont = font(); |
781 | if ( QApplication::desktop()->width() < 650 ) { | 781 | if ( QApplication::desktop()->width() < 650 ) { |
782 | bfont.setPointSize( bfont.pointSize() - 2 ); | 782 | bfont.setPointSize( bfont.pointSize() - 2 ); |
783 | } | 783 | } |
784 | bfont.setBold( true ); | 784 | bfont.setBold( true ); |
785 | int i; | 785 | int i; |
786 | 786 | ||
787 | for( i = 0; i < mDaysPerWeek; i++ ) { | 787 | for( i = 0; i < mDaysPerWeek; i++ ) { |
788 | QLabel *label = new QLabel( this ); | 788 | QLabel *label = new QLabel( this ); |
789 | label->setFont(bfont); | 789 | label->setFont(bfont); |
790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 790 | label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
791 | label->setLineWidth(1); | 791 | label->setLineWidth(1); |
792 | label->setAlignment(AlignCenter); | 792 | label->setAlignment(AlignCenter); |
793 | mDayLabels.insert( i, label ); | 793 | mDayLabels.insert( i, label ); |
794 | } | 794 | } |
795 | 795 | ||
796 | bfont.setBold( false ); | 796 | bfont.setBold( false ); |
797 | mWeekLabels.resize( mNumWeeks+1 ); | 797 | mWeekLabels.resize( mNumWeeks+1 ); |
798 | for( i = 0; i < mNumWeeks+1; i++ ) { | 798 | for( i = 0; i < mNumWeeks+1; i++ ) { |
799 | KOWeekButton *label = new KOWeekButton( this ); | 799 | KOWeekButton *label = new KOWeekButton( this ); |
800 | label->setFont(bfont); | 800 | label->setFont(bfont); |
801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) ); | 801 | connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); |
802 | label->setFlat(true); | 802 | label->setFlat(true); |
803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view")); | 803 | QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); |
804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); | 804 | //label->setFrameStyle(QFrame::Panel|QFrame::Raised); |
805 | //label->setLineWidth(1); | 805 | //label->setLineWidth(1); |
806 | //label->setAlignment(AlignCenter); | 806 | //label->setAlignment(AlignCenter); |
807 | mWeekLabels.insert( i, label ); | 807 | mWeekLabels.insert( i, label ); |
808 | } | 808 | } |
809 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 809 | mWeekLabels[mNumWeeks]->setText( i18n("")); |
810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nswitch to week mode view")); | 810 | QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); |
811 | int row, col; | 811 | int row, col; |
812 | QPopupMenu * wpo = new QPopupMenu (this); | ||
813 | wpo->insertItem( i18n("W#"), 0 ); | ||
814 | for ( i = 1; i < 54; i++ ) | ||
815 | wpo->insertItem( i18n("%1").arg(i), i ); | ||
816 | mWeekLabels[mNumWeeks]->setPopup( wpo ); | ||
812 | mCells.resize( mNumCells ); | 817 | mCells.resize( mNumCells ); |
813 | for( row = 0; row < mNumWeeks; ++row ) { | 818 | for( row = 0; row < mNumWeeks; ++row ) { |
814 | for( col = 0; col < mDaysPerWeek; ++col ) { | 819 | for( col = 0; col < mDaysPerWeek; ++col ) { |
815 | MonthViewCell *cell = new MonthViewCell( this ); | 820 | MonthViewCell *cell = new MonthViewCell( this ); |
816 | mCells.insert( row * mDaysPerWeek + col, cell ); | 821 | mCells.insert( row * mDaysPerWeek + col, cell ); |
817 | 822 | ||
818 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), | 823 | connect( cell, SIGNAL( defaultAction( Incidence * ) ), |
819 | SLOT( defaultAction( Incidence * ) ) ); | 824 | SLOT( defaultAction( Incidence * ) ) ); |
820 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), | 825 | connect( cell, SIGNAL( newEventSignal( QDateTime ) ), |
821 | SIGNAL( newEventSignal( QDateTime ) ) ); | 826 | SIGNAL( newEventSignal( QDateTime ) ) ); |
822 | connect( cell, SIGNAL( showDaySignal( QDate ) ), | 827 | connect( cell, SIGNAL( showDaySignal( QDate ) ), |
823 | SIGNAL( showDaySignal( QDate ) ) ); | 828 | SIGNAL( showDaySignal( QDate ) ) ); |
824 | } | 829 | } |
825 | } | 830 | } |
826 | 831 | ||
827 | connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), | 832 | //connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) ); |
828 | SLOT( switchView() ) ); | 833 | connect( wpo, SIGNAL( activated(int) ), SIGNAL( selectWeekNum ( int ) ) ); |
829 | mContextMenu = eventPopup(); | 834 | mContextMenu = eventPopup(); |
830 | // updateConfig(); //useless here | 835 | // updateConfig(); //useless here |
831 | 836 | ||
832 | emit incidenceSelected( 0 ); | 837 | emit incidenceSelected( 0 ); |
833 | } | 838 | } |
834 | 839 | ||
835 | KOMonthView::~KOMonthView() | 840 | KOMonthView::~KOMonthView() |
836 | { | 841 | { |
837 | delete mContextMenu; | 842 | delete mContextMenu; |
838 | } | 843 | } |
844 | void KOMonthView::selectDateWeekNum ( int ) | ||
845 | { | ||
846 | |||
847 | } | ||
848 | void KOMonthView::selectInternalWeekNum ( int n ) | ||
849 | { | ||
850 | emit selectWeekNum ( n ); | ||
851 | switchView(); | ||
852 | } | ||
853 | |||
839 | void KOMonthView::switchView() | 854 | void KOMonthView::switchView() |
840 | { | 855 | { |
841 | if ( selectedCell( ) ) | 856 | if ( selectedCell( ) ) |
842 | selectedCell()->deselect(); | 857 | selectedCell()->deselect(); |
843 | mShowWeekView = !mShowWeekView; | 858 | mShowWeekView = !mShowWeekView; |
844 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; | 859 | KOPrefs::instance()->mMonthViewWeek = mShowWeekView; |
845 | emit showNavigator( !mShowWeekView ); | 860 | //emit showNavigator( !mShowWeekView ); |
846 | computeLayout(); | 861 | computeLayout(); |
847 | updateConfig(); | 862 | updateConfig(); |
848 | } | 863 | } |
849 | 864 | ||
850 | int KOMonthView::maxDatesHint() | 865 | int KOMonthView::maxDatesHint() |
851 | { | 866 | { |
852 | return mNumCells; | 867 | return mNumCells; |
853 | } | 868 | } |
854 | 869 | ||
855 | int KOMonthView::currentDateCount() | 870 | int KOMonthView::currentDateCount() |
856 | { | 871 | { |
857 | return mNumCells; | 872 | return mNumCells; |
858 | } | 873 | } |
859 | 874 | ||
860 | QPtrList<Incidence> KOMonthView::selectedIncidences() | 875 | QPtrList<Incidence> KOMonthView::selectedIncidences() |
861 | { | 876 | { |
862 | QPtrList<Incidence> selected; | 877 | QPtrList<Incidence> selected; |
863 | 878 | ||
864 | if ( mSelectedCell ) { | 879 | if ( mSelectedCell ) { |
865 | Incidence *incidence = mSelectedCell->selectedIncidence(); | 880 | Incidence *incidence = mSelectedCell->selectedIncidence(); |
866 | if ( incidence ) selected.append( incidence ); | 881 | if ( incidence ) selected.append( incidence ); |
867 | } | 882 | } |
868 | 883 | ||
869 | return selected; | 884 | return selected; |
870 | } | 885 | } |
871 | 886 | ||
872 | DateList KOMonthView::selectedDates() | 887 | DateList KOMonthView::selectedDates() |
873 | { | 888 | { |
874 | DateList selected; | 889 | DateList selected; |
875 | 890 | ||
876 | if ( mSelectedCell ) { | 891 | if ( mSelectedCell ) { |
877 | QDate qd = mSelectedCell->selectedIncidenceDate(); | 892 | QDate qd = mSelectedCell->selectedIncidenceDate(); |
878 | if ( qd.isValid() ) selected.append( qd ); | 893 | if ( qd.isValid() ) selected.append( qd ); |
879 | } | 894 | } |
880 | 895 | ||
881 | return selected; | 896 | return selected; |
882 | } | 897 | } |
883 | 898 | ||
884 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, | 899 | void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd, |
885 | const QDate &td) | 900 | const QDate &td) |
886 | { | 901 | { |
887 | #ifndef KORG_NOPRINTER | 902 | #ifndef KORG_NOPRINTER |
888 | calPrinter->preview(CalPrinter::Month, fd, td); | 903 | calPrinter->preview(CalPrinter::Month, fd, td); |
889 | #endif | 904 | #endif |
890 | } | 905 | } |
891 | 906 | ||
892 | void KOMonthView::updateConfig() | 907 | void KOMonthView::updateConfig() |
893 | { | 908 | { |
@@ -1177,97 +1192,97 @@ void KOMonthView::computeLayoutWeek() | |||
1177 | h = cellHei; | 1192 | h = cellHei; |
1178 | for ( i = 0; i < mCells.count(); ++i) { | 1193 | for ( i = 0; i < mCells.count(); ++i) { |
1179 | if ( i > 6 ) { | 1194 | if ( i > 6 ) { |
1180 | mCells[i]->hide(); | 1195 | mCells[i]->hide(); |
1181 | continue; | 1196 | continue; |
1182 | } | 1197 | } |
1183 | 1198 | ||
1184 | w = colWid; | 1199 | w = colWid; |
1185 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { | 1200 | if ( ((i) % daysToShow) >= daysToShow-colModulo ) { |
1186 | ++w; | 1201 | ++w; |
1187 | } | 1202 | } |
1188 | if ( i == (daysToShow-1-rowModulo)*7) | 1203 | if ( i == (daysToShow-1-rowModulo)*7) |
1189 | ++h; | 1204 | ++h; |
1190 | 1205 | ||
1191 | if ( i >= 5 ) { | 1206 | if ( i >= 5 ) { |
1192 | if ( i ==5 ) { | 1207 | if ( i ==5 ) { |
1193 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1208 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1194 | x -= w ;y += h/2; | 1209 | x -= w ;y += h/2; |
1195 | } else { | 1210 | } else { |
1196 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { | 1211 | if ( ((i-1) % daysToShow) >= daysToShow-colModulo ) { |
1197 | ++w; | 1212 | ++w; |
1198 | } | 1213 | } |
1199 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1214 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1200 | y -= h/2; | 1215 | y -= h/2; |
1201 | } | 1216 | } |
1202 | } else | 1217 | } else |
1203 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1218 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1204 | 1219 | ||
1205 | 1220 | ||
1206 | x += w; | 1221 | x += w; |
1207 | if ( x + w/2 > wid ) { | 1222 | if ( x + w/2 > wid ) { |
1208 | x = 0; | 1223 | x = 0; |
1209 | y += h+dayLabelHei ; | 1224 | y += h+dayLabelHei ; |
1210 | } | 1225 | } |
1211 | } | 1226 | } |
1212 | y= dayLabelHei; | 1227 | y= dayLabelHei; |
1213 | h = cellHei ; | 1228 | h = cellHei ; |
1214 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); | 1229 | mWeekLabels[0]->setGeometry( 0,y,weeklabelwid,hei-dayLabelHei); |
1215 | for ( i = 1; i < 6; i++) { | 1230 | for ( i = 1; i < 6; i++) { |
1216 | mWeekLabels[i]->hide(); | 1231 | mWeekLabels[i]->hide(); |
1217 | } | 1232 | } |
1218 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1233 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1219 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1234 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1220 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1235 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1221 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1236 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1222 | updateDayLabels(); | 1237 | updateDayLabels(); |
1223 | bool forceUpdate = !updatePossible; | 1238 | bool forceUpdate = !updatePossible; |
1224 | updatePossible = true; | 1239 | updatePossible = true; |
1225 | mWeekLabels[mNumWeeks]->setText( i18n("M")); | 1240 | //mWeekLabels[mNumWeeks]->setText( i18n("M")); |
1226 | if ( forceUpdate ) | 1241 | if ( forceUpdate ) |
1227 | updateView(); | 1242 | updateView(); |
1228 | } | 1243 | } |
1229 | void KOMonthView::computeLayout() | 1244 | void KOMonthView::computeLayout() |
1230 | { | 1245 | { |
1231 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". | 1246 | // select the appropriate heading string size. E.g. "Wednesday" or "Wed". |
1232 | // note this only changes the text if the requested size crosses the | 1247 | // note this only changes the text if the requested size crosses the |
1233 | // threshold between big enough to support the full name and not big | 1248 | // threshold between big enough to support the full name and not big |
1234 | // enough. | 1249 | // enough. |
1235 | if ( mShowWeekView ){ | 1250 | if ( mShowWeekView ){ |
1236 | computeLayoutWeek(); | 1251 | computeLayoutWeek(); |
1237 | return; | 1252 | return; |
1238 | } | 1253 | } |
1239 | int daysToShow = 7; | 1254 | int daysToShow = 7; |
1240 | bool combinedSatSun = false; | 1255 | bool combinedSatSun = false; |
1241 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { | 1256 | if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) { |
1242 | daysToShow = 6; | 1257 | daysToShow = 6; |
1243 | combinedSatSun = true; | 1258 | combinedSatSun = true; |
1244 | } | 1259 | } |
1245 | int tWid = topLevelWidget()->size().width(); | 1260 | int tWid = topLevelWidget()->size().width(); |
1246 | int tHei = topLevelWidget()->size().height(); | 1261 | int tHei = topLevelWidget()->size().height(); |
1247 | 1262 | ||
1248 | int wid = size().width();//e | 1263 | int wid = size().width();//e |
1249 | int hei = size().height()-1; | 1264 | int hei = size().height()-1; |
1250 | 1265 | ||
1251 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) | 1266 | if ( ((wid *3)/2) < tWid && (( hei *3) /2) < tHei ) |
1252 | return; | 1267 | return; |
1253 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); | 1268 | //qDebug("KOMonthView::computeLayout()------------------------------------ "); |
1254 | QFontMetrics fm ( mWeekLabels[0]->font() ); | 1269 | QFontMetrics fm ( mWeekLabels[0]->font() ); |
1255 | int weeklabelwid = fm.width( "888" ); | 1270 | int weeklabelwid = fm.width( "888" ); |
1256 | wid -= weeklabelwid; | 1271 | wid -= weeklabelwid; |
1257 | 1272 | ||
1258 | int colWid = wid / daysToShow; | 1273 | int colWid = wid / daysToShow; |
1259 | int lastCol = wid - ( colWid*6 ); | 1274 | int lastCol = wid - ( colWid*6 ); |
1260 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); | 1275 | int dayLabelHei = mDayLabels[0]->sizeHint().height(); |
1261 | int cellHei = (hei - dayLabelHei) /6; | 1276 | int cellHei = (hei - dayLabelHei) /6; |
1262 | int colModulo = wid % daysToShow; | 1277 | int colModulo = wid % daysToShow; |
1263 | int rowModulo = (hei- dayLabelHei) % 6; | 1278 | int rowModulo = (hei- dayLabelHei) % 6; |
1264 | //qDebug("rowmod %d ", rowModulo); | 1279 | //qDebug("rowmod %d ", rowModulo); |
1265 | int i; | 1280 | int i; |
1266 | int x,y,w,h; | 1281 | int x,y,w,h; |
1267 | x= 0; | 1282 | x= 0; |
1268 | y= 0; | 1283 | y= 0; |
1269 | w = colWid; | 1284 | w = colWid; |
1270 | h = dayLabelHei ; | 1285 | h = dayLabelHei ; |
1271 | for ( i = 0; i < 7; i++) { | 1286 | for ( i = 0; i < 7; i++) { |
1272 | if ( i == daysToShow-colModulo ) | 1287 | if ( i == daysToShow-colModulo ) |
1273 | ++w; | 1288 | ++w; |
@@ -1286,97 +1301,97 @@ void KOMonthView::computeLayout() | |||
1286 | y= dayLabelHei; | 1301 | y= dayLabelHei; |
1287 | w = colWid; | 1302 | w = colWid; |
1288 | h = cellHei ; | 1303 | h = cellHei ; |
1289 | for ( i = 0; i < mCells.count(); ++i) { | 1304 | for ( i = 0; i < mCells.count(); ++i) { |
1290 | mCells[i]->show(); | 1305 | mCells[i]->show(); |
1291 | w = colWid; | 1306 | w = colWid; |
1292 | if ( ((i) % 7) >= 7-colModulo ) { | 1307 | if ( ((i) % 7) >= 7-colModulo ) { |
1293 | ++w; | 1308 | ++w; |
1294 | } | 1309 | } |
1295 | if ( i == (6-rowModulo)*7) | 1310 | if ( i == (6-rowModulo)*7) |
1296 | ++h; | 1311 | ++h; |
1297 | if ( combinedSatSun ) { | 1312 | if ( combinedSatSun ) { |
1298 | if ( (i)%7 >= daysToShow-1 ) { | 1313 | if ( (i)%7 >= daysToShow-1 ) { |
1299 | if ( (i)%7 == daysToShow-1 ) { | 1314 | if ( (i)%7 == daysToShow-1 ) { |
1300 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); | 1315 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h/2 ); |
1301 | x -= w ;y += h/2; | 1316 | x -= w ;y += h/2; |
1302 | } else { | 1317 | } else { |
1303 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); | 1318 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h-h/2 ); |
1304 | y -= h/2; | 1319 | y -= h/2; |
1305 | } | 1320 | } |
1306 | } else | 1321 | } else |
1307 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1322 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1308 | 1323 | ||
1309 | } | 1324 | } |
1310 | else | 1325 | else |
1311 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); | 1326 | mCells[i]->setGeometry ( x+weeklabelwid,y,w,h ); |
1312 | x += w; | 1327 | x += w; |
1313 | if ( x + w/2 > wid ) { | 1328 | if ( x + w/2 > wid ) { |
1314 | x = 0; | 1329 | x = 0; |
1315 | y += h; | 1330 | y += h; |
1316 | } | 1331 | } |
1317 | } | 1332 | } |
1318 | y= dayLabelHei; | 1333 | y= dayLabelHei; |
1319 | h = cellHei ; | 1334 | h = cellHei ; |
1320 | for ( i = 0; i < 6; i++) { | 1335 | for ( i = 0; i < 6; i++) { |
1321 | mWeekLabels[i]->show(); | 1336 | mWeekLabels[i]->show(); |
1322 | if ( i == (6-rowModulo)) | 1337 | if ( i == (6-rowModulo)) |
1323 | ++h; | 1338 | ++h; |
1324 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); | 1339 | mWeekLabels[i]->setGeometry( 0,y,weeklabelwid,h); |
1325 | y += h; | 1340 | y += h; |
1326 | } | 1341 | } |
1327 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); | 1342 | mWeekLabels[6]->setGeometry( 0,0,weeklabelwid,dayLabelHei); |
1328 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); | 1343 | // qDebug("RRRRRRRRRRRRR %d %d old %d %d", e->size().width(),e->size().height() , e->oldSize().width(),e->oldSize().height()); |
1329 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); | 1344 | //qDebug("parent %d %d ", topLevelWidget()->size().width(), topLevelWidget()->size().height()); |
1330 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; | 1345 | mShortDayLabels = mDayLabels[0]->width() < mWidthLongDayLabel ; |
1331 | updateDayLabels(); | 1346 | updateDayLabels(); |
1332 | bool forceUpdate = !updatePossible; | 1347 | bool forceUpdate = !updatePossible; |
1333 | updatePossible = true; | 1348 | updatePossible = true; |
1334 | mWeekLabels[mNumWeeks]->setText( i18n("W")); | 1349 | //mWeekLabels[mNumWeeks]->setText( i18n("W")); |
1335 | if ( forceUpdate ) | 1350 | if ( forceUpdate ) |
1336 | updateView(); | 1351 | updateView(); |
1337 | } | 1352 | } |
1338 | 1353 | ||
1339 | void KOMonthView::showContextMenu( Incidence *incidence ) | 1354 | void KOMonthView::showContextMenu( Incidence *incidence ) |
1340 | { | 1355 | { |
1341 | mContextMenu->showIncidencePopup(incidence); | 1356 | mContextMenu->showIncidencePopup(incidence); |
1342 | /* | 1357 | /* |
1343 | if( incidence && incidence->type() == "Event" ) { | 1358 | if( incidence && incidence->type() == "Event" ) { |
1344 | Event *event = static_cast<Event *>(incidence); | 1359 | Event *event = static_cast<Event *>(incidence); |
1345 | mContextMenu->showEventPopup(event); | 1360 | mContextMenu->showEventPopup(event); |
1346 | } else { | 1361 | } else { |
1347 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; | 1362 | kdDebug() << "MonthView::showContextMenu(): cast failed." << endl; |
1348 | } | 1363 | } |
1349 | */ | 1364 | */ |
1350 | } | 1365 | } |
1351 | MonthViewCell * KOMonthView::selectedCell( ) | 1366 | MonthViewCell * KOMonthView::selectedCell( ) |
1352 | { | 1367 | { |
1353 | return mSelectedCell; | 1368 | return mSelectedCell; |
1354 | } | 1369 | } |
1355 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) | 1370 | void KOMonthView::setSelectedCell( MonthViewCell *cell ) |
1356 | { | 1371 | { |
1357 | // qDebug("KOMonthView::setSelectedCell "); | 1372 | // qDebug("KOMonthView::setSelectedCell "); |
1358 | if ( mSelectedCell && mSelectedCell != cell ) { | 1373 | if ( mSelectedCell && mSelectedCell != cell ) { |
1359 | MonthViewCell * mvc = mSelectedCell; | 1374 | MonthViewCell * mvc = mSelectedCell; |
1360 | mSelectedCell = cell; | 1375 | mSelectedCell = cell; |
1361 | mvc->deselect(); | 1376 | mvc->deselect(); |
1362 | } else | 1377 | } else |
1363 | mSelectedCell = cell; | 1378 | mSelectedCell = cell; |
1364 | // if ( mSelectedCell ) | 1379 | // if ( mSelectedCell ) |
1365 | // mSelectedCell->select(); | 1380 | // mSelectedCell->select(); |
1366 | if ( !mSelectedCell ) | 1381 | if ( !mSelectedCell ) |
1367 | emit incidenceSelected( 0 ); | 1382 | emit incidenceSelected( 0 ); |
1368 | else | 1383 | else |
1369 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); | 1384 | emit incidenceSelected( mSelectedCell->selectedIncidence() ); |
1370 | } | 1385 | } |
1371 | 1386 | ||
1372 | void KOMonthView::processSelectionChange() | 1387 | void KOMonthView::processSelectionChange() |
1373 | { | 1388 | { |
1374 | QPtrList<Incidence> incidences = selectedIncidences(); | 1389 | QPtrList<Incidence> incidences = selectedIncidences(); |
1375 | if (incidences.count() > 0) { | 1390 | if (incidences.count() > 0) { |
1376 | emit incidenceSelected( incidences.first() ); | 1391 | emit incidenceSelected( incidences.first() ); |
1377 | } else { | 1392 | } else { |
1378 | emit incidenceSelected( 0 ); | 1393 | emit incidenceSelected( 0 ); |
1379 | } | 1394 | } |
1380 | } | 1395 | } |
1381 | 1396 | ||
1382 | void KOMonthView::clearSelection() | 1397 | void KOMonthView::clearSelection() |