author | zautrix <zautrix> | 2005-04-04 20:24:30 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-04 20:24:30 (UTC) |
commit | c408fcb55de18d1e3e1d20803c3885e3074cfaa4 (patch) (side-by-side diff) | |
tree | 092f6e385210a9fa7bd625c2e0cae3ceba68f513 /korganizer/komonthview.cpp | |
parent | 8e7f4812c4ad239b6a17cce8aa84c00274ced4df (diff) | |
download | kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.zip kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.gz kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.bz2 |
month view fixes
-rw-r--r-- | korganizer/komonthview.cpp | 116 |
1 files changed, 64 insertions, 52 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9f7db69..1ed288b 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -83,8 +83,10 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mWT = new KNOWhatsThis(this); resetOnFocusIn = true; + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() { @@ -99,16 +101,40 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) setCurrentItem( i ); setSelected ( 0, true ); } 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 ) { int i = currentItem (); if ( i >= 0 ) { setSelected ( i, false ); } - QListBox::focusOutEvent ( e ); + QListBox::focusOutEvent ( e ); + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } QString KNoScrollListBox::getWhatsThisText(QPoint p) { @@ -242,8 +268,9 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) mRecur = false; mAlarm = false; mReply = false; mInfo = false; + isWeekItem = KOPrefs::instance()->mMonthViewWeek; //qDebug("NEWWWWWWWWWWWWW "); } void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) { @@ -379,9 +406,9 @@ int MonthViewItem::height(const QListBox *lb) const int MonthViewItem::width(const QListBox *lb) const { - if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) { + if( KOPrefs::instance()->mEnableMonthScroll || isWeekItem ) { int size = PIXMAP_SIZE; if ( QApplication::desktop()->width() < 300 ) size = 3; int x = 1; @@ -414,10 +441,8 @@ int MonthViewItem::width(const QListBox *lb) const MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) : KNoScrollListBox( par ), mMonthView( parent ) { - - mCurrentAvailItem = 0; //QVBoxLayout *topLayout = new QVBoxLayout( this ); currentPalette = 0; // mLabel = new QLabel( this );QPushButton mLabel = new QPushButton( this ); @@ -571,10 +596,16 @@ void MonthViewCell::startUpdateCell() setLineWidth( 3 ); } else { setLineWidth( 1 ); } - mCurrentAvailItem = (MonthViewItem*) firstItem (); - //clear(); + MonthViewItem* CurrentAvailItem = (MonthViewItem*) firstItem (); + //clear(); + while ( CurrentAvailItem ) { + MonthViewItem *item = CurrentAvailItem; + CurrentAvailItem = (MonthViewItem *)item->next(); + mAvailItemList.append( item ); + takeItem ( item ); + } #ifdef DESKTOP_VERSION QToolTip::remove(this); #endif @@ -592,9 +623,8 @@ void MonthViewCell::startUpdateCell() void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; - bool insertNewItem = false; setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; @@ -651,23 +681,17 @@ void MonthViewCell::insertEvent(Event *event) mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } MonthViewItem *item ; - if ( mCurrentAvailItem ) { - item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem*) item->next(); + + if ( mAvailItemList.count() ) { + item = mAvailItemList.first(); + mAvailItemList.remove( item ); item->recycle( event, mDate, text ); } else { - if ( mAvailItemList.count() ) { - item = mAvailItemList.first(); - mAvailItemList.remove( item ); - item->recycle( event, mDate, text ); - insertNewItem = true; - } else { - insertNewItem = true; - item = new MonthViewItem( event, mDate, text ); - } + item = new MonthViewItem( event, mDate, text ); } + QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); QString cat = categories.first(); @@ -705,15 +729,13 @@ void MonthViewCell::insertEvent(Event *event) } else item->setReply(false); #endif item->setMultiDay( multiday ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( mToolTipText ); } void MonthViewCell::insertTodo(Todo *todo) { - bool insertNewItem = false; setFocusPolicy(WheelFocus); QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { @@ -722,22 +744,14 @@ void MonthViewCell::insertTodo(Todo *todo) } } text += todo->summary(); MonthViewItem *item ; - if ( mCurrentAvailItem ) { - item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem*) item->next(); + if ( mAvailItemList.count() ) { + item = mAvailItemList.first(); + mAvailItemList.remove( item ); item->recycle( todo, mDate, text ); } else { - if ( mAvailItemList.count() ) { - item = mAvailItemList.first(); - mAvailItemList.remove( item ); - item->recycle( todo, mDate, text ); - insertNewItem = true; - } else { - insertNewItem = true; - item = new MonthViewItem( todo, mDate, text ); - } + item = new MonthViewItem( todo, mDate, text ); } //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); QPalette pal; @@ -766,10 +780,9 @@ void MonthViewCell::insertTodo(Todo *todo) item->setPalette( pal ); item->setRecur( todo->recurrence()->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); - if ( insertNewItem) - insertItem( item ); + insertItem( item ); mToolTip.append( text ); } void MonthViewCell::repaintfinishUpdateCell() { @@ -781,14 +794,9 @@ void MonthViewCell::repaintfinishUpdateCell() } } void MonthViewCell::finishUpdateCell() { - while ( mCurrentAvailItem ) { - MonthViewItem *item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem *)item->next(); - mAvailItemList.append( item ); - takeItem ( item ); - } + #ifdef DESKTOP_VERSION if (mToolTip.count() > 0 ) { @@ -860,8 +868,10 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false } void MonthViewCell::enableScrollBars( bool enabled ) { + + return; if ( enabled ) { QListBoxItem *fi = firstItem (); if (fi ) { int ihei = fi->height( this ); @@ -870,12 +880,14 @@ void MonthViewCell::enableScrollBars( bool enabled ) setVScrollBarMode(QScrollView::AlwaysOff); } else setVScrollBarMode(QScrollView::Auto); - if ( ihei *3 > height() ) + if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); - else + } + else { setHScrollBarMode(QScrollView::Auto); + } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } @@ -980,9 +992,8 @@ void MonthViewCell::newEvent() emit newEventSignal( dt ); } void MonthViewCell::cellClicked( QListBoxItem *item ) { - static QListBoxItem * lastClicked = 0; if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; @@ -1090,9 +1101,9 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) //label->setAlignment(AlignCenter); mWeekLabels.insert( i, label ); } mWeekLabels[mNumWeeks]->setText( i18n("W")); - mWeekLabels[0]->setFocusPolicy(WheelFocus); + mWeekLabels[mNumWeeks]->setFocusPolicy(WheelFocus); QWhatsThis::add(mWeekLabels[mNumWeeks],i18n("Click on this to\nselect week number")); for( i = 0; i < 1+1; i++ ) { KOWeekButton *label = new KOWeekButton( mWeekView ); @@ -1106,9 +1117,9 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) //label->setAlignment(AlignCenter); mWeekLabelsW.insert( i, label ); } mWeekLabelsW[1]->setText( i18n("W")); - mWeekLabelsW[0]->setFocusPolicy(WheelFocus); + mWeekLabelsW[1]->setFocusPolicy(WheelFocus); int row, col; mCells.resize( mNumCells ); @@ -1397,9 +1408,9 @@ void KOMonthView::showEvents(QPtrList<Event>) void KOMonthView::changeEventDisplay(Event *, int) { // this should be re-written to be much more efficient, but this // quick-and-dirty-hack gets the job done for right now. - qDebug("KOMonthView::changeEventDisplay "); + //qDebug("KOMonthView::changeEventDisplay "); updateView(); } void KOMonthView::updateView() @@ -1527,16 +1538,17 @@ void KOMonthView::updateView() } void KOMonthView::setKeyBoardFocus() { + //qDebug("KOMonthView::setKeyBoardFocus() "); bool shootAgain = false; if ( mShowWeekView ) { - shootAgain = !mWeekLabelsW[0]->hasFocus(); - mWeekLabelsW[0]->setFocus(); + shootAgain = !mWeekLabelsW[1]->hasFocus(); + mWeekLabelsW[1]->setFocus(); } else { - shootAgain = !mWeekLabels[0]->hasFocus(); - mWeekLabels[0]->setFocus(); + shootAgain = !mWeekLabels[mNumWeeks]->hasFocus(); + mWeekLabels[mNumWeeks]->setFocus(); } if ( shootAgain ) { QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) ); } |