-rw-r--r-- | korganizer/komonthview.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 4aeb20c..8d06040 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -53,125 +53,130 @@ #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) { }; //~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); }; protected: virtual QString text( const QPoint& p) { return _wid->getWhatsThisText(p) ; }; private: KNoScrollListBox* _wid; }; KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) : QListBox(parent, name, WRepaintNoErase) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif + mBlockDeselect = false; mWT = new KNOWhatsThis(this); resetOnFocusIn = true; setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() { #if QT_VERSION >= 0x030000 #else delete mWT; #endif } void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) { QListBox::focusInEvent ( e ); if ( count() ){ int ci = currentItem(); if ( ci < 0 ) ci = 0; setCurrentItem( ci ); setSelected ( ci, true ); emit highlighted( item ( ci ) ); resetOnFocusIn = true; if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); int hei = numRows () * ihei; if ( hei < height() - horizontalScrollBar()->height () ) { setVScrollBarMode(QScrollView::AlwaysOff); } else setVScrollBarMode(QScrollView::Auto); if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); } else { setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } } } void KNoScrollListBox::focusOutEvent ( QFocusEvent * e ) { + if ( ! mBlockDeselect ) { int i = currentItem (); if ( i >= 0 ) { - setSelected ( i, false ); + setSelected ( i, false ); } QListBox::focusOutEvent ( e ); + } setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); - emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); + if ( ! mBlockDeselect ) + emit highlightIncidence( 0, (MonthViewCell*)this, 0 ); + mBlockDeselect = false; } QString KNoScrollListBox::getWhatsThisText(QPoint p) { QListBoxItem* item = itemAt ( p ); if ( ! item ) { return i18n("Click in the cell\nto add an event!"); } return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(), KOPrefs::instance()->mWTshowDetails, KOPrefs::instance()->mWTshowCreated, KOPrefs::instance()->mWTshowChanged); } void KNoScrollListBox::keyPressEvent(QKeyEvent *e) { //qDebug("KNoScrollListBox::keyPressEvent "); switch(e->key()) { case Key_Right: if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(10,0); break; case Key_Left: if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton ) { e->ignore(); return; } scrollBy(-10,0); @@ -1081,67 +1086,66 @@ void MonthViewCell::defaultAction( QListBoxItem *item ) void MonthViewCell::showDay() { emit showDaySignal( date() ); } void MonthViewCell::newEvent() { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { mMonthView->setSelectedCell( this ); if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } } void MonthViewCell::contextMenu( QListBoxItem *item ) { mMonthView->setPopupCell( this ); if ( !item ) { mMonthView->showContextMenu( 0 ); return; } //selection( item ); //qApp->processEvents(); MonthViewItem *eventItem = static_cast<MonthViewItem *>( item ); Incidence *incidence = eventItem->incidence(); if ( incidence ) { + mBlockDeselect = true; mMonthView->showContextMenu( incidence ); - selection( item ); - doHighLight( incidence ); } } void MonthViewCell::selection( QListBoxItem *item ) { if ( !item ) { emit highlightIncidence( 0 , this, 0 ); return; } MonthViewItem * it = (static_cast<MonthViewItem *>( item )); emit highlightIncidence( it->incidence(), this, it->multiDay() ); mMonthView->setSelectedCell( this ); } void MonthViewCell::deHighLight() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->setHighlightedFalse() ) updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } } // returns true if no inc found bool MonthViewCell::doHighLight( Incidence * inc ) { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { if ( mitem->incidence() == inc ) { if ( mitem->setHighlighted( inc ) ) updateItem ( mitem ); |