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
@@ -84,6 +84,8 @@ KNoScrollListBox::KNoScrollListBox(QWidget *parent,const char *name)
#endif
mWT = new KNOWhatsThis(this);
resetOnFocusIn = true;
+ setVScrollBarMode(QScrollView::AlwaysOff);
+ setHScrollBarMode(QScrollView::AlwaysOff);
}
KNoScrollListBox::~KNoScrollListBox()
{
@@ -100,6 +102,28 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
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 )
{
@@ -108,6 +132,8 @@ void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
setSelected ( i, false );
}
QListBox::focusOutEvent ( e );
+ setVScrollBarMode(QScrollView::AlwaysOff);
+ setHScrollBarMode(QScrollView::AlwaysOff);
}
QString KNoScrollListBox::getWhatsThisText(QPoint p)
@@ -243,6 +269,7 @@ MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
mAlarm = false;
mReply = false;
mInfo = false;
+ isWeekItem = KOPrefs::instance()->mMonthViewWeek;
//qDebug("NEWWWWWWWWWWWWW ");
}
void MonthViewItem::recycle( Incidence *incidence, QDate qd, const QString & s)
@@ -380,7 +407,7 @@ int MonthViewItem::height(const QListBox *lb) const
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;
@@ -415,8 +442,6 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
: KNoScrollListBox( par ),
mMonthView( parent )
{
-
- mCurrentAvailItem = 0;
//QVBoxLayout *topLayout = new QVBoxLayout( this );
currentPalette = 0;
// mLabel = new QLabel( this );QPushButton
@@ -572,8 +597,14 @@ void MonthViewCell::startUpdateCell()
} 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);
@@ -593,7 +624,6 @@ void MonthViewCell::startUpdateCell()
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 )
@@ -652,21 +682,15 @@ void MonthViewCell::insertEvent(Event *event)
}
}
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();
@@ -706,13 +730,11 @@ void MonthViewCell::insertEvent(Event *event)
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()) {
@@ -723,21 +745,13 @@ void MonthViewCell::insertTodo(Todo *todo)
}
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;
@@ -767,7 +781,6 @@ void MonthViewCell::insertTodo(Todo *todo)
item->setRecur( todo->recurrence()->doesRecur() );
item->setAlarm( todo->isAlarmEnabled() );
item->setMoreInfo( todo->description().length() > 0 );
- if ( insertNewItem)
insertItem( item );
mToolTip.append( text );
}
@@ -782,12 +795,7 @@ void MonthViewCell::repaintfinishUpdateCell()
}
void MonthViewCell::finishUpdateCell()
{
- while ( mCurrentAvailItem ) {
- MonthViewItem *item = mCurrentAvailItem;
- mCurrentAvailItem = (MonthViewItem *)item->next();
- mAvailItemList.append( item );
- takeItem ( item );
- }
+
#ifdef DESKTOP_VERSION
@@ -861,6 +869,8 @@ void MonthViewCell::updateConfig( bool bigFont ) // = false
void MonthViewCell::enableScrollBars( bool enabled )
{
+
+ return;
if ( enabled ) {
QListBoxItem *fi = firstItem ();
if (fi ) {
@@ -871,10 +881,12 @@ void MonthViewCell::enableScrollBars( bool enabled )
}
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);
@@ -981,7 +993,6 @@ void MonthViewCell::newEvent()
}
void MonthViewCell::cellClicked( QListBoxItem *item )
{
- static QListBoxItem * lastClicked = 0;
if ( item == 0 ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
@@ -1091,7 +1102,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
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++ ) {
@@ -1107,7 +1118,7 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mWeekLabelsW.insert( i, label );
}
mWeekLabelsW[1]->setText( i18n("W"));
- mWeekLabelsW[0]->setFocusPolicy(WheelFocus);
+ mWeekLabelsW[1]->setFocusPolicy(WheelFocus);
int row, col;
@@ -1398,7 +1409,7 @@ 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();
}
@@ -1528,14 +1539,15 @@ void KOMonthView::updateView()
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() ) );
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e04cdf5..e962756 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -60,6 +60,7 @@ class KOWeekButton : public QPushButton
signals:
void selectWeekNum ( int );
private:
+ void focusInEvent ( QFocusEvent * ){;}
int mNumber;
void keyPressEvent ( QKeyEvent * e )
{
@@ -122,6 +123,7 @@ class MonthViewItem: public QListBoxItem
virtual int width(const QListBox *) const;
private:
+ bool isWeekItem;
bool mblockRepaint;
int mMultiday;
bool mRecur;
@@ -195,7 +197,6 @@ public slots:
void newEvent();
private:
- MonthViewItem* mCurrentAvailItem;
QPtrList <MonthViewItem> mAvailItemList;
KOMonthView *mMonthView;
int currentPalette;