summaryrefslogtreecommitdiffabout
path: root/korganizer
authorzautrix <zautrix>2005-01-27 10:15:45 (UTC)
committer zautrix <zautrix>2005-01-27 10:15:45 (UTC)
commit1501a5d8a25e3474fb450d7e0b272feb14821d1c (patch) (side-by-side diff)
tree70a8fcafed89f6dc8225af9908e845c0feecd7d9 /korganizer
parente4beb835276376646307bea74430008c332bd387 (diff)
downloadkdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.zip
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.gz
kdepimpi-1501a5d8a25e3474fb450d7e0b272feb14821d1c.tar.bz2
fix
Diffstat (limited to 'korganizer') (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp855
-rw-r--r--korganizer/komonthview.h2
-rw-r--r--korganizer/koviewmanager.cpp4
-rw-r--r--korganizer/mainwindow.cpp2
4 files changed, 447 insertions, 416 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 437debe..10e4f1d 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -1,20 +1,20 @@
/*
- This file is part of KOrganizer.
- Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ This file is part of KOrganizer.
+ Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <qpopupmenu.h>
@@ -55,7 +55,7 @@
#define PIXMAP_SIZE 5
#ifdef DESKTOP_VERSION
- QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
+QToolTipGroup *MonthViewCell::mToolTipGroup = 0;
#endif
class KNOWhatsThis :public QWhatsThis
{
@@ -64,10 +64,10 @@ public:
//~KNOWhatsThis( ) {qDebug("~KNOWhatsThis( ) "); };
protected:
- virtual QString text( const QPoint& p)
- {
- return _wid->getWhatsThisText(p) ;
- };
+ virtual QString text( const QPoint& p)
+ {
+ return _wid->getWhatsThisText(p) ;
+ };
private:
KNoScrollListBox* _wid;
@@ -97,7 +97,7 @@ QString KNoScrollListBox::getWhatsThisText(QPoint p)
void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
{
- switch(e->key()) {
+ switch(e->key()) {
case Key_Right:
// if ( e->state() == Qt::ControlButton )
{
@@ -105,223 +105,229 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
return;
}
scrollBy(4,0);
- break;
+ break;
case Key_Left:
// if ( e->state() == Qt::ControlButton )
- {
+ {
e->ignore();
return;
}
- scrollBy(-4,0);
- break;
+ scrollBy(-4,0);
+ break;
case Key_Up:
- if(!count()) break;
- setCurrentItem((currentItem()+count()-1)%count());
- if(!itemVisible(currentItem())) {
- if((unsigned int) currentItem() == (count()-1)) {
- setTopItem(currentItem()-numItemsVisible()+1);
- } else {
- setTopItem(topItem()-1);
+ if(count() < 2) {
+ e->ignore();
+ break;
}
- }
- break;
+ setCurrentItem((currentItem()+count()-1)%count());
+ if(!itemVisible(currentItem())) {
+ if((unsigned int) currentItem() == (count()-1)) {
+ setTopItem(currentItem()-numItemsVisible()+1);
+ } else {
+ setTopItem(topItem()-1);
+ }
+ }
+ break;
case Key_Down:
- if(!count()) break;
- setCurrentItem((currentItem()+1)%count());
- if(!itemVisible(currentItem())) {
- if(currentItem() == 0) {
- setTopItem(0);
- } else {
- setTopItem(topItem()+1);
+ if(count() < 2) {
+ e->ignore();
+ break;
}
- }
- break;
+ setCurrentItem((currentItem()+1)%count());
+ if(!itemVisible(currentItem())) {
+ if(currentItem() == 0) {
+ setTopItem(0);
+ } else {
+ setTopItem(topItem()+1);
+ }
+ }
+ break;
case Key_Shift:
- emit shiftDown();
- break;
+ emit shiftDown();
+ break;
default:
e->ignore();
- break;
- }
+ break;
+ }
}
void KNoScrollListBox::keyReleaseEvent(QKeyEvent *e)
{
- switch(e->key()) {
+ switch(e->key()) {
case Key_Shift:
- emit shiftUp();
- break;
+ emit shiftUp();
+ break;
default:
- break;
- }
+ break;
+ }
}
void KNoScrollListBox::mousePressEvent(QMouseEvent *e)
{
- QListBox::mousePressEvent(e);
+ QListBox::mousePressEvent(e);
- if(e->button() == RightButton) {
- emit rightClick();
- }
+ if(e->button() == RightButton) {
+ emit rightClick();
+ }
}
MonthViewItem::MonthViewItem( Incidence *incidence, QDate qd, const QString & s)
- : QListBoxItem()
+ : QListBoxItem()
{
- setText( s );
-
- mIncidence = incidence;
- mDate = qd;
- // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
- mRecur = false;
- mAlarm = false;
- mReply = false;
- mInfo = false;
+ setText( s );
+
+ mIncidence = incidence;
+ mDate = qd;
+ // QWhatsThis::add(this,KIncidenceFormatter::instance()->getFormattedText( mIncidence ));
+ mRecur = false;
+ mAlarm = false;
+ mReply = false;
+ mInfo = false;
}
void MonthViewItem::paint(QPainter *p)
{
#if QT_VERSION >= 0x030000
- bool sel = isSelected();
+ bool sel = isSelected();
#else
- bool sel = selected();
+ 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;
- 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;
- }
- }
- QFontMetrics fm = p->fontMetrics();
- int yPos;
- int pmheight = size;
- if( pmheight < fm.height() )
- yPos = fm.ascent() + fm.leading()/2;
- else
- yPos = pmheight/2 - fm.height()/2 + fm.ascent();
- p->setPen( palette().color( QPalette::Normal, sel ? \
- QColorGroup::HighlightedText : QColorGroup::Foreground ) );
- p->drawText( x, yPos, text() );
- if ( mIncidence->cancelled() ) {
- int wid = fm.width( text() );
- p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
- }
+ 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;
+ 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;
+ }
+ }
+ QFontMetrics fm = p->fontMetrics();
+ int yPos;
+ int pmheight = size;
+ if( pmheight < fm.height() )
+ yPos = fm.ascent() + fm.leading()/2;
+ else
+ yPos = pmheight/2 - fm.height()/2 + fm.ascent();
+ p->setPen( palette().color( QPalette::Normal, sel ? \
+ QColorGroup::HighlightedText : QColorGroup::Foreground ) );
+ p->drawText( x, yPos, text() );
+ if ( mIncidence->cancelled() ) {
+ int wid = fm.width( text() );
+ p->drawLine( x, yPos- fm.height()/2+2,x+wid, yPos- fm.height()/2 +2);
+ }
}
int MonthViewItem::height(const QListBox *lb) const
{
- return lb->fontMetrics().lineSpacing()+1;
+ return lb->fontMetrics().lineSpacing()+1;
}
int MonthViewItem::width(const QListBox *lb) const
{
int size = PIXMAP_SIZE;
- if ( QApplication::desktop()->width() < 300 )
- size = 3;
- int x = 1;
- if ( mInfo ) {
- x += size + 1;
- }
- if( mRecur ) {
- x += size+1;
- }
- if( mAlarm ) {
- x += size+1;
- }
- if( mReply ) {
- x += size+1;
- }
-
- return( x + lb->fontMetrics().width( text() ) + 1 );
+ if ( QApplication::desktop()->width() < 300 )
+ size = 3;
+ int x = 1;
+ if ( mInfo ) {
+ x += size + 1;
+ }
+ if( mRecur ) {
+ x += size+1;
+ }
+ if( mAlarm ) {
+ x += size+1;
+ }
+ if( mReply ) {
+ x += size+1;
+ }
+
+ return( x + lb->fontMetrics().width( text() ) + 1 );
}
MonthViewCell::MonthViewCell( KOMonthView *parent)
- : QWidget( parent ),
- mMonthView( parent )
+ : QWidget( parent ),
+ mMonthView( parent )
{
- QVBoxLayout *topLayout = new QVBoxLayout( this );
-
- // mLabel = new QLabel( this );QPushButton
- mLabel = new QPushButton( this );
- //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
- //mLabel->setLineWidth( 1 );
- //mLabel->setAlignment( AlignCenter );
- mLabel->setFlat( true );
- mItemList = new KNoScrollListBox( this );
- mItemList->setMinimumSize( 10, 10 );
- mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
- mItemList->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 *) ),
- SLOT( defaultAction( QListBoxItem * ) ) );
- connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
- const QPoint &) ),
- SLOT( contextMenu( QListBoxItem * ) ) );
- connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
- SLOT( selection( QListBoxItem * ) ) );
- connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
- SLOT( cellClicked( QListBoxItem * ) ) );
- connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
- SLOT( selection( QListBoxItem * ) ) );
+ QVBoxLayout *topLayout = new QVBoxLayout( this );
+
+ // mLabel = new QLabel( this );QPushButton
+ mLabel = new QPushButton( this );
+ //mLabel->setFrameStyle( QFrame::Panel | QFrame::Plain );
+ //mLabel->setLineWidth( 1 );
+ //mLabel->setAlignment( AlignCenter );
+ mLabel->setFlat( true );
+ mItemList = new KNoScrollListBox( this );
+ mItemList->setMinimumSize( 10, 10 );
+ mItemList->setFrameStyle( QFrame::Panel | QFrame::Plain );
+ mItemList->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 *) ),
+ SLOT( defaultAction( QListBoxItem * ) ) );
+ connect( mItemList, SIGNAL( rightButtonPressed( QListBoxItem *,
+ const QPoint &) ),
+ SLOT( contextMenu( QListBoxItem * ) ) );
+ connect( mItemList, SIGNAL( highlighted( QListBoxItem *) ),
+ SLOT( selection( QListBoxItem * ) ) );
+ connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
+ SLOT( cellClicked( QListBoxItem * ) ) );
+ connect( mItemList, SIGNAL( clicked( QListBoxItem * ) ),
+ SLOT( selection( QListBoxItem * ) ) );
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
- if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
- return mToolTipGroup;
+ if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
+ return mToolTipGroup;
}
#endif
void MonthViewCell::setDate( const QDate &date )
{
-// kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
- mDate = date;
+ // kdDebug() << "MonthViewCell::setDate(): " << date.toString() << endl;
+ mDate = date;
- //resizeEvent( 0 );
+ //resizeEvent( 0 );
}
QDate MonthViewCell::date() const
{
- return mDate;
+ return mDate;
}
void MonthViewCell::setPrimary( bool primary )
@@ -360,27 +366,27 @@ QPalette MonthViewCell::getPalette ()
}
bool MonthViewCell::isPrimary() const
{
- return mPrimary;
+ return mPrimary;
}
void MonthViewCell::setHoliday( bool holiday )
{
- mHoliday = holiday;
- //setMyPalette();
+ mHoliday = holiday;
+ //setMyPalette();
}
void MonthViewCell::setHoliday( const QString &holiday )
{
- mHolidayString = holiday;
+ mHolidayString = holiday;
- if ( !holiday.isEmpty() ) {
- setHoliday( true );
- }
+ if ( !holiday.isEmpty() ) {
+ setHoliday( true );
+ }
}
void MonthViewCell::keyPressEvent ( QKeyEvent * e )
{
- e->ignore();
+ e->ignore();
}
void MonthViewCell::clear()
@@ -396,8 +402,8 @@ void MonthViewCell::updateCell()
return;
/*
if ( !isVisible() ){
- return;
- }
+ return;
+ }
*/
// qDebug("MonthViewCell::updateCell() ");
setPrimary( mDate.month()%2 );
@@ -405,7 +411,7 @@ void MonthViewCell::updateCell()
if ( mDate == QDate::currentDate() ) {
mItemList->setLineWidth( 3 );
} else {
- mItemList->setLineWidth( 1 );
+ mItemList->setLineWidth( 1 );
}
mItemList->clear();
@@ -585,71 +591,71 @@ void MonthViewCell::updateCell()
void MonthViewCell::updateConfig()
{
- 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();
+ 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);
- } else {
- mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
- mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
- }
+ if ( enabled ) {
+ mItemList->setVScrollBarMode(QScrollView::Auto);
+ mItemList->setHScrollBarMode(QScrollView::Auto);
+ } else {
+ mItemList->setVScrollBarMode(QScrollView::AlwaysOff);
+ mItemList->setHScrollBarMode(QScrollView::AlwaysOff);
+ }
}
Incidence *MonthViewCell::selectedIncidence()
{
- int index = mItemList->currentItem();
- if ( index < 0 ) return 0;
+ int index = mItemList->currentItem();
+ if ( index < 0 ) return 0;
- MonthViewItem *item =
- static_cast<MonthViewItem *>( mItemList->item( index ) );
+ MonthViewItem *item =
+ static_cast<MonthViewItem *>( mItemList->item( index ) );
- if ( !item ) return 0;
+ if ( !item ) return 0;
- return item->incidence();
+ return item->incidence();
}
QDate MonthViewCell::selectedIncidenceDate()
{
- QDate qd;
- int index = mItemList->currentItem();
- if ( index < 0 ) return qd;
+ QDate qd;
+ int index = mItemList->currentItem();
+ if ( index < 0 ) return qd;
- MonthViewItem *item =
- static_cast<MonthViewItem *>( mItemList->item( index ) );
+ MonthViewItem *item =
+ static_cast<MonthViewItem *>( mItemList->item( index ) );
- if ( !item ) return qd;
+ if ( !item ) return qd;
- return item->incidenceDate();
+ return item->incidenceDate();
}
void MonthViewCell::deselect()
{
- mItemList->clearSelection();
- enableScrollBars( false );
- // updateCell();
+ mItemList->clearSelection();
+ enableScrollBars( false );
+ // updateCell();
}
void MonthViewCell::select()
{
@@ -677,11 +683,11 @@ void MonthViewCell::resizeEvent ( QResizeEvent * )
void MonthViewCell::defaultAction( QListBoxItem *item )
{
- if ( !item ) return;
+ if ( !item ) return;
- MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
- Incidence *incidence = eventItem->incidence();
- if ( incidence ) mMonthView->defaultAction( incidence );
+ MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
+ Incidence *incidence = eventItem->incidence();
+ if ( incidence ) mMonthView->defaultAction( incidence );
}
void MonthViewCell::showDay()
{
@@ -700,33 +706,33 @@ void MonthViewCell::cellClicked( QListBoxItem *item )
emit newEventSignal( dt );
return;
}
- /*
- if ( lastClicked )
+ /*
+ if ( lastClicked )
if ( ! item ) {
- if ( lastClicked->listBox() != item->listBox() )
- lastClicked->listBox()->clearSelection();
+ if ( lastClicked->listBox() != item->listBox() )
+ lastClicked->listBox()->clearSelection();
}
- */
+ */
- mMonthView->setSelectedCell( this );
- if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
- select();
+ mMonthView->setSelectedCell( this );
+ if( KOPrefs::instance()->mEnableMonthScroll ) enableScrollBars( true );
+ select();
}
void MonthViewCell::contextMenu( QListBoxItem *item )
{
- if ( !item ) return;
+ if ( !item ) return;
- MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
- Incidence *incidence = eventItem->incidence();
- if ( incidence ) mMonthView->showContextMenu( incidence );
+ MonthViewItem *eventItem = static_cast<MonthViewItem *>( item );
+ Incidence *incidence = eventItem->incidence();
+ if ( incidence ) mMonthView->showContextMenu( incidence );
}
void MonthViewCell::selection( QListBoxItem *item )
{
- if ( !item ) return;
+ if ( !item ) return;
- mMonthView->setSelectedCell( this );
+ mMonthView->setSelectedCell( this );
}
@@ -741,198 +747,198 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
mShortDayLabels( false ), mWidthLongDayLabel( 0 ), mSelectedCell( 0 )
{
- updatePossible = false;
- mCells.setAutoDelete( true );
- mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
- // mDayLayout = new QGridLayout( this );
- // create the day of the week labels (Sun, Mon, etc) and add them to
- // the layout.
- mDayLabels.resize( mDaysPerWeek );
- QFont bfont = font();
- if ( QApplication::desktop()->width() < 650 ) {
- bfont.setPointSize( bfont.pointSize() - 2 );
- }
- bfont.setBold( true );
- int i;
+ updatePossible = false;
+ mCells.setAutoDelete( true );
+ mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
+ // mDayLayout = new QGridLayout( this );
+ // create the day of the week labels (Sun, Mon, etc) and add them to
+ // the layout.
+ mDayLabels.resize( mDaysPerWeek );
+ QFont bfont = font();
+ if ( QApplication::desktop()->width() < 650 ) {
+ bfont.setPointSize( bfont.pointSize() - 2 );
+ }
+ bfont.setBold( true );
+ int i;
- for( i = 0; i < mDaysPerWeek; i++ ) {
- QLabel *label = new QLabel( this );
- label->setFont(bfont);
- label->setFrameStyle(QFrame::Panel|QFrame::Raised);
- label->setLineWidth(1);
- label->setAlignment(AlignCenter);
- mDayLabels.insert( i, label );
- }
-
- bfont.setBold( false );
- mWeekLabels.resize( mNumWeeks+1 );
- for( i = 0; i < mNumWeeks+1; i++ ) {
- KOWeekButton *label = new KOWeekButton( this );
- label->setFont(bfont);
- connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
- label->setFlat(true);
- QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
- //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
- //label->setLineWidth(1);
- //label->setAlignment(AlignCenter);
- mWeekLabels.insert( i, label );
- }
- mWeekLabels[mNumWeeks]->setText( i18n("W"));
- int row, col;
- mCells.resize( mNumCells );
- for( row = 0; row < mNumWeeks; ++row ) {
- for( col = 0; col < mDaysPerWeek; ++col ) {
- MonthViewCell *cell = new MonthViewCell( this );
- mCells.insert( row * mDaysPerWeek + col, cell );
-
- connect( cell, SIGNAL( defaultAction( Incidence * ) ),
- SLOT( defaultAction( Incidence * ) ) );
- connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
- SIGNAL( newEventSignal( QDateTime ) ) );
- connect( cell, SIGNAL( showDaySignal( QDate ) ),
- SIGNAL( showDaySignal( QDate ) ) );
+ for( i = 0; i < mDaysPerWeek; i++ ) {
+ QLabel *label = new QLabel( this );
+ label->setFont(bfont);
+ label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ label->setLineWidth(1);
+ label->setAlignment(AlignCenter);
+ mDayLabels.insert( i, label );
}
- }
- mContextMenu = eventPopup();
- // updateConfig(); //useless here
+ bfont.setBold( false );
+ mWeekLabels.resize( mNumWeeks+1 );
+ for( i = 0; i < mNumWeeks+1; i++ ) {
+ KOWeekButton *label = new KOWeekButton( this );
+ label->setFont(bfont);
+ connect( label, SIGNAL( selectWeekNum ( int )),this, SIGNAL( selectWeekNum ( int )) );
+ label->setFlat(true);
+ QWhatsThis::add(label,i18n("Click on the week number to\nshow week in agenda view"));
+ //label->setFrameStyle(QFrame::Panel|QFrame::Raised);
+ //label->setLineWidth(1);
+ //label->setAlignment(AlignCenter);
+ mWeekLabels.insert( i, label );
+ }
+ mWeekLabels[mNumWeeks]->setText( i18n("W"));
+ int row, col;
+ mCells.resize( mNumCells );
+ for( row = 0; row < mNumWeeks; ++row ) {
+ for( col = 0; col < mDaysPerWeek; ++col ) {
+ MonthViewCell *cell = new MonthViewCell( this );
+ mCells.insert( row * mDaysPerWeek + col, cell );
+
+ connect( cell, SIGNAL( defaultAction( Incidence * ) ),
+ SLOT( defaultAction( Incidence * ) ) );
+ connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
+ SIGNAL( newEventSignal( QDateTime ) ) );
+ connect( cell, SIGNAL( showDaySignal( QDate ) ),
+ SIGNAL( showDaySignal( QDate ) ) );
+ }
+ }
- emit incidenceSelected( 0 );
+ mContextMenu = eventPopup();
+ // updateConfig(); //useless here
+
+ emit incidenceSelected( 0 );
}
KOMonthView::~KOMonthView()
{
- delete mContextMenu;
+ delete mContextMenu;
}
int KOMonthView::maxDatesHint()
{
- return mNumCells;
+ return mNumCells;
}
int KOMonthView::currentDateCount()
{
- return mNumCells;
+ return mNumCells;
}
QPtrList<Incidence> KOMonthView::selectedIncidences()
{
- QPtrList<Incidence> selected;
+ QPtrList<Incidence> selected;
- if ( mSelectedCell ) {
- Incidence *incidence = mSelectedCell->selectedIncidence();
- if ( incidence ) selected.append( incidence );
- }
+ if ( mSelectedCell ) {
+ Incidence *incidence = mSelectedCell->selectedIncidence();
+ if ( incidence ) selected.append( incidence );
+ }
- return selected;
+ return selected;
}
DateList KOMonthView::selectedDates()
{
- DateList selected;
+ DateList selected;
- if ( mSelectedCell ) {
- QDate qd = mSelectedCell->selectedIncidenceDate();
- if ( qd.isValid() ) selected.append( qd );
- }
+ if ( mSelectedCell ) {
+ QDate qd = mSelectedCell->selectedIncidenceDate();
+ if ( qd.isValid() ) selected.append( qd );
+ }
- return selected;
+ return selected;
}
void KOMonthView::printPreview(CalPrinter *calPrinter, const QDate &fd,
const QDate &td)
{
#ifndef KORG_NOPRINTER
- calPrinter->preview(CalPrinter::Month, fd, td);
+ calPrinter->preview(CalPrinter::Month, fd, td);
#endif
}
void KOMonthView::updateConfig()
{
- mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
-
- QFontMetrics fontmetric(mDayLabels[0]->font());
- mWidthLongDayLabel = 0;
-
- for (int i = 0; i < 7; i++) {
- int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
- if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
- }
- bool temp = mShowSatSunComp ;
- mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
- if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
- computeLayout();
- updateDayLabels();
- //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
- int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
- //resizeEvent( 0 );
- for (uint i = 0; i < mCells.count(); ++i) {
- mCells[i]->updateConfig();
- }
+ mWeekStartsMonday = KGlobal::locale()->weekStartsMonday();
+
+ QFontMetrics fontmetric(mDayLabels[0]->font());
+ mWidthLongDayLabel = 0;
+
+ for (int i = 0; i < 7; i++) {
+ int width = fontmetric.width(KOGlobals::self()->calendarSystem()->weekDayName(i+1));
+ if ( width > mWidthLongDayLabel ) mWidthLongDayLabel = width;
+ }
+ bool temp = mShowSatSunComp ;
+ mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ;
+ if ( temp != KOPrefs::instance()->mMonthViewSatSunTog )
+ computeLayout();
+ updateDayLabels();
+ //qDebug("KOMonthView::updateConfig() %d %d %d ",height(), mDayLabels[0]->sizeHint().height() ,mNumWeeks);
+ int cellHeight = (height() - mDayLabels[0]->sizeHint().height()) /mNumWeeks;
+ //resizeEvent( 0 );
+ for (uint i = 0; i < mCells.count(); ++i) {
+ mCells[i]->updateConfig();
+ }
#ifdef DESKTOP_VERSION
- MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
+ MonthViewCell::toolTipGroup()->setEnabled(KOPrefs::instance()->mEnableToolTips);
#endif
}
void KOMonthView::updateDayLabels()
{
- for (int i = 0; i < 7; i++) {
- if (mWeekStartsMonday) {
- bool show = mShortDayLabels;
- if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
- show = true;
- mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
- } else {
- if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
- else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
+ for (int i = 0; i < 7; i++) {
+ if (mWeekStartsMonday) {
+ bool show = mShortDayLabels;
+ if ( i > 4 && mShowSatSunComp && mWidthLongDayLabel > mDayLabels[i]->width() )
+ show = true;
+ mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i+1,show));
+ } else {
+ if (i==0) mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(7,mShortDayLabels));
+ else mDayLabels[i]->setText(KOGlobals::self()->calendarSystem()->weekDayName(i,mShortDayLabels));
+ }
}
- }
}
void KOMonthView::showDates(const QDate &start, const QDate &)
{
-// kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
+ // kdDebug() << "KOMonthView::showDates(): " << start.toString() << endl;
- mStartDate = start;
+ mStartDate = start;
- int startWeekDay = mWeekStartsMonday ? 1 : 7;
+ int startWeekDay = mWeekStartsMonday ? 1 : 7;
- while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
- mStartDate = mStartDate.addDays( -1 );
- }
+ while( KOGlobals::self()->calendarSystem()->dayOfWeek(mStartDate) != startWeekDay ) {
+ mStartDate = mStartDate.addDays( -1 );
+ }
- bool primary = false;
- uint i;
- for( i = 0; i < mCells.size(); ++i ) {
- QDate date = mStartDate.addDays( i );
- mCells[i]->setDate( date );
+ bool primary = false;
+ uint i;
+ for( i = 0; i < mCells.size(); ++i ) {
+ QDate date = mStartDate.addDays( i );
+ mCells[i]->setDate( date );
#ifndef KORG_NOPLUGINS
- // add holiday, if present
- QString hstring(KOCore::self()->holiday(date));
- mCells[i]->setHoliday( hstring );
+ // add holiday, if present
+ QString hstring(KOCore::self()->holiday(date));
+ mCells[i]->setHoliday( hstring );
#endif
- }
- QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
- for( i = 0; i < 6; ++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;
- mWeekLabels[i]->setWeekNum( wno );
- date = date.addDays( 7 );
- }
- updateView();
+ }
+ QDate date = mStartDate.addDays( mWeekStartsMonday ? 3 : 4 );
+ for( i = 0; i < 6; ++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;
+ mWeekLabels[i]->setWeekNum( wno );
+ date = date.addDays( 7 );
+ }
+ updateView();
}
void KOMonthView::showEvents(QPtrList<Event>)
@@ -942,24 +948,26 @@ 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.
- updateView();
+ // 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("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
int i;
- for( i = 0; i < mCells.count(); ++i ) {
- mCells[i]->updateCell();
- }
+ for( i = 0; i < mCells.count(); ++i ) {
+ mCells[i]->updateCell();
+ }
- //qDebug("KOMonthView::updateView() ");
- processSelectionChange();
- // qDebug("---------------------------------------------------------------------+ ");
+ //qDebug("KOMonthView::updateView() ");
+ processSelectionChange();
+ // qDebug("---------------------------------------------------------------------+ ");
+ setFocus();
}
void KOMonthView::resizeEvent(QResizeEvent * e)
@@ -968,10 +976,10 @@ void KOMonthView::resizeEvent(QResizeEvent * e)
}
void KOMonthView::computeLayout()
{
- // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
- // note this only changes the text if the requested size crosses the
- // threshold between big enough to support the full name and not big
- // enough.
+ // select the appropriate heading string size. E.g. "Wednesday" or "Wed".
+ // note this only changes the text if the requested size crosses the
+ // threshold between big enough to support the full name and not big
+ // enough.
int daysToShow = 7;
bool combinedSatSun = false;
@@ -1073,15 +1081,15 @@ void KOMonthView::computeLayout()
void KOMonthView::showContextMenu( Incidence *incidence )
{
- mContextMenu->showIncidencePopup(incidence);
- /*
- if( incidence && incidence->type() == "Event" ) {
- Event *event = static_cast<Event *>(incidence);
- mContextMenu->showEventPopup(event);
- } else {
- kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
- }
- */
+ mContextMenu->showIncidencePopup(incidence);
+ /*
+ if( incidence && incidence->type() == "Event" ) {
+ Event *event = static_cast<Event *>(incidence);
+ mContextMenu->showEventPopup(event);
+ } else {
+ kdDebug() << "MonthView::showContextMenu(): cast failed." << endl;
+ }
+ */
}
MonthViewCell * KOMonthView::selectedCell( )
{
@@ -1096,34 +1104,51 @@ void KOMonthView::setSelectedCell( MonthViewCell *cell )
mvc->deselect();
} else
mSelectedCell = cell;
- // if ( mSelectedCell )
-// mSelectedCell->select();
- if ( !mSelectedCell )
- emit incidenceSelected( 0 );
- else
- emit incidenceSelected( mSelectedCell->selectedIncidence() );
+ // if ( mSelectedCell )
+ // mSelectedCell->select();
+ if ( !mSelectedCell )
+ emit incidenceSelected( 0 );
+ else
+ emit incidenceSelected( mSelectedCell->selectedIncidence() );
}
void KOMonthView::processSelectionChange()
{
- QPtrList<Incidence> incidences = selectedIncidences();
- if (incidences.count() > 0) {
- emit incidenceSelected( incidences.first() );
- } else {
- emit incidenceSelected( 0 );
- }
+ QPtrList<Incidence> incidences = selectedIncidences();
+ if (incidences.count() > 0) {
+ emit incidenceSelected( incidences.first() );
+ } else {
+ emit incidenceSelected( 0 );
+ }
}
void KOMonthView::clearSelection()
{
- if ( mSelectedCell ) {
- mSelectedCell->deselect();
- mSelectedCell = 0;
- }
+ if ( mSelectedCell ) {
+ mSelectedCell->deselect();
+ mSelectedCell = 0;
+ }
}
void KOMonthView::keyPressEvent ( QKeyEvent * e )
{
-
- e->ignore();
-
+ switch(e->key()) {
+ break;
+ case Key_Up:
+ {
+ emit prevMonth();
+ setFocus();
+ }
+ e->accept();
+ break;
+ case Key_Down:
+ {
+ emit nextMonth();
+ setFocus();
+ }
+ e->accept();
+ break;
+ default:
+ e->ignore();
+ break;
+ }
}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index a965bf3..50903b3 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -237,6 +237,8 @@ class KOMonthView: public KOEventView
protected slots:
void processSelectionChange();
signals:
+ void nextMonth();
+ void prevMonth();
void selectWeekNum ( int );
void showDaySignal( QDate );
protected:
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 94c459b..e8d5ab1 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -457,6 +457,10 @@ void KOViewManager::showMonthView()
connect( mMonthView, SIGNAL( showDaySignal( QDate ) ),
mMainView, SLOT ( showDay( QDate ) ) );
connect(mMainView, SIGNAL(configChanged()), mMonthView, SLOT(updateConfig()));
+ connect( mMonthView, SIGNAL(nextMonth() ),
+ mMainView->navigatorBar(), SIGNAL(goNextMonth() ) );
+ connect( mMonthView, SIGNAL(prevMonth() ),
+ mMainView->navigatorBar(), SIGNAL(goPrevMonth() ) );
mMonthView->updateConfig();
}
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index 145b36c..950d2ec 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -1736,7 +1736,7 @@ void MainWindow::showConfigureAgenda( )
for ( iii = 1;iii<= 10 ;++iii ){
configureAgendaMenu->setItemChecked( (iii+1)*2, false );
}
- configureAgendaMenu->setItemChecked( KOPrefs::instance()->mHourSize, true );
+ configureAgendaMenu->setItemChecked( (KOPrefs::instance()->mHourSize/2)*2, true );
}
void MainWindow::configureAgenda( int item )
{