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 | |
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 | ||||
-rw-r--r-- | korganizer/komonthview.h | 5 |
2 files changed, 67 insertions, 54 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 9f7db69..1ed288b 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -75,48 +75,74 @@ private: }; KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name) : QListBox(parent, name, WRepaintNoErase) { #ifndef DESKTOP_VERSION QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); #endif mWT = new KNOWhatsThis(this); resetOnFocusIn = true; + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } KNoScrollListBox::~KNoScrollListBox() { } void KNoScrollListBox::focusInEvent ( QFocusEvent * e ) { QListBox::focusInEvent ( e ); QListBoxItem * i = item ( 0 ); if ( i && resetOnFocusIn ) { 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) { 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); @@ -234,24 +260,25 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) : QListBoxItem() { mblockRepaint = true; setText( s ); mMultiday = 0; mIncidence = incidence; mDate = qd; mRecur = false; mAlarm = false; mReply = false; mInfo = false; + isWeekItem = KOPrefs::instance()->mMonthViewWeek; //qDebug("NEWWWWWWWWWWWWW "); } void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s) { setText( s ); mMultiday = 0; mIncidence = incidence; mDate = qd; mRecur = false; mAlarm = false; mReply = false; mInfo = false; @@ -371,25 +398,25 @@ void MonthViewItem::paint(QPainter *p) int MonthViewItem::height(const QListBox *lb) const { int ret = 10; if ( lb ) ret = lb->fontMetrics().lineSpacing()+1; return ret; } 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; if ( KOPrefs::instance()->mMonthShowIcons ) { if ( mInfo ) { x += size + 1; } if( mRecur ) { x += size+1; } if( mAlarm ) { @@ -406,26 +433,24 @@ int MonthViewItem::width(const QListBox *lb) const } if ( ! lb ) return 10; //qDebug("ret wid %d ", lb->width()); return lb->width(); } 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 ); //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain ); //mLabel->setLineWidth( 1 ); //mLabel->setAlignment( AlignCenter ); mLabel->setFlat( true ); mLabel->setFocusPolicy(NoFocus); //mItemList = new KNoScrollListBox( this ); setMinimumSize( 10, 10 ); setFrameStyle( QFrame::Panel | QFrame::Plain ); @@ -563,46 +588,51 @@ void MonthViewCell::startUpdateCell() if ( !isVisible() ){ return; } */ // qDebug("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() ) { 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 mToolTip.clear(); //qApp->processEvents(); #if 0 if ( !mHolidayString.isEmpty() ) { MonthViewItem *item = new MonthViewItem( 0, mDate, mHolidayString ); item->setPalette( mHolidayPalette ); insertItem( item ); mToolTip.append ( mHolidayString ); } #endif } 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; else if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly ) return; } if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) @@ -643,39 +673,33 @@ void MonthViewCell::insertEvent(Event *event) } else { if (event->doesFloat()) { text = event->summary(); mToolTipText += text; } else { text = KGlobal::locale()->formatTime(event->dtStart().time()); text += " " + event->summary(); 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(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); } else { pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat))); } @@ -697,55 +721,45 @@ void MonthViewCell::insertEvent(Event *event) #ifdef DESKTOP_VERSION Attendee *me = event->attendeeByMails(KOPrefs::instance()->mAdditionalMails, KOPrefs::instance()->email()); if ( me != 0 ) { if ( me->status() == Attendee::NeedsAction && me->RSVP()) item->setReply(true && multiday < 2); else item->setReply(false); } 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()) { text += KGlobal::locale()->formatTime(todo->dtDue().time()); text += " "; } } 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; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = todo->categories(); QString cat = categories.first(); if ( KOPrefs::instance()->mMonthViewUsesForegroundColor ) { pal = getPalette(); if (cat.isEmpty()) { pal.setColor(QColorGroup::Foreground,KOPrefs::instance()->mEventColor); } else { @@ -758,45 +772,39 @@ void MonthViewCell::insertTodo(Todo *todo) } else { pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat))); } } } else { pal = mStandardPalette ; } 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() { MonthViewItem *mitem = (MonthViewItem*) firstItem (); while ( mitem ) { mitem->setBlockRepaint( false ); updateItem ( mitem ); mitem = (MonthViewItem *)mitem->next(); } } void MonthViewCell::finishUpdateCell() { - while ( mCurrentAvailItem ) { - MonthViewItem *item = mCurrentAvailItem; - mCurrentAvailItem = (MonthViewItem *)item->next(); - mAvailItemList.append( item ); - takeItem ( item ); - } + #ifdef DESKTOP_VERSION if (mToolTip.count() > 0 ) { mToolTip.sort(); QToolTip::add(this,mToolTip.join("\n"),toolTipGroup(),""); } #endif sort(); //setMyPalette(); setMyPalette(); @@ -852,38 +860,42 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false mPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewOddColor.dark()); mPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewOddColor); mPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewOddColor); mNonPrimaryPalette.setColor(QColorGroup::Foreground,KOPrefs::instance()->mMonthViewEvenColor.dark()); mNonPrimaryPalette.setColor(QColorGroup::Base,KOPrefs::instance()->mMonthViewEvenColor); mNonPrimaryPalette.setColor(QColorGroup::Background,KOPrefs::instance()->mMonthViewEvenColor); } //updateCell(); } void MonthViewCell::enableScrollBars( bool enabled ) { + + return; if ( enabled ) { 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() ) + if ( ihei *3 > height() ) { setHScrollBarMode(QScrollView::AlwaysOff); - else + } + else { setHScrollBarMode(QScrollView::Auto); + } } else { setVScrollBarMode(QScrollView::Auto); setHScrollBarMode(QScrollView::Auto); } } else { setVScrollBarMode(QScrollView::AlwaysOff); setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { @@ -972,25 +984,24 @@ 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 ) { - static QListBoxItem * lastClicked = 0; if ( item == 0 ) { QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) ); emit newEventSignal( dt ); return; } /* if ( lastClicked ) if ( ! item ) { if ( lastClicked->listBox() != item->listBox() ) lastClicked->listBox()->clearSelection(); } */ @@ -1082,41 +1093,41 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name) KOWeekButton *label = new KOWeekButton( mMonthView ); label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //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 ); label->setFocusPolicy(NoFocus); label->setFont(bfont); connect( label, SIGNAL( selectWeekNum ( int )),this, SLOT( selectInternalWeekNum ( int )) ); label->setFlat(true); QWhatsThis::add(label,i18n("Click on the week number to\nshow week zoomed")); //label->setFrameStyle(QFrame::Panel|QFrame::Raised); //label->setLineWidth(1); //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 ); for( row = 0; row < mNumWeeks; ++row ) { for( col = 0; col < mDaysPerWeek; ++col ) { MonthViewCell *cell = new MonthViewCell( this, mMonthView ); mCells.insert( row * mDaysPerWeek + col, cell ); connect( cell, SIGNAL( defaultAction( Incidence * ) ), SLOT( defaultAction( Incidence * ) ) ); connect( cell, SIGNAL( newEventSignal( QDateTime ) ), @@ -1389,25 +1400,25 @@ void KOMonthView::showDates(const QDate &start, const QDate &) updateView(); } void KOMonthView::showEvents(QPtrList<Event>) { qDebug("KOMonthView::selectEvents is not implemented yet. "); } 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() { if ( !updatePossible ) return; //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); //QTime ti; //ti.start(); clearSelection(); @@ -1519,32 +1530,33 @@ void KOMonthView::updateView() //qDebug("KOMonthView::updateView() "); processSelectionChange(); // qDebug("---------------------------------------------------------------------+ "); (*cells)[0]->setFocus(); #endif //qDebug("update time %d ", ti.elapsed()); } 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() ) ); } } void KOMonthView::setKeyBFocus() { //qDebug("KOMonthView::setKeyBFocus() "); QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) ); } void KOMonthView::resizeEvent(QResizeEvent * e) { diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index e04cdf5..e962756 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -50,25 +50,26 @@ class KOWeekButton : public QPushButton public: KOWeekButton( QWidget *parent=0, const char *name=0 ) : QPushButton( parent, name) { connect( this, SIGNAL( clicked() ), SLOT( bottonClicked() )); mNumber = -1; } void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));} int getWeekNum() { return mNumber;} signals: void selectWeekNum ( int ); -private: +private: + void focusInEvent ( QFocusEvent * ){;} int mNumber; void keyPressEvent ( QKeyEvent * e ) { e->ignore(); } private slots : void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); } }; class KNoScrollListBox: public QListBox { @@ -113,24 +114,25 @@ class MonthViewItem: public QListBoxItem void setPalette(const QPalette &p) { mPalette = p; } QPalette palette() const { return mPalette; } Incidence *incidence() const { return mIncidence; } QDate incidenceDate() { return mDate; } protected: virtual void paint(QPainter *); virtual int height(const QListBox *) const; virtual int width(const QListBox *) const; private: + bool isWeekItem; bool mblockRepaint; int mMultiday; bool mRecur; bool mAlarm; bool mReply; bool mInfo; QPalette mPalette; QDate mDate; Incidence *mIncidence; }; @@ -186,25 +188,24 @@ class MonthViewCell : public KNoScrollListBox public slots: void showDay(); protected slots: void defaultAction( QListBoxItem * ); void contextMenu( QListBoxItem * ); void selection( QListBoxItem * ); void cellClicked( QListBoxItem * ); void newEvent(); private: - MonthViewItem* mCurrentAvailItem; QPtrList <MonthViewItem> mAvailItemList; KOMonthView *mMonthView; int currentPalette; QDate mDate; bool mPrimary; bool mHoliday; QString mHolidayString; //QLabel *mLabel; QPushButton *mLabel; //QListBox *mItemList; |