summaryrefslogtreecommitdiffabout
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp26
-rw-r--r--korganizer/kotodoview.h1
2 files changed, 17 insertions, 10 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 8d354c8..e2966f8 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -735,39 +735,38 @@ void KOTodoView::paintEvent(QPaintEvent * pevent)
updateView();
mPendingUpdateBeforeRepaint = false;
}
KOrg::BaseView::paintEvent( pevent);
}
void KOTodoView::updateView()
{
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
if ( !isVisible() ) {
mPendingUpdateBeforeRepaint = true;
return;
}
- storeCurrentItem();
//qDebug("KOTodoView::updateView() %x", this);
if ( isFlatDisplay ) {
displayAllFlat();
- resetCurrentItem();
return;
}
+ storeCurrentItem();
//qDebug("update ");
// kdDebug() << "KOTodoView::updateView()" << endl;
QFont fo = KOPrefs::instance()->mTodoViewFont;
mTodoListView->clear();
if ( mName == "todolistsmall" ) {
if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
int ps = fo.pointSize() -2;
if ( ps > 12 )
ps -= 2;
fo.setPointSize( ps );
}
}
mTodoListView->setFont( fo );
@@ -822,58 +821,57 @@ void KOTodoView::updateView()
}
if ( next )
todo = todoList.next();
}
for(todo = todoList.first(); todo; todo = todoList.next()) {
if (!mTodoMap.contains(todo) && checkTodo( todo ) )
{
insertTodoItem(todo);
}
}
// Restore opened/closed state
mTodoListView->blockSignals( true );
if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() );
mTodoListView->blockSignals( false );
resetCurrentItem();
- processSelectionChange();
}
void KOTodoView::storeCurrentItem()
{
mCurItem = 0;
mCurItemRootParent = 0;
mCurItemParent = 0;
mCurItemAbove = 0;
mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem();
if (mActiveItem) {
mCurItem = mActiveItem->todo();
KOTodoViewItem* activeItemAbove = (KOTodoViewItem*)mActiveItem->itemAbove ();
if ( activeItemAbove )
mCurItemAbove = activeItemAbove->todo();
mCurItemRootParent = mCurItem;
mCurItemParent = mCurItemRootParent->relatedTo();
while ( mCurItemRootParent->relatedTo() != 0 )
mCurItemRootParent = mCurItemRootParent->relatedTo();
}
mActiveItem = 0;
}
void KOTodoView::resetCurrentItem()
{
- mTodoListView->setFocus();
+ //mTodoListView->setFocus();
KOTodoViewItem* foundItem = 0;
KOTodoViewItem* foundItemRoot = 0;
KOTodoViewItem* foundItemParent = 0;
KOTodoViewItem* foundItemAbove = 0;
if ( mTodoListView->firstChild () ) {
if ( mCurItem ) {
KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild ();
while ( item ) {
if ( item->todo() == mCurItem ) {
foundItem = item;
break;
} else if ( item->todo() == mCurItemAbove ) {
foundItemAbove = item;
}
if ( item->todo() == mCurItemRootParent ) {
@@ -883,38 +881,48 @@ void KOTodoView::resetCurrentItem()
foundItemParent = item;
}
item = (KOTodoViewItem*)item->itemBelow();
}
if ( ! foundItem ) {
if ( foundItemParent ) {
foundItem = foundItemParent;
} else {
if ( foundItemRoot )
foundItem = foundItemRoot;
else
foundItem = foundItemAbove;
}
}
}
if ( foundItem ) {
+ mTodoListView->setSelected ( foundItem, true );
mTodoListView->setCurrentItem( foundItem );
mTodoListView->ensureItemVisible( foundItem );
- } else {
- mTodoListView->setCurrentItem( mTodoListView->firstChild () );
+ } else {
+ if ( mTodoListView->firstChild () ) {
+ mTodoListView->setSelected ( mTodoListView->firstChild (), true );
+ mTodoListView->setCurrentItem( mTodoListView->firstChild () );
+ }
}
}
+ processSelectionChange();
+ QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
+}
+void KOTodoView::resetFocusToList()
+{
+ topLevelWidget()->setActiveWindow();
mTodoListView->setFocus();
}
//Incidence * mCurItem, *mCurItemRootParent,*mCurItemAbove;
bool KOTodoView::checkTodo( Todo * todo )
{
if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() )
return false;
if ( !todo->isCompleted() ) {
if ( todo->hasDueDate() && todo->dtDue().date() <= QDate::currentDate() )
return true;
}
if ( KOPrefs::instance()->mHideNonStartedTodos && mNavigator ) {
if ( todo->hasStartDate() )
if ( mNavigator->selectedDates().last() < todo->dtStart().date() )
return false;
@@ -1391,61 +1399,59 @@ void KOTodoView::setAllClose()
}
setOpen(mTodoListView->firstChild(), false);
resetCurrentItem();
}
void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
{
while ( item ) {
setOpen( item->firstChild(), setOpenI );
item->setOpen( setOpenI );
item = item->nextSibling();
}
}
void KOTodoView::displayAllFlat()
{
+ storeCurrentItem();
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
mPopupMenu->setItemChecked( 8,true );
isFlatDisplay = true;
QPtrList<Todo> todoList = calendar()->todos();
mTodoMap.clear();
mTodoListView->clear();
Todo *todo;
for(todo = todoList.first(); todo; todo = todoList.next()) {
KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
mTodoMap.insert(todo,todoItem);
}
- mTodoListView->setFocus();
- processSelectionChange();
+ resetCurrentItem();
}
void KOTodoView::setAllFlat()
{
if ( isFlatDisplay ) {
isFlatDisplay = false;
mPopupMenu->setItemChecked( 8,false );
updateView();
return;
}
- storeCurrentItem();
displayAllFlat();
- resetCurrentItem();
}
void KOTodoView::purgeCompleted()
{
emit purgeCompletedSignal();
}
void KOTodoView::toggleQuickTodo()
{
if ( mQuickAdd->isVisible() ) {
mQuickAdd->hide();
KOPrefs::instance()->mEnableQuickTodo = false;
}
else {
mQuickAdd->show();
KOPrefs::instance()->mEnableQuickTodo = true;
diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h
index 1b31d0d..9ae7f53 100644
--- a/korganizer/kotodoview.h
+++ b/korganizer/kotodoview.h
@@ -211,32 +211,33 @@ class KOTodoView : public KOrg::BaseView
void setAllOpen();
void setAllClose();
void setAllFlat();
void displayAllFlat();
void purgeCompleted();
void toggleCompleted();
void toggleRunning();
void toggleQuickTodo();
void updateTodo( Todo *, int );
void itemClicked(QListViewItem *);
void itemStateChanged(QListViewItem *);
void modified(bool);
void itemDoubleClicked(QListViewItem *item);
+ void resetFocusToList();
signals:
void newTodoSignal();
void newSubTodoSignal(Todo *);
void unparentTodoSignal(Todo *);
void reparentTodoSignal( Todo *,Todo * );
void showTodoSignal(Todo *);
void editTodoSignal(Todo *);
void deleteTodoSignal(Todo *);
void todoModifiedSignal (Todo *, int);
void isModified(bool);
void cloneTodoSignal( Incidence * );
void cancelTodoSignal( Incidence * );
void moveTodoSignal( Incidence * );