author | zautrix <zautrix> | 2005-01-11 15:48:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-01-11 15:48:26 (UTC) |
commit | ff808c2b4cd2751e7f99dd7cb5c1e44886ac151f (patch) (side-by-side diff) | |
tree | 7cd2fdcfea35ca54b94aff1b113c92482a904fae /korganizer | |
parent | 7738615474fd5186928e3f4dcdc58b483f7ad1a9 (diff) | |
download | kdepimpi-ff808c2b4cd2751e7f99dd7cb5c1e44886ac151f.zip kdepimpi-ff808c2b4cd2751e7f99dd7cb5c1e44886ac151f.tar.gz kdepimpi-ff808c2b4cd2751e7f99dd7cb5c1e44886ac151f.tar.bz2 |
tooltips added
-rw-r--r-- | korganizer/komonthview.cpp | 40 | ||||
-rw-r--r-- | korganizer/komonthview.h | 11 |
2 files changed, 45 insertions, 6 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; diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 5124057..4c1567c 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -31,16 +31,20 @@ #include <qvaluelist.h> #include <qptrvector.h> #include <libkcal/calendar.h> #include <libkcal/event.h> #include "koeventview.h" +#ifdef DESKTOP_VERSION +class QToolTipGroup; +#endif + class KOWeekButton : public QPushButton { Q_OBJECT public: KOWeekButton( QWidget *parent=0, const char *name=0 ) : QPushButton( parent, name) { connect( this, SIGNAL( clicked() ), @@ -135,16 +139,19 @@ class MonthViewCell : public QWidget void enableScrollBars( bool ); Incidence *selectedIncidence(); QDate selectedIncidenceDate(); void deselect(); void select(); +#ifdef DESKTOP_VERSION + static QToolTipGroup *toolTipGroup(); +#endif signals: void defaultAction( Incidence * ); void newEventSignal( QDateTime ); void showDaySignal( QDate ); protected: void resizeEvent( QResizeEvent * ); @@ -162,17 +169,19 @@ class MonthViewCell : public QWidget QDate mDate; bool mPrimary; bool mHoliday; QString mHolidayString; //QLabel *mLabel; QPushButton *mLabel; QListBox *mItemList; - +#ifdef DESKTOP_VERSION + static QToolTipGroup *mToolTipGroup; +#endif QSize mLabelSize; QSize mLabelBigSize; QPalette mHolidayPalette; QPalette mStandardPalette; QPalette mPrimaryPalette; QPalette mNonPrimaryPalette; void setMyPalette(); QPalette getPalette (); |