summaryrefslogtreecommitdiffabout
path: root/korganizer
Side-by-side diff
Diffstat (limited to 'korganizer') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/komonthview.cpp60
-rw-r--r--korganizer/komonthview.h5
2 files changed, 47 insertions, 18 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index e66ddce..4dfb9df 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -93,17 +93,20 @@ KNoScrollListBox::~KNoScrollListBox()
}
void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
{
QListBox::focusInEvent ( e );
- QListBoxItem * i = item ( 0 );
- if ( i && resetOnFocusIn ) {
- setCurrentItem( i );
- setSelected ( 0, true );
- }
+ if ( count() ){
+ int ci = currentItem();
+ if ( ci < 0 ) ci = 0;
+
+ setCurrentItem( ci );
+ setSelected ( ci, true );
+ emit highlighted( item ( ci ) );
+
resetOnFocusIn = true;
if ( KOPrefs::instance()->mEnableMonthScroll || KOPrefs::instance()->mMonthViewWeek ) {
QListBoxItem *fi = firstItem ();
if (fi ) {
int ihei = fi->height( this );
@@ -122,12 +125,13 @@ void KNoScrollListBox::focusInEvent ( QFocusEvent * e )
} else {
setVScrollBarMode(QScrollView::Auto);
setHScrollBarMode(QScrollView::Auto);
}
}
}
+}
void KNoScrollListBox::focusOutEvent ( QFocusEvent * e )
{
int i = currentItem ();
if ( i >= 0 ) {
setSelected ( i, false );
}
@@ -170,37 +174,45 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
case Key_Up:
if( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
e->ignore();
break;
}
if ( count() ) {
+ if ( currentItem() == 0 ) {
+ emit prevCell();
+ } else {
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(e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton) {
e->ignore();
break;
}
if ( count () ) {
+ if ( currentItem()+1 == count () ) {
+ emit nextCell();
+ } else {
setCurrentItem((currentItem()+1)%count());
if(!itemVisible(currentItem())) {
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
+ }
break;
case Key_I:
QTimer::singleShot( 1, this, SLOT ( oneDown() ) );
e->ignore();
break;
case Key_Return:
@@ -223,23 +235,27 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
}
}
void KNoScrollListBox::oneDown()
{
if ( count () ) {
+ if ( currentItem()+1 == count () ) {
+ emit nextCell();
+ } else {
resetOnFocusIn = false;
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;
@@ -470,16 +486,17 @@ MonthViewCell::MonthViewCell( KOMonthView *parent,QWidget* par )
SLOT( defaultAction( QListBoxItem * ) ) );
connect( this, SIGNAL( rightButtonPressed( QListBoxItem *,
const QPoint &) ),
SLOT( contextMenu( QListBoxItem * ) ) );
connect( this, SIGNAL( highlighted( QListBoxItem *) ),
SLOT( selection( QListBoxItem * ) ) );
- connect( this, SIGNAL( clicked( QListBoxItem * ) ),
- SLOT( cellClicked( QListBoxItem * ) ) );
+
+ /*
connect( this, SIGNAL( clicked( QListBoxItem * ) ),
SLOT( selection( QListBoxItem * ) ) );
+ */
}
#ifdef DESKTOP_VERSION
QToolTipGroup *MonthViewCell::toolTipGroup()
{
if (!mToolTipGroup) mToolTipGroup = new QToolTipGroup(0);
return mToolTipGroup;
@@ -986,12 +1003,13 @@ void MonthViewCell::resizeEvent ( QResizeEvent * e )
if ( e )
KNoScrollListBox::resizeEvent ( e );
}
void MonthViewCell::defaultAction( QListBoxItem *item )
{
+
if ( !item ) {
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
return;
}
@@ -1007,28 +1025,19 @@ void MonthViewCell::newEvent()
{
QDateTime dt( date(), QTime( KOPrefs::instance()->mStartTime, 0 ) );
emit newEventSignal( dt );
}
void MonthViewCell::cellClicked( QListBoxItem *item )
{
+ qDebug("CELL ");
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;
@@ -1148,12 +1157,16 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
SIGNAL( newEventSignal( QDateTime ) ) );
connect( cell, SIGNAL( showDaySignal( QDate ) ),
SIGNAL( showDaySignal( QDate ) ) );
+ connect( cell, SIGNAL( nextCell() ),
+ SLOT( nextCell() ) );
+ connect( cell, SIGNAL( prevCell() ),
+ SLOT( prevCell() ) );
}
}
mCellsW.resize( mDaysPerWeek );
for( col = 0; col < mDaysPerWeek; ++col ) {
MonthViewCell *cell = new MonthViewCell( this, mWeekView );
mCellsW.insert( col, cell );
@@ -1161,12 +1174,16 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
SIGNAL( newEventSignal( QDateTime ) ) );
connect( cell, SIGNAL( showDaySignal( QDate ) ),
SIGNAL( showDaySignal( QDate ) ) );
+ connect( cell, SIGNAL( nextCell() ),
+ SLOT( nextCell() ) );
+ connect( cell, SIGNAL( prevCell() ),
+ SLOT( prevCell() ) );
cell->updateConfig(KOPrefs::instance()->mMonthViewUsesBigFont );
}
//connect( mWeekLabels[mNumWeeks], SIGNAL( clicked() ), SLOT( switchView() ) );
mContextMenu = eventPopup();
// updateConfig(); //useless here...
@@ -1971,6 +1988,15 @@ void KOMonthView::keyPressEvent ( QKeyEvent * e )
break;
default:
e->ignore();
break;
}
}
+
+void KOMonthView::nextCell()
+{
+ bool res = focusNextPrevChild ( true );
+}
+void KOMonthView::prevCell()
+{
+ focusNextPrevChild ( false );
+}
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index e39eeb0..c6b6b5e 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -80,12 +80,14 @@ class KNoScrollListBox: public QListBox
QString getWhatsThisText(QPoint p) ;
signals:
void shiftDown();
void shiftUp();
void rightClick();
+ void nextCell();
+ void prevCell();
protected slots:
void oneDown();
void keyPressEvent(QKeyEvent *);
void keyReleaseEvent(QKeyEvent *);
void mousePressEvent(QMouseEvent *);
@@ -185,13 +187,12 @@ class MonthViewCell : public KNoScrollListBox
void showDaySignal( QDate );
protected:
QStringList mToolTip;
void resizeEvent( QResizeEvent * );
-
public slots:
void showDay();
protected slots:
void defaultAction( QListBoxItem * );
void contextMenu( QListBoxItem * );
@@ -253,12 +254,14 @@ class KOMonthView: public KOEventView
bool isUpdatePossible() { return updatePossible; }
MonthViewCell * selectedCell();
bool skipResize;
NavigatorBar* navigatorBar() { return mNavigatorBar ;}
public slots:
+ void nextCell();
+ void prevCell();
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);