-rw-r--r-- | korganizer/komonthview.cpp | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 08232e2..9344567 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -49,17 +49,19 @@ #include "kocore.h" #endif #include "koglobals.h" #include <libkcal/kincidenceformatter.h> #include "komonthview.h" #define PIXMAP_SIZE 5 - +#ifdef DESKTOP_VERSION + QToolTipGroup *MonthViewCell::mToolTipGroup = 0; +#endif class KNOWhatsThis :public QWhatsThis { public: KNOWhatsThis( KNoScrollListBox* sbox ) : QWhatsThis( sbox ), _wid( sbox) { }; protected: virtual QString text( const QPoint& p) { @@ -79,17 +81,17 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) #endif new KNOWhatsThis(this); } QString KNoScrollListBox::getWhatsThisText(QPoint p) { QListBoxItem* item = itemAt ( p ); if ( ! item ) { - return i18n("Click in the cell or\non the date label\nto add an event!"); + return i18n("Click in the cell\nto add an event!"); } return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence()); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { switch(e->key()) { case Key_Right: @@ -290,17 +292,24 @@ MonthViewCell::MonthViewCell( KOMonthView *parent) SLOT( contextMenu( QListBoxItem * ) ) ); connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), SLOT( selection( QListBoxItem * ) ) ); connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), SLOT( cellClicked( QListBoxItem * ) ) ); connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), SLOT( selection( QListBoxItem * ) ) ); } - +#ifdef DESKTOP_VERSION +QToolTipGroup *MonthViewCell::toolTipGroup() +{ + if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0); + return mToolTipGroup; +} +#endif + void MonthViewCell::setDate( const QDate &date ) { // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl; mDate = date; QString text; bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog; @@ -387,21 +396,26 @@ void MonthViewCell::updateCell() setPrimary( mDate.month()%2 ); setHoliday( KOGlobals::self()->calendarSystem()->dayOfWeek(mDate) == KOGlobals::self()->calendarSystem()->weekDayOfPray() || ( mDate.dayOfWeek() == 6 ) && KOPrefs::instance()-> mExcludeSaturdays); if ( mDate == QDate::currentDate() ) { mItemList->setLineWidth( 3 ); } else { mItemList->setLineWidth( 1 ); } mItemList->clear(); +#ifdef DESKTOP_VERSION + QToolTip::remove(this); +#endif + QString tipText(""); //qApp->processEvents(); if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); mItemList->insertItem( item ); + tipText += mHolidayString+"\n"; } //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); QPtrList<Event> events = mMonthView->calendar()->events( mDate, true ); Event *event; for( event = events.first(); event; event = events.next() ) { if ( event->categories().contains("Holiday") || event->categories().contains(i18n("Holiday"))) { setHoliday( true ); @@ -423,22 +437,26 @@ void MonthViewCell::updateCell() } else { if (mDate == event->dtStart().date()) { prefix ="->" ; } else if (mDate == event->dtEnd().date()) { prefix ="<-" ; } } text = prefix + event->summary(); + tipText += text; } else { - if (event->doesFloat()) + if (event->doesFloat()) { text = event->summary(); + tipText += text; + } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); + tipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } MonthViewItem *item = new MonthViewItem( event, mDate, text ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); QString cat = categories.first(); @@ -478,18 +496,21 @@ void MonthViewCell::updateCell() if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) insert = false; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) insert = false; } - if ( insert ) + if ( insert ) { mItemList->insertItem( item ); + tipText += "\n"; + } else + tipText = ""; } // insert due todos QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate ); Todo *todo; for(todo = todos.first(); todo; todo = todos.next()) { QString text; if (todo->hasDueDate()) { @@ -522,17 +543,23 @@ void MonthViewCell::updateCell() } } } else { pal = mStandardPalette ; } item->setPalette( pal ); mItemList->insertItem( item ); + tipText += text+"\n"; } +#ifdef DESKTOP_VERSION + if (tipText != "") + QToolTip::add(this,tipText,toolTipGroup(),""); +#endif + //setMyPalette(); setMyPalette(); resizeEvent( 0 ); // if ( isVisible()) // qApp->processEvents(); } void MonthViewCell::updateConfig() @@ -809,16 +836,19 @@ void KOMonthView::updateConfig() computeLayout(); updateDayLabels(); //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks); int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks; //resizeEvent( 0 ); for (uint i = 0; i < mCells.count(); ++i) { mCells[i]->updateConfig(); } +#ifdef DESKTOP_VERSION + MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips); +#endif } void KOMonthView::updateDayLabels() { for (int i = 0; i < 7; i++) { if (mWeekStartsMonday) { bool show = mShortDayLabels; |