summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kdatenavigator.cpp3
-rw-r--r--korganizer/komonthview.cpp222
-rw-r--r--korganizer/komonthview.h14
-rw-r--r--korganizer/koviewmanager.cpp3
4 files changed, 173 insertions, 69 deletions
diff --git a/korganizer/kdatenavigator.cpp b/korganizer/kdatenavigator.cpp
index 6438c9a..0cb767f 100644
--- a/korganizer/kdatenavigator.cpp
+++ b/korganizer/kdatenavigator.cpp
@@ -74,97 +74,98 @@ KDateNavigator::KDateNavigator( QWidget *parent, const char *name )
// get the day of the week on the first day
QDate dayone(m_MthYr.year(), m_MthYr.month(), 1);
m_fstDayOfWk = dayone.dayOfWeek();
int i;
// Set up the heading fields.
for( i = 0; i < 7; i++ ) {
headings[i] = new QLabel("",this);
//headings[i]->setFont(QFont("Arial", 10, QFont::Bold));
headings[i]->setAlignment(AlignCenter);
headings[i]->installEventFilter(this);
topLayout->addWidget(headings[i],1,i+1);
}
// Create the weeknumber labels
for( i = 0; i < 6; i++ ) {
weeknos[i] = new QLabel(this);
weeknos[i]->setAlignment(AlignCenter);
//weeknos[i]->setFont(QFont("Arial", 10));
if(!m_bShowWeekNums) {
weeknos[i]->hide();
}
weeknos[i]->installEventFilter(this);
topLayout->addWidget(weeknos[i],i+2,0);
}
daymatrix = new KODayMatrix( this, "KDateNavigator::DayMatrix");
daymatrix->setFrameStyle(QFrame::Panel|QFrame::Sunken);
daymatrix->setLineWidth(1);
connect( daymatrix, SIGNAL( selected( const KCal::DateList & ) ),
SIGNAL( datesSelected( const KCal::DateList & ) ) );
connect( daymatrix, SIGNAL( eventDropped( Event * ) ),
SIGNAL( eventDropped( Event * ) ) );
topLayout->addMultiCellWidget(daymatrix,2,7,1,7);
// read settings from configuration file.
updateConfig();
enableRollover(FollowMonth);
mySizeHint = sizeHintTwoButtons();
myFullSizeHint = sizeHintTwoButtons( 4 );
mFontChanged = false;
- resize ( 0,0 );
+ resize ( 3,3 );
+
}
void KDateNavigator::changeFont ( QFont fo )
{
setFont( fo );
mNavigatorBar->resetFont( fo );
}
QFont KDateNavigator::yourFontHint( QSize si , bool *b)
{
QFont fo = KOPrefs::instance()->mDateNavigatorFont;
*b = false;
int fontPoint = fo.pointSize();
while ( fontPoint > 5 ) {
--fontPoint;
fo.setPointSize( fontPoint );
setFont( fo );
mFontChanged = true;
mNavigatorBar->resetFont( fo );
QSize sh = sizeHintTwoButtons( 2 );
//qDebug("fp %d %d %d %d %d", fontPoint, si.width() , sh.width() , si.height() , sh.height() );
if ( si.width() > sh.width() && si.height() > sh.height()) {
if ( si.width() / sh.width() == 1 ) {
if ( si.width() < sizeHintTwoButtons( 4 ).width())
continue;
}
*b = true;
//qDebug("fooooooooooooooooooooooouuuuund ");
break;
}
}
//qDebug("returnnnnnnnnnnnnnnnnnnn %d", fo.pointSize() );
return fo;
}
QSize KDateNavigator::sizeHint() const
{
QFontMetrics fm ( font() );
QSize day = daymatrix->sizeHint();
QSize nav = mNavigatorBar->sizeHint();
int wid = fm.width( "30") + day.width()+3;
int hei = fm.height() +day.height()+nav.height()+2;
if ( wid < nav.width() )
wid = nav.width() ;
//qDebug("KDateNavigator+++++++++++++ %d %d", wid , hei);
return QSize ( wid, hei );
}
QSize KDateNavigator::sizeHintTwoButtons( int butnum ) const
{
QFontMetrics fm ( font() );
QSize day = daymatrix->sizeHint();
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 050bfb9..38cfda7 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -149,108 +149,127 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
break;
case Key_I:
QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
e->ignore();
break;
case Key_Shift:
emit shiftDown();
break;
default:
e->ignore();
break;
}
}
void KNoScrollListBox::oneDown()
{
setCurrentItem((currentItem()+1)%count());
if(!itemVisible(currentItem())) {
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
switch(e->key()) {
case Key_Shift:
emit shiftUp();
break;
default:
break;
}
}
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
QListBox::mousePressEvent(e);
if(e->button() == RightButton) {
emit rightClick();
}
}
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;
+ //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
bool sel = selected();
#endif
if (KOPrefs::instance()->mMonthViewUsesCategoryColor)
{
p->setBackgroundColor( palette().color( QPalette::Normal, \
sel ? QColorGroup::Highlight : QColorGroup::Background ) );
p->eraseRect( 0, 0, listBox()->maxItemWidth(), height( listBox() ) );
}
int x = 1;
//int y = 3;//(height() - mRecurPixmap.height()) /2;
int size = PIXMAP_SIZE;
if ( QApplication::desktop()->width() < 300 )
size = 3;
int heihei = height( listBox () );
int y = (heihei - size -1 ) /2;
if ( KOPrefs::instance()->mMonthShowIcons ) {
if ( mInfo ) {
p->fillRect ( x, y,size,size, Qt::darkGreen );
x += size + 1;
}
if ( mRecur ) {
p->fillRect ( x, y,size,size, Qt::blue );
x += size + 1;
}
if ( mAlarm ) {
p->fillRect ( x, y,size,size, Qt::red );
x += size + 1;
}
if ( mReply ) {
p->fillRect ( x, y,size,size, Qt::yellow );
x += size + 1;
}
}
if ( mMultiday ) {
int yyy = y+(size/2);
int sizeM = size+2;
p->setBrush( QBrush::SolidPattern );
p->drawLine ( x+1, yyy, x +sizeM +sizeM/2-1, yyy ) ;
if ( mMultiday == 2 || mMultiday == 3 ) {
QPointArray pa ( 3 );
pa.setPoint (0, x, yyy );
pa.setPoint (1, x+sizeM/2, yyy+sizeM/2 );
@@ -308,559 +327,631 @@ void MonthViewItem::paint(QPainter *p)
p->drawLine( x, heihei/2-1 ,x+wid, heihei/2-1 );
}
}
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 ) {
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 ) {
x += size+1;
}
if( mReply ) {
x += size+1;
}
}
if( mMultiday ) {
x += size+1+2+size/2;
}
return( x + lb->fontMetrics().width( text() ) + 1 );
}
if ( ! lb )
return 10;
//qDebug("ret wid %d ", lb->width());
return lb->width();
}
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 );
//mLabel->setLineWidth( 1 );
//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 )
mStandardPalette = palette();
mStandardPalette.setColor(QColorGroup::Base, mStandardPalette.color( QPalette::Normal, QColorGroup::Background ) );
enableScrollBars( false );
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
QToolTipGroup *MonthViewCell::toolTipGroup()
{
if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
return mToolTipGroup;
}
#endif
void MonthViewCell::setDate( const QDate &date )
{
// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
mDate = date;
//resizeEvent( 0 );
}
QDate MonthViewCell::date() const
{
return mDate;
}
void MonthViewCell::setPrimary( bool primary )
{
mPrimary = primary;
//setMyPalette();
}
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();
//mLabel->setPalette( QPalette ( pal.color( QPalette::Normal,QColorGroup::Base),pal.color(QPalette::Normal,QColorGroup::Base ) ));
}
QPalette MonthViewCell::getPalette ()
{
if ( !KOPrefs::instance()->mMonthViewUsesDayColors )
return mStandardPalette;
if ( mHoliday) {
return mHolidayPalette ;
} else {
if ( mPrimary ) {
return mPrimaryPalette ;
}
}
return mNonPrimaryPalette;
}
bool MonthViewCell::isPrimary() const
{
return mPrimary;
}
void MonthViewCell::setHoliday( bool holiday )
{
mHoliday = holiday;
//setMyPalette();
}
void MonthViewCell::setHoliday( const QString &holiday )
{
mHolidayString = holiday;
if ( !holiday.isEmpty() ) {
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;
}
*/
// 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() ) {
- 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;
else
if ( !KOPrefs::instance()->mMonthWeeklyRecur && event->doesRecur() == Recurrence::rWeekly )
return;
}
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
if (event->isMultiDay()) {
QString prefix = "<->";multiday = 2;
QString time;
if ( event->doesRecur() ) {
if ( event->recursOn( mDate) ) {
prefix ="->" ;multiday = 1;
}
else {
int days = event->dtStart().date().daysTo ( event->dtEnd().date() );
if ( event->recursOn( mDate.addDays( -days)) ) {
prefix ="<-" ;multiday = 3;
}
}
} else {
if (mDate == event->dtStart().date()) {
prefix ="->" ;multiday = 1;
} else if (mDate == event->dtEnd().date()) {
prefix ="<-" ;multiday = 3;
}
}
if ( !event->doesFloat() ) {
if ( mDate == event->dtStart().date () )
time = KGlobal::locale()->formatTime(event->dtStart().time())+" ";
else if ( mDate == event->dtEnd().date () )
time = KGlobal::locale()->formatTime(event->dtEnd().time())+" ";
}
text = time + event->summary();
mToolTipText += prefix + text;
} 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 = 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();
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)));
}
} else {
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
} else {
pal = QPalette(*(KOPrefs::instance()->categoryColor(cat)), *(KOPrefs::instance()->categoryColor(cat)));
}
}
} else {
pal = mStandardPalette ;
}
item->setPalette( pal );
item->setRecur( event->recurrence()->doesRecur() );
item->setAlarm( event->isAlarmEnabled() && multiday < 2 );
item->setMoreInfo( event->description().length() > 0 );
#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 );
- 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()) {
text += KGlobal::locale()->formatTime(todo->dtDue().time());
text += " ";
}
}
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) {
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 {
pal.setColor(QColorGroup::Foreground, *(KOPrefs::instance()->categoryColor(cat)));
}
} else {
if (cat.isEmpty()) {
pal = QPalette(KOPrefs::instance()->mEventColor, KOPrefs::instance()->mEventColor);
} 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 );
- 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;
bool smallDisplay = QApplication::desktop()->width() < 320 && KOPrefs::instance()->mMonthViewSatSunTog;
if ( KOPrefs::instance()->mMonthViewWeek || KOGlobals::self()->calendarSystem()->day( mDate ) == 1 || (mDate.dayOfWeek() == 7 && !smallDisplay ) || KOPrefs::instance()->mMonthShowShort) {
text = KOGlobals::self()->calendarSystem()->monthName( mDate, true ) + " ";
mLabel->resize( mLabelBigSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
} else {
mLabel->resize( mLabelSize );
text += QString::number( KOGlobals::self()->calendarSystem()->day(mDate) );
}
mLabel->setText( text );
resizeEvent( 0 );
}
void MonthViewCell::updateCell()
{
//qDebug("MonthViewCell::updateCell() ");
if ( !mMonthView->isUpdatePossible() )
return;
startUpdateCell();
//mLabel->setMaximumWidth( width() - mItemList->lineWidth()*2);
QPtrList<Event> events = mMonthView->calendar()->events( mDate, true );
Event *event;
for( event = events.first(); event; event = events.next() ) { // for event
insertEvent(event);
}
// insert due todos
QPtrList<Todo> todos = mMonthView->calendar()->todos( mDate );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
insertTodo( todo );
}
finishUpdateCell();
// if ( isVisible())
//qApp->processEvents();
}
void MonthViewCell::updateConfig( bool bigFont ) // = false
{
if ( bigFont ) {
QFont fo = KOPrefs::instance()->mMonthViewFont;
int ps = fo.pointSize() + 2;
if ( ps < 18 )
ps += 2;
fo.setPointSize( ps );
setFont( fo );
} else
setFont( KOPrefs::instance()->mMonthViewFont );
QFontMetrics fm( font() );
mLabelSize = fm.size( 0, "30" ) + QSize( 4, 2 );
mLabelBigSize = fm.size( 0, "Mag 30" ) + QSize( 2, 2 );
mHolidayPalette = mStandardPalette;
mPrimaryPalette = mStandardPalette;
mNonPrimaryPalette = mStandardPalette;
if ( KOPrefs::instance()->mMonthViewUsesDayColors ) {
mHolidayPalette.setColor(QColorGroup::Base, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Background, KOPrefs::instance()->mMonthViewHolidayColor );
mHolidayPalette.setColor(QColorGroup::Foreground, KOPrefs::instance()->mMonthViewHolidayColor.dark());
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 )
{
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();
}
void MonthViewCell::select()
{
;// updateCell();
}
void MonthViewCell::resizeEvent ( QResizeEvent * e )
{
if ( !mMonthView->isUpdatePossible() )
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 )
{
if ( !item ) return;
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->defaultAction( incidence );
}
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();
}
*/
mMonthView->setSelectedCell( this );
if( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) enableScrollBars( true );
select();
}
void MonthViewCell::contextMenu( QListBoxItem *item )
{
if ( !item ) return;
MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
Incidence *incidence = eventItem->incidence();
if ( incidence ) mMonthView->showContextMenu( incidence );
}
@@ -1215,192 +1306,197 @@ void KOMonthView::showDates(const QDate &start, const QDate &)
bool primary = false;
uint i;
for( i = 0; i < (*cells).size(); ++i ) {
QDate date = mStartDate.addDays( i );
(*cells)[i]->setDate( date );
#ifndef KORG_NOPLUGINS
// add holiday, if present
QString hstring(KOCore::self()->holiday(date));
(*cells)[i]->setHoliday( hstring );
#endif
}
QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
for( i = 0; i < weekNum; ++i ) {
int wno;
// remember, according to ISO 8601, the first week of the year is the
// first week that contains a thursday. Thus we must subtract off 4,
// not just 1.
int dayOfYear = date.dayOfYear();
if (dayOfYear % 7 != 0)
wno = dayOfYear / 7 + 1;
else
wno =dayOfYear / 7;
(*weekLabels)[i]->setWeekNum( wno );
date = date.addDays( 7 );
}
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.
updateView();
}
void KOMonthView::updateView()
{
if ( !updatePossible )
return;
+ //qDebug("UUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU ");
//QTime ti;
//ti.start();
clearSelection();
QPtrVector<MonthViewCell> *cells;
if ( mShowWeekView ) {
cells = &mCellsW;
} else {
cells = &mCells;
}
#if 1
int i;
int timeSpan = (*cells).size()-1;
if ( KOPrefs::instance()->mMonthViewWeek )
timeSpan = 6;
for( i = 0; i < timeSpan + 1; ++i ) {
(*cells)[i]->startUpdateCell();
}
QPtrList<Event> events = calendar()->events();
Event *event;
QDateTime dt;
bool ok;
QDate endDate = mStartDate.addDays( timeSpan );
for( event = events.first(); event; event = events.next() ) { // for event
if ( event->doesRecur() ) {
bool last;
QDateTime incidenceStart = event->recurrence()->getPreviousDateTime( QDateTime( mStartDate ) , &last );
QDateTime incidenceEnd;
int eventlen = event->dtStart().date().daysTo ( event->dtEnd().date() );
bool invalid = false;
while( true ) {
if ( incidenceStart.isValid() ) {
incidenceEnd = incidenceStart.addDays( eventlen );
int st = incidenceStart.date().daysTo( endDate );
if ( st >= 0 ) { // start before timeend
int end = mStartDate.daysTo( incidenceEnd.date() );
if ( end >= 0 ) { // end after timestart --- got one!
//normalize
st = timeSpan - st;
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
//qDebug("found %s %d %d ",event->summary().latin1(), st, end );
for ( iii = st;iii<= end;++iii)
(*cells)[iii]->insertEvent( event );
}
}
} else {
if ( invalid )
break;
invalid = true;
//qDebug("invalid %s", event->summary().latin1());
incidenceStart = QDateTime( mStartDate ).addSecs( -2 );;
}
if ( last )
break;
bool ok;
incidenceStart = event->getNextOccurence( incidenceStart.addSecs( 1 ) ,&ok );
if ( ! ok )
break;
if ( incidenceStart.date() > endDate )
break;
}
} else { // no recur
int st = event->dtStart().date().daysTo( endDate );
if ( st >= 0 ) { // start before timeend
int end = mStartDate.daysTo( event->dtEnd().date() );
if ( end >= 0 ) { // end after timestart --- got one!
//normalize
st = timeSpan - st;
if ( st < 0 ) st = 0;
if ( end > timeSpan ) end = timeSpan;
int iii;
for ( iii = st;iii<= end;++iii)
(*cells)[iii]->insertEvent( event );
}
}
}
}
// insert due todos
QPtrList<Todo> todos = calendar()->todos( );
Todo *todo;
for(todo = todos.first(); todo; todo = todos.next()) {
//insertTodo( todo );
if ( todo->hasDueDate() ) {
int day = mStartDate.daysTo( todo->dtDue().date() );
if ( day >= 0 && day < timeSpan + 1) {
(*cells)[day]->insertTodo( todo );
}
}
}
for( i = 0; i < timeSpan+1; ++i ) {
(*cells)[i]->finishUpdateCell();
}
processSelectionChange();
+ qApp->processEvents();
+ for( i = 0; i < timeSpan+1; ++i ) {
+ (*cells)[i]->repaintfinishUpdateCell();
+ }
(*cells)[0]->setFocus();
#else
// old code
//qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
int i;
for( i = 0; i < (*cells).count(); ++i ) {
(*cells)[i]->updateCell();
}
//qDebug("KOMonthView::updateView() ");
processSelectionChange();
// qDebug("---------------------------------------------------------------------+ ");
(*cells)[0]->setFocus();
#endif
//qDebug("update time %d ", ti.elapsed());
}
void KOMonthView::resizeEvent(QResizeEvent * e)
{
qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
if ( isVisible() ) {
qDebug("KOMonthView::isVisible ");
slotComputeLayout();
} else
mComputeLayoutTimer->start( 100 );
}
void KOMonthView::slotComputeLayout()
{
mComputeLayoutTimer->stop();
qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
computeLayout();
clPending = true;
if ( mShowWeekView )
mCellsW[0]->setFocus();
else
mCells[0]->setFocus();
}
void KOMonthView::computeLayoutWeek()
{
static int lastWid = 0;
static int lastHei = 0;
int daysToShow;
bool combinedSatSun = false;
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 89912e0..b997c1a 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -48,208 +48,214 @@ class KOWeekButton : public QPushButton
{
Q_OBJECT
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:
int mNumber;
private slots :
void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
};
class KNoScrollListBox: public QListBox
{
Q_OBJECT
public:
KNoScrollListBox(QWidget *parent=0, const char *name=0);
~KNoScrollListBox();
QString getWhatsThisText(QPoint p) ;
signals:
void shiftDown();
void shiftUp();
void rightClick();
protected slots:
void oneDown();
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
void mousePressEvent(QMouseEvent *);
private:
KNOWhatsThis * mWT;
};
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; }
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 mblockRepaint;
int mMultiday;
bool mRecur;
bool mAlarm;
bool mReply;
bool mInfo;
QPalette mPalette;
QDate mDate;
Incidence *mIncidence;
};
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;
void setPrimary( bool );
bool isPrimary() const;
void setHoliday( bool );
void setHoliday( const QString & );
void updateCell();
void startUpdateCell();
void finishUpdateCell();
+ void repaintfinishUpdateCell();
void insertEvent(Event *);
void insertTodo(Todo *);
void updateConfig( bool bigFont = false );
void enableScrollBars( bool );
Incidence *selectedIncidence();
QDate selectedIncidenceDate();
void deselect();
void select();
#ifdef DESKTOP_VERSION
static QToolTipGroup *toolTipGroup();
#endif
signals:
void defaultAction( Incidence * );
void newEventSignal( QDateTime );
void showDaySignal( QDate );
protected:
QStringList mToolTip;
void resizeEvent( QResizeEvent * );
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;
+ //QListBox *mItemList;
#ifdef DESKTOP_VERSION
static QToolTipGroup *mToolTipGroup;
#endif
QSize mLabelSize;
QSize mLabelBigSize;
QPalette mHolidayPalette;
QPalette mStandardPalette;
QPalette mPrimaryPalette;
QPalette mNonPrimaryPalette;
void setMyPalette();
QPalette getPalette ();
- void keyPressEvent ( QKeyEvent * ) ;
};
class KOMonthView: public KOEventView
{
Q_OBJECT
public:
KOMonthView(Calendar *cal, QWidget *parent = 0, const char *name = 0 );
~KOMonthView();
/** Returns maximum number of days supported by the komonthview */
virtual int maxDatesHint();
/** Returns number of currently shown dates. */
virtual int currentDateCount();
/** returns the currently selected events */
virtual QPtrList<Incidence> selectedIncidences();
/** returns dates of the currently selected events */
virtual DateList selectedDates();
virtual void printPreview(CalPrinter *calPrinter,
const QDate &, const QDate &);
bool isMonthView() { return !mShowWeekView; }
bool isUpdatePossible() { return updatePossible; }
MonthViewCell * selectedCell();
bool skipResize;
NavigatorBar* navigatorBar() { return mNavigatorBar ;}
public slots:
virtual void updateView();
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
void clearSelection();
void showContextMenu( Incidence * );
void setSelectedCell( MonthViewCell * );
void switchView();
protected slots:
void slotComputeLayout();
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94d74f1..c6e76c4 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -163,118 +163,119 @@ void KOViewManager::showDateView( int view, QDate date)
} else
showWeekView();
} else if (view == 10) {
mMainView->dateNavigator()->selectDates( date,mMainView->dateNavigator()->selectedDates().count() );
}
}
void KOViewManager::writeSettings(KConfig *config)
{
config->setGroup("General");
QString view;
if (mCurrentView == mWhatsNextView) view = "WhatsNext";
else if (mCurrentView == mMonthView) view = "Month";
else if (mCurrentView == mListView) view = "List";
else if (mCurrentView == mJournalView) view = "Journal";
else if (mCurrentView == mTimeSpanView) view = "TimeSpan";
else if (mCurrentView == mTodoView) view = "Todo";
else view = "Agenda";
config->writeEntry("Current View",view);
if (mAgendaView) {
mAgendaView->writeSettings(config);
}
if (mTimeSpanView) {
mTimeSpanView->writeSettings(config);
}
if (mListView) {
mListView->writeSettings(config);
}
if (mTodoView) {
mTodoView->saveLayout(config,"Todo View");
}
}
void KOViewManager::showView(KOrg::BaseView *view, bool fullScreen )
{
//mFlagShowNextxDays = false;
//if(view == mCurrentView) return;
if ( view == 0 ) {
view = mCurrentView;
if ( view == 0 )
return;
}
+ bool callupdate = !(view == mCurrentView);
bool full = fullScreen;
if(view == mCurrentView && view != mWhatsNextView ) {
if ( mCurrentAgendaView < 0 )
return;
if ( view != mMonthView )
full = mMainView->leftFrame()->isVisible();
} else {
if ( view == mMonthView && mMonthView)
;//mMonthView->skipResize = true ;
mCurrentView = view;
// bool full = fullScreen;
bool isFull = !mMainView->leftFrame()->isVisible();
if ( isFull && KOPrefs::instance()->mViewChangeHoldFullscreen )
full = true;
if ( !isFull && KOPrefs::instance()->mViewChangeHoldNonFullscreen )
full = false;
}
if ( mAgendaView ) mAgendaView->deleteSelectedDateTime();
//raiseCurrentView( full );
mMainView->processIncidenceSelection( 0 );
//mMainView->updateView();
- raiseCurrentView( full, true );
+ raiseCurrentView( full, callupdate );
mMainView->adaptNavigationUnits();
}
void KOViewManager::raiseCurrentView( bool fullScreen, bool callUpdateView )
{
mCurrentAgendaView = 0;
if ( fullScreen ) {
mMainView->leftFrame()->hide();
} else {
mMainView->leftFrame()->show();
}
//if ( mCurrentView == mMonthView ) qApp->processEvents();
emit signalFullScreen( !fullScreen );
if ( callUpdateView )
mMainView->updateView();
if ( globalFlagBlockAgenda == 5 ) {
globalFlagBlockAgenda = 4;
globalFlagBlockAgendaItemPaint = 1;
}
mMainView->viewStack()->raiseWidget(mCurrentView);
if ( globalFlagBlockAgenda == 4 ) {
if ( mCurrentView == mAgendaView ) {
//globalFlagBlockAgenda =1 ;
if ( KOPrefs::instance()->mSetTimeToDayStartAt )
mAgendaView->setStartHour( KOPrefs::instance()->mDayBegins );
else if ( KOPrefs::instance()->mCenterOnCurrentTime )
mAgendaView->setStartHour( QTime::currentTime ().hour() );
qApp->processEvents();
//qDebug("qApp->processEvents() ");
globalFlagBlockAgenda = 0;
mAgendaView->repaintAgenda();
}
globalFlagBlockAgenda = 0;
}
emit signalAgendaView( mCurrentView == mAgendaView );
//qDebug("raiseCurrentView ende ");
}
void KOViewManager::updateView()
{
// qDebug("KOViewManager::updateView() ");
// if we are updating mTodoView, we get endless recursion
if ( mTodoView == mCurrentView )
return;
if ( mCurrentView ) mCurrentView->updateView();