From e3b935f4e24086117213662e670ab26cb2ad8822 Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 25 Mar 2005 05:47:45 +0000 Subject: mal sehn... --- diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp index 6438c9a..0cb767f 100644 --- a/korganizer/kdatenavigator.cpp +++ b/korganizer/kdatenavigator.cpp @@ -119,7 +119,8 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name ) mySizeHint = sizeHintTwoButtons(); myFullSizeHint = sizeHintTwoButtons( 4 ); mFontChanged = false; - resize ( 0,0 ); + resize ( 3,3 ); + } void KDateNavigator::changeFont ( QFont fo ) { diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp index 050bfb9..38cfda7 100644 --- a/korganizer/komonthview.cpp +++ b/korganizer/komonthview.cpp @@ -194,6 +194,7 @@ void KNoScrollListBox::mousePressEvent(QMouseEvent *e) MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) : QListBoxItem() { + mblockRepaint = true; setText( s ); mMultiday = 0; mIncidence = incidence; @@ -202,10 +203,28 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s) mAlarm = false; mReply = false; mInfo = false; + //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; + //qDebug("recucleeeeeeeeeeeeeeeee "); } void MonthViewItem::paint(QPainter *p) { + if ( mblockRepaint ) { + //qDebug("block "); + return; + } + //qDebug("NON block "); #if QT_VERSION >= 0x030000 bool sel = isSelected(); #else @@ -353,12 +372,13 @@ int MonthViewItem::width(const QListBox *lb) const MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) - : 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 ); @@ -366,10 +386,10 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) //mLabel->setAlignment( AlignCenter ); mLabel->setFlat( true ); mLabel->setFocusPolicy(NoFocus); - mItemList = new KNoScrollListBox( this ); - mItemList->setMinimumSize( 10, 10 ); - mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain ); - mItemList->setLineWidth( 1 ); + //mItemList = new KNoScrollListBox( this ); + setMinimumSize( 10, 10 ); + setFrameStyle( QFrame::Panel | QFrame::Plain ); + setLineWidth( 1 ); //topLayout->addWidget( mItemList ); mLabel->raise(); // QColor( 0,0,255 ) QColor( 160,1600,255 ) @@ -380,16 +400,16 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par ) updateConfig(); //connect( mLabel, SIGNAL( clicked( )), SLOT( newEvent() )); connect( mLabel, SIGNAL( clicked( )), SLOT( showDay() )); - connect( mItemList, SIGNAL( doubleClicked( QListBoxItem *) ), + connect( this , SIGNAL( doubleClicked( QListBoxItem *) ), SLOT( defaultAction( QListBoxItem * ) ) ); - connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *, + connect( this, SIGNAL( rightButtonPressed( QListBoxItem *, const QPoint &) ), SLOT( contextMenu( QListBoxItem * ) ) ); - connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ), + connect( this, SIGNAL( highlighted( QListBoxItem *) ), SLOT( selection( QListBoxItem * ) ) ); - connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), + connect( this, SIGNAL( clicked( QListBoxItem * ) ), SLOT( cellClicked( QListBoxItem * ) ) ); - connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ), + connect( this, SIGNAL( clicked( QListBoxItem * ) ), SLOT( selection( QListBoxItem * ) ) ); } #ifdef DESKTOP_VERSION @@ -422,17 +442,28 @@ void MonthViewCell::setPrimary( bool primary ) } void MonthViewCell::setMyPalette() { - + if ( mHoliday) { + if ( currentPalette == 1 ) return; mLabel->setPalette( QPalette ( mHolidayPalette.color( QPalette::Normal,QColorGroup::Base),mHolidayPalette.color(QPalette::Normal,QColorGroup::Base ) )); - mItemList->setPalette( mHolidayPalette ); + setPalette( mHolidayPalette ); + //mLabel->setPalette( mHolidayPalette ); + currentPalette = 1; + } else { if ( mPrimary ) { + if ( currentPalette == 2 ) return; mLabel->setPalette( QPalette ( mPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); - mItemList->setPalette( mPrimaryPalette ); + //mLabel->setPalette( mPrimaryPalette ); + setPalette( mPrimaryPalette ); + currentPalette = 2; + } else { - mItemList->setPalette( mNonPrimaryPalette ); - mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); + if ( currentPalette == 3 ) return; + setPalette( mNonPrimaryPalette ); + mLabel->setPalette( QPalette ( mNonPrimaryPalette.color( QPalette::Normal,QColorGroup::Base),mNonPrimaryPalette.color(QPalette::Normal,QColorGroup::Base ) )); + //mLabel->setPalette( mNonPrimaryPalette );; + currentPalette = 3; } } //QPalette pal = palette(); @@ -471,20 +502,18 @@ void MonthViewCell::setHoliday( const QString &holiday ) setHoliday( true ); } } -void MonthViewCell::keyPressEvent ( QKeyEvent * e ) -{ - - e->ignore(); - -} void MonthViewCell::startUpdateCell() { - mItemList->setFocusPolicy(NoFocus); + setFocusPolicy(NoFocus); if ( !mMonthView->isUpdatePossible() ) return; - + MonthViewItem *mitem = (MonthViewItem*) firstItem (); + while ( mitem ) { + mitem->setBlockRepaint( true ); + mitem = (MonthViewItem *)mitem->next(); + } /* if ( !isVisible() ){ return; @@ -494,29 +523,33 @@ void MonthViewCell::startUpdateCell() 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 ); + setLineWidth( 3 ); } else { - mItemList->setLineWidth( 1 ); + setLineWidth( 1 ); } - mItemList->clear(); + mCurrentAvailItem = (MonthViewItem*) firstItem (); + //clear(); #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 ); - mItemList->insertItem( item ); + insertItem( item ); mToolTip.append ( mHolidayString ); } +#endif } void MonthViewCell::insertEvent(Event *event) { QString mToolTipText; - mItemList->setFocusPolicy(WheelFocus); + bool insertNewItem = false; + setFocusPolicy(WheelFocus); if ( !(event->doesRecur() == Recurrence::rNone) ) { if ( !KOPrefs::instance()->mMonthDailyRecur && event->doesRecur() == Recurrence::rDaily ) return; @@ -528,7 +561,7 @@ void MonthViewCell::insertEvent(Event *event) if ( event->isHoliday()) { setHoliday( true ); if ( mDate.dayOfWeek() == 7 ) - mItemList->setLineWidth( 3 ); + setLineWidth( 3 ); } QString text; int multiday = 0;// 1 = start, 2 = midddle, 3 = end day @@ -573,8 +606,22 @@ void MonthViewCell::insertEvent(Event *event) mToolTipText += KGlobal::locale()->formatTime(event->dtStart().time()) +"-"+KGlobal::locale()->formatTime(event->dtEnd().time())+" " + event->summary(); } } - - MonthViewItem *item = new MonthViewItem( event, mDate, text ); + MonthViewItem *item ; + if ( mCurrentAvailItem ) { + item = mCurrentAvailItem; + mCurrentAvailItem = (MonthViewItem*) item->next(); + 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 ); + } + } QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { QStringList categories = event->categories(); @@ -614,12 +661,14 @@ void MonthViewCell::insertEvent(Event *event) item->setReply(false); #endif item->setMultiDay( multiday ); - mItemList->insertItem( item ); + if ( insertNewItem) + insertItem( item ); mToolTip.append( mToolTipText ); } void MonthViewCell::insertTodo(Todo *todo) { - mItemList->setFocusPolicy(WheelFocus); + bool insertNewItem = false; + setFocusPolicy(WheelFocus); QString text; if (todo->hasDueDate()) { if (!todo->doesFloat()) { @@ -628,8 +677,23 @@ void MonthViewCell::insertTodo(Todo *todo) } } text += todo->summary(); - - MonthViewItem *item = new MonthViewItem( todo, mDate, text ); + MonthViewItem *item ; + if ( mCurrentAvailItem ) { + item = mCurrentAvailItem; + mCurrentAvailItem = (MonthViewItem*) item->next(); + 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 ); + } + } + //MonthViewItem *item = new MonthViewItem( todo, mDate, text ); //item->setPalette( mStandardPalette ); QPalette pal; if (KOPrefs::instance()->mMonthViewUsesCategoryColor) { @@ -658,18 +722,36 @@ void MonthViewCell::insertTodo(Todo *todo) item->setRecur( todo->recurrence()->doesRecur() ); item->setAlarm( todo->isAlarmEnabled() ); item->setMoreInfo( todo->description().length() > 0 ); - mItemList->insertItem( item ); + if ( insertNewItem) + 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 - mItemList->sort(); + sort(); //setMyPalette(); setMyPalette(); QString text; @@ -746,52 +828,59 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false void MonthViewCell::enableScrollBars( bool enabled ) { if ( enabled ) { - //mItemList->setVScrollBarMode(QScrollView::Auto); - mItemList->setHScrollBarMode(QScrollView::Auto); - QListBoxItem *fi = mItemList->firstItem (); + + QListBoxItem *fi = firstItem (); if (fi ) { - int hei = mItemList->numRows () * fi->height(mItemList); - if ( hei < height() - mItemList->horizontalScrollBar()->height () ) - mItemList->setVScrollBarMode(QScrollView::AlwaysOff); + int ihei = fi->height( this ); + int hei = numRows () * ihei; + if ( hei < height() - horizontalScrollBar()->height () ) + setVScrollBarMode(QScrollView::AlwaysOff); else - mItemList->setVScrollBarMode(QScrollView::Auto); + setVScrollBarMode(QScrollView::Auto); + if ( ihei *3 > height() ) + setHScrollBarMode(QScrollView::AlwaysOff); + else + setHScrollBarMode(QScrollView::Auto); + } else { + setVScrollBarMode(QScrollView::Auto); + setHScrollBarMode(QScrollView::Auto); } } else { - mItemList->setVScrollBarMode(QScrollView::AlwaysOff); - mItemList->setHScrollBarMode(QScrollView::AlwaysOff); + setVScrollBarMode(QScrollView::AlwaysOff); + setHScrollBarMode(QScrollView::AlwaysOff); } } Incidence *MonthViewCell::selectedIncidence() { - int index = mItemList->currentItem(); + int index = currentItem(); if ( index < 0 ) return 0; - MonthViewItem *item = - static_cast( mItemList->item( index ) ); + MonthViewItem *mitem = + static_cast( item( index ) ); - if ( !item ) return 0; + if ( !mitem ) return 0; - return item->incidence(); + return mitem->incidence(); } QDate MonthViewCell::selectedIncidenceDate() { QDate qd; - int index = mItemList->currentItem(); + int index = currentItem(); if ( index < 0 ) return qd; - MonthViewItem *item = - static_cast( mItemList->item( index ) ); + MonthViewItem *mitem = + static_cast( item( index ) ); - if ( !item ) return qd; + if ( !mitem ) return qd; - return item->incidenceDate(); + return mitem->incidenceDate(); } void MonthViewCell::deselect() { - mItemList->clearSelection(); + clearSelection(); enableScrollBars( false ); // updateCell(); } @@ -806,16 +895,18 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e ) return; //qDebug("++++++++++++++MonthViewCell::resizeEvent %d %d ", width(), height()); deselect(); - int size = height() - mLabel->height() - 2; + int size = height() - mLabel->height() - lineWidth()-1; + //qDebug("LW %d ", lineWidth()); if ( size > 0 ) - mItemList->verticalScrollBar()->setMaximumHeight( size ); - size = width() - mLabel->width() -2; + verticalScrollBar()->setMaximumHeight( size ); + size = width() - mLabel->width() -lineWidth()-1; if ( size > 0 ) - mItemList->horizontalScrollBar()->setMaximumWidth( size ); - mLabel->move( width()-mItemList->lineWidth() - mLabel->width(), height()-mItemList->lineWidth() - mLabel->height() ); + horizontalScrollBar()->setMaximumWidth( size ); + mLabel->move( width()-lineWidth() - mLabel->width(), height()-lineWidth() - mLabel->height() ); //mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2); - mItemList->resize ( width(), height () ); - + // mItemList->resize ( width(), height () ); + if ( e ) + KNoScrollListBox::resizeEvent ( e ); } void MonthViewCell::defaultAction( QListBoxItem *item ) @@ -1260,6 +1351,7 @@ void KOMonthView::updateView() if ( !updatePossible ) return; + //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU "); //QTime ti; //ti.start(); clearSelection(); @@ -1356,6 +1448,10 @@ void KOMonthView::updateView() (*cells)[i]->finishUpdateCell(); } processSelectionChange(); + qApp->processEvents(); + for( i = 0; i < timeSpan+1; ++i ) { + (*cells)[i]->repaintfinishUpdateCell(); + } (*cells)[0]->setFocus(); diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h index 89912e0..b997c1a 100644 --- a/korganizer/komonthview.h +++ b/korganizer/komonthview.h @@ -93,12 +93,13 @@ class MonthViewItem: public QListBoxItem { public: MonthViewItem( Incidence *, QDate qd, const QString & title ); - + void recycle( Incidence *incidence, QDate qd, const QString & s); void setRecur(bool on) { mRecur = on; } void setAlarm(bool on) { mAlarm = on; } void setReply(bool on) { mReply = on; } void setMoreInfo(bool on) { mInfo = on; } void setMultiDay(int type) { mMultiday = type; } + void setBlockRepaint(bool on) { mblockRepaint = on; } void setPalette(const QPalette &p) { mPalette = p; } @@ -113,6 +114,7 @@ class MonthViewItem: public QListBoxItem virtual int width(const QListBox *) const; private: + bool mblockRepaint; int mMultiday; bool mRecur; bool mAlarm; @@ -128,11 +130,12 @@ class MonthViewItem: public QListBoxItem class KOMonthView; -class MonthViewCell : public QWidget +class MonthViewCell : public KNoScrollListBox { Q_OBJECT public: MonthViewCell(KOMonthView *,QWidget* ); + ~MonthViewCell() {mAvailItemList.setAutoDelete( true );} void setDate( const QDate & ); QDate date() const; @@ -146,6 +149,7 @@ class MonthViewCell : public QWidget void updateCell(); void startUpdateCell(); void finishUpdateCell(); + void repaintfinishUpdateCell(); void insertEvent(Event *); void insertTodo(Todo *); @@ -183,7 +187,10 @@ public slots: void newEvent(); private: + MonthViewItem* mCurrentAvailItem; + QPtrList mAvailItemList; KOMonthView *mMonthView; + int currentPalette; QDate mDate; bool mPrimary; @@ -192,7 +199,7 @@ public slots: //QLabel *mLabel; QPushButton *mLabel; - QListBox *mItemList; + //QListBox *mItemList; #ifdef DESKTOP_VERSION static QToolTipGroup *mToolTipGroup; #endif @@ -204,7 +211,6 @@ public slots: QPalette mNonPrimaryPalette; void setMyPalette(); QPalette getPalette (); - void keyPressEvent ( QKeyEvent * ) ; }; diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp index 94d74f1..c6e76c4 100644 --- a/korganizer/koviewmanager.cpp +++ b/korganizer/koviewmanager.cpp @@ -208,6 +208,7 @@ void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) if ( view == 0 ) return; } + bool callupdate = !(view == mCurrentView); bool full = fullScreen; if(view == mCurrentView && view != mWhatsNextView ) { if ( mCurrentAgendaView < 0 ) @@ -229,7 +230,7 @@ void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen ) //raiseCurrentView( full ); mMainView->processIncidenceSelection( 0 ); //mMainView->updateView(); - raiseCurrentView( full, true ); + raiseCurrentView( full, callupdate ); mMainView->adaptNavigationUnits(); } -- cgit v0.9.0.2