author | zautrix <zautrix> | 2005-01-31 22:41:05 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-31 22:41:05 (UTC) |
commit | 336678d691a8c3346c92a4e561ac7938ed532003 (patch) (side-by-side diff) | |
tree | d4c12ab5536003910727b4478f70372324b7c00d /korganizer/koagendaview.cpp | |
parent | 949ead6797c44f632a4addd2e6aae1fb88f37816 (diff) | |
download | kdepimpi-336678d691a8c3346c92a4e561ac7938ed532003.zip kdepimpi-336678d691a8c3346c92a4e561ac7938ed532003.tar.gz kdepimpi-336678d691a8c3346c92a4e561ac7938ed532003.tar.bz2 |
fixxx
-rw-r--r-- | korganizer/koagendaview.cpp | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index 8e9add3..d43712f 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -564,279 +564,309 @@ void KOAgendaView::toggleAllDay() if ( mSplitterAgenda->firstHandle() ) mSplitterAgenda->firstHandle()->toggle(); } void KOAgendaView::addToCalSlot(Incidence * inc, Incidence * incOld ) { calendar()->addIncidence( inc ); if ( incOld ) { if ( incOld->type() == "Todo" ) emit todoMoved((Todo*)incOld, KOGlobals::EVENTEDITED ); else emit incidenceChanged(incOld, KOGlobals::EVENTEDITED); } } KOAgendaView::~KOAgendaView() { delete mAgendaPopup; delete mAllDayAgendaPopup; delete KOAgendaItem::paintPix(); delete KOAgendaItem::paintPixSel(); } void KOAgendaView::resizeEvent( QResizeEvent* e ) { //qDebug("KOAgendaView::resizeEvent( QResizeEvent* e ) %d ", e->size().width()); bool uc = false; int ow = e->oldSize().width(); int oh = e->oldSize().height(); int w = e->size().width(); int h = e->size().height(); if ( (ow > oh && w< h ) || (ow < oh && w > h ) ) { if ( ! mBlockUpdating && !globalFlagBlockStartup && !globalFlagBlockAgenda ) uc = true; //qDebug("view changed %d %d %d %d ", ow, oh , w , h); } mUpcomingWidth = e->size().width() ; if ( mBlockUpdating || uc ) { mBlockUpdating = false; //mAgenda->setMinimumSize(800 , 600 ); //qDebug("mAgenda->resize+++++++++++++++ "); updateConfig(); //qDebug("KOAgendaView::Updating now possible "); } else createDayLabels(); //qDebug("resizeEvent end "); } +void KOAgendaView::slotDaylabelClicked() +{ + QString cap = ((QPushButton*) sender() )->caption(); + + QDate firstDate = mSelectedDates.first(); + if ( cap == "0" ) + emit showDateView( 6, firstDate ); + else if ( cap != "last" ) { + if ( mSelectedDates.count() == 1) + emit showDateView( 9, firstDate.addDays( cap.toInt()-1 ) ); + else + emit showDateView( 3, firstDate.addDays( cap.toInt()-1 ) ); + } + else + showDateView( 10, firstDate.addDays(1 ) ); +} void KOAgendaView::createDayLabels() { if ( mBlockUpdating || globalFlagBlockLabel == 1) { // qDebug(" KOAgendaView::createDayLabels() blocked "); return; } int newHight; // ### Before deleting and recreating we could check if mSelectedDates changed... // It would remove some flickering and gain speed (since this is called by // each updateView() call) int maxWid = mUpcomingWidth - mTimeLabels->width()- mAgenda->verticalScrollBar()->width() - 2; mDayLabelsFrame->setMaximumWidth( mUpcomingWidth ); if ( maxWid < 0 ) maxWid = 20; QFont dlf = KOPrefs::instance()->mTimeLabelsFont; QFontMetrics fm ( dlf ); int selCount = mSelectedDates.count(); QString dayTest = "Mon 20"; int wid = fm.width( dayTest ); maxWid -= ( selCount * 3 ); if ( maxWid < 0 ) maxWid = 20; int needWid = wid * selCount; //qDebug("++++++++Needed : %d MaxWidth: %d", needWid, maxWid ); //if ( needWid > maxWid ) // qDebug("DAYLABELS TOOOOOOO BIG "); while ( needWid > maxWid ) { dayTest = dayTest.left( dayTest.length() - 1 ); wid = fm.width( dayTest ); needWid = wid * selCount; } int maxLen = dayTest.length(); int fontPoint = dlf.pointSize(); if ( maxLen < 2 ) { int fontPoint = dlf.pointSize(); while ( fontPoint > 4 ) { --fontPoint; dlf.setPointSize( fontPoint ); QFontMetrics f( dlf ); wid = f.width( "20" ); needWid = wid * selCount; if ( needWid < maxWid ) break; } maxLen = 2; } //qDebug("Max len %d ", dayTest.length() ); QFontMetrics tempF( dlf ); newHight = tempF.height(); mDayLabels->setFont( dlf ); // mLayoutDayLabels = new QHBoxLayout(mDayLabels);; // mLayoutDayLabels->addSpacing(mTimeLabels->width()); //mLayoutDayLabels->addSpacing( 2 ); // QFont lFont = dlf; bool appendLabels = false; - QLabel *dayLabel; + QPushButton *dayLabel; dayLabel = mDayLabelsList.first(); if ( !dayLabel ) { appendLabels = true; - dayLabel = new QLabel(mDayLabels); + dayLabel = new QPushButton(mDayLabels); + dayLabel->setFlat( true ); + connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); + dayLabel->setFocusPolicy(NoFocus); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); } dayLabel->setFixedWidth( mTimeLabels->width()+2 ); dayLabel->setFont( dlf ); - dayLabel->setAlignment(QLabel::AlignHCenter); + dayLabel->setCaption("0"); + //dayLabel->setAlignment(QLabel::AlignHCenter); dayLabel->setText( KOGlobals::self()->calendarSystem()->monthName( mSelectedDates.first(), true ) ); dayLabel->show(); DateList::ConstIterator dit; bool oneday = (mSelectedDates.first() == mSelectedDates.last() ); + int counter = 0; for( dit = mSelectedDates.begin(); dit != mSelectedDates.end(); ++dit ) { + ++counter; QDate date = *dit; // QBoxLayout *dayLayout = new QVBoxLayout(mLayoutDayLabels); if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { - dayLabel = new QLabel(mDayLabels); + dayLabel = new QPushButton(mDayLabels); + dayLabel->setFlat( true ); + connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); + dayLabel->setFocusPolicy(NoFocus); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); } dayLabel->setMinimumWidth( 1 ); dayLabel->setMaximumWidth( 2048 ); dayLabel->setFont( dlf ); dayLabel->show(); + dayLabel->setCaption(QString::number( counter )); QString str; int dW = KOGlobals::self()->calendarSystem()->dayOfWeek(date); QString dayName = KOGlobals::self()->calendarSystem()->weekDayName( dW, true ); switch ( maxLen ) { case 2: str = QString::number( date.day() ); break; case 3: str = dayName.left( 1 ) +QString::number( date.day()); break; case 4: str = dayName.left( 1 ) + " " +QString::number( date.day()); break; case 5: str = dayName.left( 2 ) + " " +QString::number( date.day()); break; case 6: str = dayName.left( 3 ) + " " +QString::number( date.day()); break; default: break; } if ( oneday ) { QString addString; if ( mSelectedDates.first() == QDateTime::currentDateTime().date() ) addString = i18n("Today"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(1) ) addString = i18n("Tomorrow"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-1) ) addString = i18n("Yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(-2) ) addString = i18n("Day before yesterday"); else if ( mSelectedDates.first() == QDateTime::currentDateTime().date().addDays(2) ) addString = i18n("Day after tomorrow"); if ( !addString.isEmpty() ) { str = addString+", " + str; } } dayLabel->setText(str); - dayLabel->setAlignment(QLabel::AlignHCenter); + //dayLabel->setAlignment(QLabel::AlignHCenter); if (date == QDate::currentDate()) { QFont bFont = dlf; bFont.setBold( true ); dayLabel->setFont(bFont); } //dayLayout->addWidget(dayLabel); #ifndef KORG_NOPLUGINS CalendarDecoration::List cds = KOCore::self()->calendarDecorations(); CalendarDecoration *it; for(it = cds.first(); it; it = cds.next()) { QString text = it->shortText( date ); if ( !text.isEmpty() ) { QLabel *label = new QLabel(text,mDayLabels); label->setAlignment(AlignCenter); dayLayout->addWidget(label); } } for(it = cds.first(); it; it = cds.next()) { QWidget *wid = it->smallWidget(mDayLabels,date); if ( wid ) { // wid->setHeight(20); dayLayout->addWidget(wid); } } #endif } if ( ! appendLabels ) { dayLabel = mDayLabelsList.next(); if ( !dayLabel ) appendLabels = true; } if ( appendLabels ) { - dayLabel = new QLabel(mDayLabels); + dayLabel = new QPushButton(mDayLabels); + dayLabel->setFlat( true ); + connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); + dayLabel->setFocusPolicy(NoFocus); mDayLabelsList.append( dayLabel ); mLayoutDayLabels->addWidget(dayLabel); } //dayLabel->hide();//test only int offset = (mAgenda->width() - mAgenda->verticalScrollBar()->width()-3 ) % mSelectedDates.count() ; if ( offset < 0 ) offset = 0; //qDebug("mLayoutDayLabels->addSpacing %d ", mAgenda->verticalScrollBar()->width()+offset+2 ); - dayLabel->setText("");//QString::number ( mSelectedDates.first().month() ) ); + dayLabel->setText(">");//QString::number ( mSelectedDates.first().month() ) ); dayLabel->show(); + dayLabel->setCaption("last"); dayLabel->setFixedWidth( mAgenda->verticalScrollBar()->width()+ offset ); //qDebug("setToFixed %d ", mAgenda->verticalScrollBar()->width()+ offset+2); //mLayoutDayLabels->addSpacing(mAgenda->verticalScrollBar()->width()+ offset+2); if ( !appendLabels ) { dayLabel = mDayLabelsList.next(); while ( dayLabel ) { //qDebug("!dayLabel %d",dayLabel ); dayLabel->hide(); dayLabel = mDayLabelsList.next(); } } //mDayLabelsFrame->show(); //mDayLabels->show(); //qDebug("heigt %d %d %d ",mDayLabelsFrame->height(), mDayLabelsFrame->sizeHint().height(), newHight); //mDayLabelsFrame->resize( mAgenda->visibleWidth(), newHight ); mDayLabelsFrame->setFixedHeight( newHight ); } int KOAgendaView::maxDatesHint() { // Not sure about the max number of events, so return 0 for now. return 0; } int KOAgendaView::currentDateCount() { return mSelectedDates.count(); } QPtrList<Incidence> KOAgendaView::selectedIncidences() { QPtrList<Incidence> selected; Incidence *incidence; incidence = mAgenda->selectedIncidence(); if (incidence) selected.append(incidence); incidence = mAllDayAgenda->selectedIncidence(); if (incidence) selected.append(incidence); return selected; } DateList KOAgendaView::selectedDates() { DateList selected; QDate qd; |