summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-04-04 20:24:30 (UTC)
committer zautrix <zautrix>2005-04-04 20:24:30 (UTC)
commitc408fcb55de18d1e3e1d20803c3885e3074cfaa4 (patch) (side-by-side diff)
tree092f6e385210a9fa7bd625c2e0cae3ceba68f513
parent8e7f4812c4ad239b6a17cce8aa84c00274ced4df (diff)
downloadkdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.zip
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.gz
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.bz2
month view fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp92
-rw-r--r--korganizer/komonthview.h3
2 files changed, 54 insertions, 41 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 9f7db69..1ed288b 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -79,40 +79,66 @@ 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 );
+ 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!");
}
@@ -238,16 +264,17 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
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;
@@ -375,17 +402,17 @@ int MonthViewItem::height(const QListBox *lb) const
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;
}
@@ -410,18 +437,16 @@ int MonthViewItem::width(const QListBox *lb) const
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 );
@@ -567,18 +592,24 @@ void MonthViewCell::startUpdateCell()
// 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 ();
+ 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() ) {
@@ -588,17 +619,16 @@ void MonthViewCell::startUpdateCell()
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;
}
@@ -647,31 +677,25 @@ void MonthViewCell::insertEvent(Event *event)
}
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();
- 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);
@@ -701,48 +725,38 @@ void MonthViewCell::insertEvent(Event *event)
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 );
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();
- 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();
@@ -762,37 +776,31 @@ void MonthViewCell::insertTodo(Todo *todo)
} 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 );
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
@@ -856,30 +864,34 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
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);
}
@@ -976,17 +988,16 @@ void MonthViewCell::showDay()
}
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 ) {
@@ -1086,33 +1097,33 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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 );
@@ -1393,17 +1404,17 @@ 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;
@@ -1523,24 +1534,25 @@ void KOMonthView::updateView()
(*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() ");
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e04cdf5..e962756 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -55,16 +55,17 @@ class KOWeekButton : public QPushButton
SLOT( bottonClicked() ));
mNumber = -1;
}
void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
int getWeekNum() { return mNumber;}
signals:
void selectWeekNum ( int );
private:
+ void focusInEvent ( QFocusEvent * ){;}
int mNumber;
void keyPressEvent ( QKeyEvent * e )
{
e->ignore();
}
private slots :
void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
@@ -117,16 +118,17 @@ class MonthViewItem: public QListBoxItem
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;
@@ -190,17 +192,16 @@ public slots:
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;