summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/komonthview.cpp55
-rw-r--r--korganizer/komonthview.h8
-rw-r--r--korganizer/koviewmanager.cpp2
3 files changed, 48 insertions, 17 deletions
diff --git a/korganizer/komonthview.cpp b/korganizer/komonthview.cpp
index 940d288..ca35a86 100644
--- a/korganizer/komonthview.cpp
+++ b/korganizer/komonthview.cpp
@@ -92,25 +92,25 @@ QString KNoScrollListBox::getWhatsThisText(QPoint p)
{
QListBoxItem* item = itemAt ( p );
if ( ! item ) {
return i18n("Click in the cell\nto add an event!");
}
return KIncidenceFormatter::instance()->getFormattedText(((MonthViewItem*) item)->incidence(),
KOPrefs::instance()->mWTshowDetails,
KOPrefs::instance()->mWTshowCreated,
KOPrefs::instance()->mWTshowChanged);
}
void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
{
-
+ //qDebug("KNoScrollListBox::keyPressEvent ");
switch(e->key()) {
case Key_Right:
if ( e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
e->ignore();
return;
}
scrollBy(10,0);
break;
case Key_Left:
if (e->state() == Qt::ControlButton|| e->state() == Qt::ShiftButton )
{
@@ -145,24 +145,35 @@ void KNoScrollListBox::keyPressEvent(QKeyEvent *e)
if(!itemVisible(currentItem())) {
if(currentItem() == 0) {
setTopItem(0);
} else {
setTopItem(topItem()+1);
}
}
}
break;
case Key_I:
QTimer::singleShot( 11, this, SLOT ( oneDown() ) );
e->ignore();
+ break;
+ case Key_Return:
+ case Key_Enter:
+ {
+ if ( currentItem() >= 0 ) {
+ emit doubleClicked( item( currentItem() ) );
+ e->accept();
+ } else {
+ e->ignore();
+ }
+ }
break;
case Key_Shift:
emit shiftDown();
break;
default:
e->ignore();
break;
}
}
void KNoScrollListBox::oneDown()
{
@@ -304,26 +315,26 @@ void MonthViewItem::paint(QPainter *p)
}
if ( mIncidence->type() == "Todo" ){
Todo* td = ( Todo* ) mIncidence;
if ( td->isCompleted() ) {
int half = size/2;
p->drawLine ( x, heihei/2, x +half , heihei/2 +half ) ;
p->drawLine ( x +half , heihei/2 +half , x +half+half +2 , heihei/2 -2 ) ;
x += half+half + 4;
} else {
int val = td->percentComplete()/20;
- p->fillRect ( x+1, y-1, val ,size+2,Qt::black );
- p->drawRect ( x, y-1,7,size+2);
+ p->fillRect ( x+1, y-2, val ,size+4,Qt::black );
+ p->drawRect ( x, y-2,7,size+4);
x += size + 3;
}
}
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 ) );
@@ -1043,39 +1054,41 @@ KOMonthView::KOMonthView(Calendar *calendar, QWidget *parent, const char *name)
KOWeekButton *label = new KOWeekButton( mMonthView );
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);
mWeekLabels.insert( i, label );
}
mWeekLabels[mNumWeeks]->setText( i18n("W"));
+ mWeekLabels[0]->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);
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 );
connect( cell, SIGNAL( defaultAction( Incidence * ) ),
SLOT( defaultAction( Incidence * ) ) );
connect( cell, SIGNAL( newEventSignal( QDateTime ) ),
@@ -1457,65 +1470,79 @@ void KOMonthView::updateView()
}
}
}
for( i = 0; i < timeSpan+1; ++i ) {
(*cells)[i]->finishUpdateCell();
}
processSelectionChange();
//qApp->processEvents();
for( i = 0; i < timeSpan+1; ++i ) {
(*cells)[i]->repaintfinishUpdateCell();
}
- (*cells)[0]->setFocus();
-
-
+ setKeyBFocus();
#else
// old code
//qDebug("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ");
int i;
for( i = 0; i < (*cells).count(); ++i ) {
(*cells)[i]->updateCell();
}
//qDebug("KOMonthView::updateView() ");
processSelectionChange();
// qDebug("---------------------------------------------------------------------+ ");
(*cells)[0]->setFocus();
#endif
//qDebug("update time %d ", ti.elapsed());
}
+void KOMonthView::setKeyBoardFocus()
+{
+ bool shootAgain = false;
+ if ( mShowWeekView ) {
+ shootAgain = !mWeekLabelsW[0]->hasFocus();
+ mWeekLabelsW[0]->setFocus();
+ }
+ else {
+ shootAgain = !mWeekLabels[0]->hasFocus();
+ mWeekLabels[0]->setFocus();
+ }
+ if ( shootAgain ) {
+ QTimer::singleShot( 0, this, SLOT ( setKeyBFocus() ) );
+ }
+}
+void KOMonthView::setKeyBFocus()
+{
+ //qDebug("KOMonthView::setKeyBFocus() ");
+ QTimer::singleShot( 0, this, SLOT ( setKeyBoardFocus() ) );
+}
void KOMonthView::resizeEvent(QResizeEvent * e)
{
//qDebug("KOMonthView::resizeEvent %d %d -- %d %d ", e->size().width(), e->size().height(), e->oldSize().width(), e->oldSize().height());
if ( isVisible() ) {
//qDebug("KOMonthView::isVisible ");
slotComputeLayout();
} else
mComputeLayoutTimer->start( 100 );
}
void KOMonthView::slotComputeLayout()
{
mComputeLayoutTimer->stop();
//qDebug("KOMonthView::Post - resizeEvent %d %d ", width(), height() );
computeLayout();
- clPending = true;
- if ( mShowWeekView )
- mCellsW[0]->setFocus();
- else
- mCells[0]->setFocus();
-
+ clPending = true;
+ setKeyBFocus();
}
void KOMonthView::computeLayoutWeek()
{
static int lastWid = 0;
static int lastHei = 0;
int daysToShow;
bool combinedSatSun = false;
if (mShowSatSunComp = KOPrefs::instance()->mMonthViewSatSunTog ) {
daysToShow = 6;
combinedSatSun = true;
}
int tWid = topLevelWidget()->size().width();
@@ -1808,42 +1835,38 @@ void KOMonthView::clearSelection()
if ( mSelectedCell ) {
mSelectedCell->deselect();
mSelectedCell = 0;
}
}
void KOMonthView::keyPressEvent ( QKeyEvent * e )
{
//qDebug("KOMonthView::keyPressEvent ");
switch(e->key()) {
case Key_Up:
{
if ( mShowWeekView ) {
- mCellsW[0]->setFocus();
emit selectWeekNum ( currentWeek() - 1 );
}
else {
- mCells[0]->setFocus();
emit prevMonth();
}
}
e->accept();
break;
case Key_Down:
{
if ( mShowWeekView ) {
- mCellsW[0]->setFocus();
emit selectWeekNum ( currentWeek() +1);
}
else {
- mCells[0]->setFocus();
emit nextMonth();
}
}
e->accept();
break;
case Key_Return:
case Key_Enter:
{
selectInternalWeekNum ( currentWeek() );
}
e->accept();
diff --git a/korganizer/komonthview.h b/korganizer/komonthview.h
index 9e724c7..c1ca3d4 100644
--- a/korganizer/komonthview.h
+++ b/korganizer/komonthview.h
@@ -52,24 +52,29 @@ class KOWeekButton : public QPushButton
QPushButton( parent, name)
{
connect( this, SIGNAL( clicked() ),
SLOT( bottonClicked() ));
mNumber = -1;
}
void setWeekNum ( int num ) {mNumber = num; setText( QString::number ( num ));}
int getWeekNum() { return mNumber;}
signals:
void selectWeekNum ( int );
private:
int mNumber;
+ void keyPressEvent ( QKeyEvent * e )
+ {
+ e->ignore();
+ }
+
private slots :
void bottonClicked() { if ( mNumber > 0 ) emit selectWeekNum ( mNumber ); }
};
class KNoScrollListBox: public QListBox
{
Q_OBJECT
public:
KNoScrollListBox(QWidget *parent=0, const char *name=0);
~KNoScrollListBox();
QString getWhatsThisText(QPoint p) ;
@@ -154,25 +159,24 @@ class MonthViewCell : public KNoScrollListBox
void insertTodo(Todo *);
void updateConfig( bool bigFont = false );
void enableScrollBars( bool );
Incidence *selectedIncidence();
QDate selectedIncidenceDate();
QPushButton * dateLabel() { return mLabel; }
void deselect();
void select();
-
#ifdef DESKTOP_VERSION
static QToolTipGroup *toolTipGroup();
#endif
signals:
void defaultAction( Incidence * );
void newEventSignal( QDateTime );
void showDaySignal( QDate );
protected:
QStringList mToolTip;
void resizeEvent( QResizeEvent * );
@@ -248,24 +252,26 @@ class KOMonthView: public KOEventView
virtual void updateConfig();
virtual void showDates(const QDate &start, const QDate &end);
virtual void showEvents(QPtrList<Event> eventList);
void changeEventDisplay(Event *, int);
void clearSelection();
void showContextMenu( Incidence * );
void setSelectedCell( MonthViewCell * );
void switchView();
+ void setKeyBoardFocus();
+ void setKeyBFocus();
protected slots:
void slotComputeLayout();
void selectInternalWeekNum ( int );
void processSelectionChange();
signals:
void nextMonth();
void prevMonth();
void selectWeekNum ( int );
void selectMonth ();
void showDaySignal( QDate );
protected:
diff --git a/korganizer/koviewmanager.cpp b/korganizer/koviewmanager.cpp
index 53cd011..548ffd3 100644
--- a/korganizer/koviewmanager.cpp
+++ b/korganizer/koviewmanager.cpp
@@ -638,24 +638,25 @@ void KOViewManager::showMonthViewWeek()
bool full = true;
if ( mCurrentView == mMonthView)
full = mMainView->leftFrame()->isVisible();
if ( !KOPrefs::instance()->mMonthViewWeek ) {
mMonthView->switchView();
if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
full = false;
else
full = true;
}
mMainView->dateNavigator()->selectWeek();
showView(mMonthView, full );
+ mMonthView->setKeyBFocus();
}
void KOViewManager::showMonth( const QDate & date )
{
mMainView->dateNavigator()->blockSignals( true );
mMainView->dateNavigator()->selectDate( date );
mMainView->dateNavigator()->blockSignals( false );
showMonthView();
}
void KOViewManager::showMonthView()
{
@@ -667,24 +668,25 @@ void KOViewManager::showMonthView()
full = mMainView->leftFrame()->isVisible();
// if(mMonthView == mCurrentView) return;
if ( KOPrefs::instance()->mMonthViewWeek ) {
mMonthView->switchView();
if ( KOPrefs::instance()->mViewChangeHoldNonFullscreen && mMainView->leftFrame()->isVisible() )
full = false;
else
full = true;
}
mMainView->dateNavigator()->selectMonth();
showView(mMonthView, full );
+ mMonthView->setKeyBFocus();
}
void KOViewManager::showTodoView()
{
//mFlagShowNextxDays = false;
if ( !mTodoView ) {
mTodoView = new KOTodoView( mMainView->calendar(), mMainView->viewStack(),
"KOViewManager::TodoView" );
addView( mTodoView );
// QPEApplication::setStylusOperation( mTodoView, QPEApplication::RightOnHold );