-rw-r--r-- | korganizer/koagendaview.cpp | 41 | ||||
-rw-r--r-- | korganizer/koagendaview.h | 1 | ||||
-rw-r--r-- | korganizer/kodaymatrix.cpp | 8 | ||||
-rw-r--r-- | korganizer/koviewmanager.cpp | 41 |
4 files changed, 48 insertions, 43 deletions
diff --git a/korganizer/koagendaview.cpp b/korganizer/koagendaview.cpp index aa36553..8c27c43 100644 --- a/korganizer/koagendaview.cpp +++ b/korganizer/koagendaview.cpp @@ -604,145 +604,151 @@ void KOAgendaView::resizeEvent( QResizeEvent* e ) //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 ) ); } + +QPushButton* KOAgendaView::getNewDaylabel() +{ + + QPushButton * dayLabel = new QPushButton(mDayLabels); + dayLabel->setFlat( true ); + connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); + dayLabel->setFocusPolicy(NoFocus); + dayLabel->setSizePolicy(QSizePolicy( QSizePolicy::Expanding ,QSizePolicy::Expanding )); + mDayLabelsList.append( dayLabel ); + mLayoutDayLabels->addWidget(dayLabel); + //mLayoutDayLabels->setStretchFactor(dayLabel, 100); + return dayLabel ; +} + 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 ); + //maxWid -= ( selCount * 3 ); //working for QLabels + maxWid -= ( selCount * 5 ); //working for QPushButton 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" ); + wid = f.width( "20" )+2; 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; QPushButton *dayLabel; dayLabel = mDayLabelsList.first(); if ( !dayLabel ) { appendLabels = true; - dayLabel = new QPushButton(mDayLabels); - dayLabel->setFlat( true ); - connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); - dayLabel->setFocusPolicy(NoFocus); - mDayLabelsList.append( dayLabel ); - mLayoutDayLabels->addWidget(dayLabel); + dayLabel = getNewDaylabel(); } dayLabel->setFixedWidth( mTimeLabels->width()+2 ); dayLabel->setFont( dlf ); 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 QPushButton(mDayLabels); - dayLabel->setFlat( true ); - connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); - dayLabel->setFocusPolicy(NoFocus); - mDayLabelsList.append( dayLabel ); - mLayoutDayLabels->addWidget(dayLabel); + dayLabel = getNewDaylabel(); } 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()); @@ -786,54 +792,49 @@ void KOAgendaView::createDayLabels() 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 QPushButton(mDayLabels); - dayLabel->setFlat( true ); - connect( dayLabel, SIGNAL( clicked() ), this, SLOT ( slotDaylabelClicked() ) ); - dayLabel->setFocusPolicy(NoFocus); - mDayLabelsList.append( dayLabel ); - mLayoutDayLabels->addWidget(dayLabel); + dayLabel = getNewDaylabel(); } //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->setFont( dlf ); 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); diff --git a/korganizer/koagendaview.h b/korganizer/koagendaview.h index fd0a7af..cbe86b6 100644 --- a/korganizer/koagendaview.h +++ b/korganizer/koagendaview.h @@ -169,48 +169,49 @@ class KOAgendaView : public KOEventView { void newTodoAllDay(int gx, int gy); void startDrag(Event *); void readSettings(); void readSettings(KConfig *); void writeSettings(KConfig *); void setContentsPos(int y); void setExpandedButton( bool expanded ); void scrollOneHourUp(); void scrollOneHourDown(); void addToCalSlot(Incidence *, Incidence *); signals: void showDateView( int, QDate ); void newTodoSignal( QDateTime ,bool ); void toggleExpand(); void todoMoved( Todo *, int ); void incidenceChanged(Incidence * , int ); // void cloneIncidenceSignal(Incidence *); protected: + QPushButton* getNewDaylabel(); bool mBlockUpdating; int mUpcomingWidth; /** Fill agenda beginning with date startDate */ void fillAgenda(const QDate &startDate); void resizeEvent( QResizeEvent* e ); /** Fill agenda using the current set value for the start date */ void fillAgenda(); /** Create labels for the selected dates. */ void createDayLabels(); /** Set the masks on the agenda widgets indicating, which days are holidays. */ void setHolidayMasks(); protected slots: void slotDaylabelClicked(); /** Update event belonging to agenda item */ void updateEventDates(KOAgendaItem *item, int mode = -1); //void updateMovedTodo(); void updateEventIndicatorTop(int newY); void updateEventIndicatorBottom(int newY); diff --git a/korganizer/kodaymatrix.cpp b/korganizer/kodaymatrix.cpp index dd83d48..989f758 100644 --- a/korganizer/kodaymatrix.cpp +++ b/korganizer/kodaymatrix.cpp @@ -319,88 +319,88 @@ int KODayMatrix::getDayIndexFrom(int x, int y) 6 - x/daysize.width() : x/daysize.width()); } // ---------------------------------------------------------------------------- // M O U S E E V E N T H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::mousePressEvent (QMouseEvent* e) { mSelStart = getDayIndexFrom(e->x(), e->y()); if (mSelStart > NUMDAYS-1) mSelStart=NUMDAYS-1; mSelInit = mSelStart; } void KODayMatrix::mouseReleaseEvent (QMouseEvent* e) { int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; - repaint(); + repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; - repaint(); + repaint(false); } } DateList daylist; if ( mSelStart < 0 ) mSelStart = 0; for (int i = mSelStart; i <= mSelEnd; i++) { daylist.append(days[i]); } emit selected((const DateList)daylist); } void KODayMatrix::mouseMoveEvent (QMouseEvent* e) { int tmp = getDayIndexFrom(e->x(), e->y()); if (tmp > NUMDAYS-1) tmp=NUMDAYS-1; if (mSelInit > tmp) { mSelEnd = mSelInit; if (tmp != mSelStart) { mSelStart = tmp; - repaint(); + repaint(false); } } else { mSelStart = mSelInit; //repaint only if selection has changed if (tmp != mSelEnd) { mSelEnd = tmp; - repaint(); + repaint(false); } } } // ---------------------------------------------------------------------------- // D R A G ' N D R O P H A N D L I N G // ---------------------------------------------------------------------------- void KODayMatrix::dragEnterEvent(QDragEnterEvent *e) { #ifndef KORG_NODND if ( !ICalDrag::canDecode( e ) && !VCalDrag::canDecode( e ) ) { e->ignore(); return; } // some visual feedback // oldPalette = palette(); // setPalette(my_HilitePalette); // update(); #endif } void KODayMatrix::dragMoveEvent(QDragMoveEvent *e) diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 188ad23..7e126d9 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -77,101 +77,104 @@ KOViewManager::~KOViewManager() { } KOrg::BaseView *KOViewManager::currentView() { return mCurrentView; } void KOViewManager::readSettings(KConfig *config) { config->setGroup("General"); QString view = config->readEntry("Current View"); if (view == "WhatsNext") showWhatsNextView(); else if (view == "Month") showMonthView(); else if (view == "List") showListView(); else if (view == "Journal") showJournalView(); else if (view == "TimeSpan") showTimeSpanView(); else if (view == "Todo") showTodoView(); else { showAgendaView(); } } - void KOViewManager::showDateView( int view, QDate date) { - + static int lastMode = 0; + static int lastCount = 0; + static bool lastNDMode = false; + static QDate lastDate; //qDebug("date %d %s", view, date.toString().latin1()); -#if 0 - mNewItemPopup->insertItem ( SmallIcon( pathString +"day" ), i18n("Day view"),3 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"week" ), i18n("Next Week"),4 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Two Weeks"),5 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"month" ), i18n("Next Month"),6 ); - mNewItemPopup->insertItem ( SmallIcon( pathString +"journal" ), i18n("Journal view"),7 ); -#endif + + //qDebug("%d %d ", lastNDMode, mFlagShowNextxDays ); + bool savemFlagShowNextxDays = mFlagShowNextxDays; + mFlagShowNextxDays = false; if ( view == 3 ) { //mCurrentAgendaView = 1 ; + lastDate = mMainView->dateNavigator()->selectedDates().first(); + lastCount = mMainView->dateNavigator()->selectedDates().count(); + lastNDMode = savemFlagShowNextxDays; mMainView->showDay( date ); } else if (view == 4 ) { mCurrentAgendaView = 7 ; mMainView->dateNavigator()->selectDates( date, 7 ); } else if (view == 5 ) { mCurrentAgendaView = 14 ; mMainView->dateNavigator()->selectDates( date, 14); } else if (view == 6 ) { mMainView->dateNavigator()->blockSignals( true ); showMonthView(); mMainView->dateNavigator()->selectMonthByDate( date ); mMainView->dateNavigator()->blockSignals( false ); mMainView->dateNavigator()->selectDate( date ); } else if (view == 7 ) { mMainView->dateNavigator()->selectDate( date ); showJournalView(); } else if (view == 8 ) { globalFlagBlockAgenda = 1; if ( mCurrentAgendaView != 3 ) mCurrentAgendaView = -1; showAgendaView(KOPrefs::instance()->mFullViewMonth); globalFlagBlockAgenda = 2; mMainView->dateNavigator()->selectDates( date , KOPrefs::instance()->mNextXDays ); mFlagShowNextxDays = true; mCurrentAgendaView = 3 ; - } if (view == 9) { - showWeekView(); + } if (view == 9) { // return behaviour, for getting back from mode == 3 (single day mode ) + if ( lastMode ) { + mCurrentAgendaView = lastCount ; + mMainView->dateNavigator()->selectDates( lastDate, lastCount); + mFlagShowNextxDays = lastNDMode; + if ( mFlagShowNextxDays ) { + mCurrentAgendaView = 3 ; + } + } else + showWeekView(); } else if (view == 10) { mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() ); } - -#if 0 - dateNavigator()->blockSignals( true ); - dateNavigator()->selectDate( d ); - dateNavigator()->blockSignals( false ); - mViewManager->showDayView(); -#endif - + lastMode = view; } void KOViewManager::writeSettings(KConfig *config) { config->setGroup("General"); QString view; if (mCurrentView == mWhatsNextView) view = "WhatsNext"; else if (mCurrentView == mMonthView) view = "Month"; else if (mCurrentView == mListView) view = "List"; else if (mCurrentView == mJournalView) view = "Journal"; else if (mCurrentView == mTimeSpanView) view = "TimeSpan"; else if (mCurrentView == mTodoView) view = "Todo"; else view = "Agenda"; config->writeEntry("Current View",view); if (mAgendaView) { mAgendaView->writeSettings(config); } if (mTimeSpanView) { mTimeSpanView->writeSettings(config); |