summaryrefslogtreecommitdiffabout
path: root/korganizer/komonthview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/komonthview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp222
1 files changed, 159 insertions, 63 deletions
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
@@ -424,15 +444,26 @@ 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 );
+ 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
+ setVScrollBarMode(QScrollView::Auto);
+ if ( ihei *3 > height() )
+ setHScrollBarMode(QScrollView::AlwaysOff);
else
- mItemList->setVScrollBarMode(QScrollView::Auto);
+ 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<MonthViewItem *>( mItemList->item( index ) );
+ MonthViewItem *mitem =
+ static_cast<MonthViewItem *>( 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<MonthViewItem *>( mItemList->item( index ) );
+ MonthViewItem *mitem =
+ static_cast<MonthViewItem *>( 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();