-rw-r--r-- | korganizer/kotodoview.cpp | 30 | ||||
-rw-r--r-- | korganizer/kotodoview.h | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 00c2d97..27d755e 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -494,24 +494,25 @@ void KOQuickTodo::focusInEvent(QFocusEvent *ev) void KOQuickTodo::focusOutEvent(QFocusEvent *ev) { setText(i18n("Click to add new Todo")); QLineEdit::focusOutEvent(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; QBoxLayout *topLayout = new QVBoxLayout(this); mName = QString ( name ); mBlockUpdate = false; mQuickBar = new QWidget( this ); topLayout->addWidget(mQuickBar); mQuickAdd = new KOQuickTodo(mQuickBar); QBoxLayout *quickLayout = new QHBoxLayout(mQuickBar); @@ -798,46 +799,56 @@ void KOTodoView::paintNeeded() mPendingUpdateBeforeRepaint = false; } } void KOTodoView::paintEvent(QPaintEvent * pevent) { if ( mPendingUpdateBeforeRepaint ) { updateView(); mPendingUpdateBeforeRepaint = false; } 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 ) ps -= 2; fo.setPointSize( ps ); } } mTodoListView->setFont( fo ); // QFontMetrics fm ( KOPrefs::instance()->mTodoViewFont ); //mTodoListView->header()->setMaximumHeight(fm.height()); @@ -855,25 +866,24 @@ void KOTodoView::updateView() QPtrList<Event> l = t->getRelations(); Event *c; for(c=l.first();c;c=l.next()) { kdDebug() << " - relation: " << c->getSummary() << endl; } } */ // 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; // qDebug("todo %s ", todo->summary().latin1()); Incidence *incidence = todo->relatedTo(); while ( incidence ) { if ( incidence->typeID() == todoID ) { //qDebug("related %s ",incidence->summary().latin1() ); if ( !(todoList.contains ( ((Todo* )incidence ) ) ) && incidence->calEnabled() ) { //qDebug("related not found "); todoList.remove( ); @@ -965,24 +975,25 @@ void KOTodoView::resetCurrentItem() if ( foundItem ) { mTodoListView->setSelected ( foundItem, true ); mTodoListView->setCurrentItem( foundItem ); mTodoListView->ensureItemVisible( foundItem ); } else { if ( mTodoListView->firstChild () ) { mTodoListView->setSelected ( mTodoListView->firstChild (), true ); mTodoListView->setCurrentItem( mTodoListView->firstChild () ); } } } processSelectionChange(); + if ( mName != "todolistsmall" ) 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() ) @@ -1091,29 +1102,31 @@ void KOTodoView::showEvents(QPtrList<Event>) } void KOTodoView::printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td) { #ifndef KORG_NOPRINTER calPrinter->preview(CalPrinter::Todolist, fd, td); #endif } 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) { pendingSubtodo = 0; mActiveItem = (KOTodoViewItem *)item; if (item) { switch (column){ case 1: mPriorityPopupMenu->popup(QCursor::pos ()); break; case 2: @@ -1348,42 +1361,42 @@ void KOTodoView::toggleRunningItem() return; Todo * t = mActiveItem->todo(); if ( t->isRunning() ) { KOStopTodoPrefs tp ( t, this ); if (QApplication::desktop()->width() <= 800 ){ int wid = tp.width(); int hei = tp.height(); int xx = (QApplication::desktop()->width()-wid)/2; 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(); int hei = tp.height(); int xx = (QApplication::desktop()->width()-wid)/2; int yy = (QApplication::desktop()->height()-hei)/2; tp.setGeometry( xx,yy,wid,hei ); } if ( !tp.exec() ) return; if ( tp.stopAll() ) { mCalendar->stopAllTodos(); t->setRunning( true ); updateView(); } else { t->setRunning( true ); - updateTodo ( t, 0 ); + updateTodo ( t, KOGlobals::EVENTEDITED ); } } } void KOTodoView::itemClicked(QListViewItem *item) { //qDebug("KOTodoView::itemClicked %d", item); if (!item) { if ( pendingSubtodo != 0 ) { topLevelWidget()->setCaption(i18n("Reparenting aborted!")); } pendingSubtodo = 0; @@ -1496,34 +1509,34 @@ void KOTodoView::setAllClose() void KOTodoView::setOpen( QListViewItem* item, bool setOpenI) { while ( item ) { setOpen( item->firstChild(), setOpenI ); item->setOpen( setOpenI ); item = item->nextSibling(); } } 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); mTodoMap.insert(todo,todoItem); } } resetCurrentItem(); } void KOTodoView::setAllFlat() { @@ -1687,24 +1700,25 @@ void KOTodoView::keyPressEvent ( QKeyEvent * e ) cn = (KOTodoViewItem*)cn->itemBelow(); if ( cn ) { mTodoListView->setCurrentItem ( cn ); mTodoListView->ensureItemVisible ( cn ); } } } e->accept(); } } } + void KOTodoView::updateTodo( Todo * t, int type ) { if ( mBlockUpdate) return; QMap<Todo *,KOTodoViewItem *>::ConstIterator itemIterator; itemIterator = mTodoMap.find(t); if (itemIterator != mTodoMap.end()) { (*itemIterator)->construct(); } else { if ( type == KOGlobals::EVENTADDED ) { insertTodoItem( t ); diff --git a/korganizer/kotodoview.h b/korganizer/kotodoview.h index a8e90e2..9180015 100644 --- a/korganizer/kotodoview.h +++ b/korganizer/kotodoview.h @@ -165,25 +165,25 @@ class KOTodoView : public KOrg::BaseView /** Return number of shown dates. TodoView does not show dates, */ int currentDateCount() { return 0; } void printPreview(CalPrinter *calPrinter, const QDate &fd, const QDate &td); void setDocumentId( const QString & ); void saveLayout(KConfig *config, const QString &group) const; void restoreLayout(KConfig *config, const QString &group); void setNavigator( DateNavigator* nav ) {mNavigator = nav;} QString getWhatsThisText(QPoint p); - void clearList() {mTodoListView->clear(); } + void clearList( bool saveCurrentItem = true ); public slots: void updateView(); void updateConfig(); void changeEventDisplay(Event *, int); void showDates(const QDate &start, const QDate &end); void showEvents(QPtrList<Event> eventList); void clearSelection(); void jumpToDate (); |