summaryrefslogtreecommitdiffabout
path: root/korganizer
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 /korganizer
parent8e7f4812c4ad239b6a17cce8aa84c00274ced4df (diff)
downloadkdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.zip
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.gz
kdepimpi-c408fcb55de18d1e3e1d20803c3885e3074cfaa4.tar.bz2
month view fixes
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp116
-rw-r--r--korganizer/komonthview.h5
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
@@ -81,12 +81,14 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
{
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
#endif
mWT = new KNOWhatsThis(this);
resetOnFocusIn = true;
+ setVScrollBarMode(QScrollView::AlwaysOff);
+ setHScrollBarMode(QScrollView::AlwaysOff);
}
KNoScrollListBox::~KNoScrollListBox()
{
}
@@ -97,20 +99,44 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * 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 ) {
@@ -240,12 +266,13 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
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;
@@ -377,13 +404,13 @@ int MonthViewItem::height(const QListBox *lb) const
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 ) {
@@ -412,14 +439,12 @@ int MonthViewItem::width(const QListBox *lb) const
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 );
@@ -569,14 +594,20 @@ void MonthViewCell::startUpdateCell()
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();
@@ -590,13 +621,12 @@ void MonthViewCell::startUpdateCell()
#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 )
@@ -649,27 +679,21 @@ void MonthViewCell::insertEvent(Event *event)
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();
@@ -703,43 +727,33 @@ void MonthViewCell::insertEvent(Event *event)
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();
@@ -764,14 +778,13 @@ void MonthViewCell::insertTodo(Todo *todo)
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 ) {
@@ -779,18 +792,13 @@ void MonthViewCell::repaintfinishUpdateCell()
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(),"");
@@ -858,26 +866,30 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
}
//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);
@@ -978,13 +990,12 @@ 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;
}
/*
@@ -1088,13 +1099,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
//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);
@@ -1104,13 +1115,13 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
//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 ) {
@@ -1395,13 +1406,13 @@ void KOMonthView::showEvents(QPtrList<Event>)
}
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()
{
@@ -1525,20 +1536,21 @@ void KOMonthView::updateView()
//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()
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e04cdf5..e962756 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -56,13 +56,14 @@ class KOWeekButton : public QPushButton
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();
}
@@ -119,12 +120,13 @@ class MonthViewItem: public QListBoxItem
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;
@@ -192,13 +194,12 @@ public slots:
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;