summaryrefslogtreecommitdiffabout
path: root/korganizer/kotodoview.cpp
Side-by-side diff
Diffstat (limited to 'korganizer/kotodoview.cpp') (more/less context) (show whitespace changes)
-rw-r--r--korganizer/kotodoview.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp
index 00c2d97..27d755e 100644
--- a/korganizer/kotodoview.cpp
+++ b/korganizer/kotodoview.cpp
@@ -502,8 +502,9 @@ void KOQuickTodo::focusOutEvent(QFocusEvent *ev)
KOTodoView::KOTodoView(Calendar *calendar,QWidget* parent,const char* name) :
KOrg::BaseView(calendar,parent,name)
{
+ mActiveItem = 0;
mCategoryPopupMenu = 0;
mPendingUpdateBeforeRepaint = false;
isFlatDisplay = false;
mNavigator = 0;
@@ -806,30 +807,40 @@ void KOTodoView::paintEvent(QPaintEvent * pevent)
}
KOrg::BaseView::paintEvent( pevent);
}
+void KOTodoView::clearList( bool saveCurrentItem ) // default true
+{
+ if ( mTodoListView->childCount() ) {
+ if ( saveCurrentItem )
+ storeCurrentItem();
+ mTodoListView->clear();
+ mTodoMap.clear();
+ }
+}
void KOTodoView::updateView()
{
+ mActiveItem = 0;
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
if ( !isVisible() ) {
+ clearList ();
mPendingUpdateBeforeRepaint = true;
return;
}
//qDebug("KOTodoView::updateView() %x", this);
if ( isFlatDisplay ) {
displayAllFlat();
return;
}
- storeCurrentItem();
//qDebug("update ");
// kdDebug() << "KOTodoView::updateView()" << endl;
QFont fo = KOPrefs::instance()->mTodoViewFont;
+ clearList ();
- mTodoListView->clear();
if ( mName == "todolistsmall" ) {
if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) {
int ps = fo.pointSize() -2;
if ( ps > 12 )
@@ -863,9 +874,8 @@ void KOTodoView::updateView()
// Put for each Event a KOTodoViewItem in the list view. Don't rely on a
// specific order of events. That means that we have to generate parent items
// recursively for proper hierarchical display of Todos.
- mTodoMap.clear();
Todo *todo;
todo = todoList.first();// todo; todo = todoList.next()) {
while ( todo ) {
bool next = true;
@@ -973,8 +983,9 @@ void KOTodoView::resetCurrentItem()
}
}
}
processSelectionChange();
+ if ( mName != "todolistsmall" )
QTimer::singleShot( 100, this, SLOT ( resetFocusToList() ));
}
void KOTodoView::resetFocusToList()
{
@@ -1099,13 +1110,15 @@ void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd,
}
void KOTodoView::editItem(QListViewItem *item )
{
+ if ( item )
emit editTodoSignal(((KOTodoViewItem *)item)->todo());
}
void KOTodoView::showItem(QListViewItem *item,const QPoint &,int)
{
+ if ( item )
emit showTodoSignal(((KOTodoViewItem *)item)->todo());
}
void KOTodoView::popupMenu(QListViewItem *item,const QPoint &p,int column)
@@ -1356,9 +1369,9 @@ void KOTodoView::toggleRunningItem()
int yy = (QApplication::desktop()->height()-hei)/2;
tp.setGeometry( xx,yy,wid,hei );
}
tp.exec();
- updateTodo ( t, 0 );
+ updateTodo ( t, KOGlobals::EVENTEDITED );
} else {
KOStartTodoPrefs tp ( t->summary(), this );
if (QApplication::desktop()->width() <= 800 ){
int wid = tp.width();
@@ -1373,9 +1386,9 @@ void KOTodoView::toggleRunningItem()
t->setRunning( true );
updateView();
} else {
t->setRunning( true );
- updateTodo ( t, 0 );
+ updateTodo ( t, KOGlobals::EVENTEDITED );
}
}
}
@@ -1504,18 +1517,18 @@ void KOTodoView::setOpen( QListViewItem* item, bool setOpenI)
}
void KOTodoView::displayAllFlat()
{
- storeCurrentItem();
+
+ mActiveItem = 0;
pendingSubtodo = 0;
if ( mBlockUpdate ) {
return;
}
+ clearList ();
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()) {
if ( checkTodo( todo ) ) {
KOTodoViewItem *todoItem = new KOTodoViewItem(mTodoListView,todo,this);
@@ -1695,8 +1708,9 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e )
e->accept();
}
}
}
+
void KOTodoView::updateTodo( Todo * t, int type )
{
if ( mBlockUpdate)
return;