-rw-r--r-- | korganizer/calendarview.cpp | 52 | ||||
-rw-r--r-- | korganizer/calendarview.h | 3 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 0 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 21 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.h | 6 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 8 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 | ||||
-rw-r--r-- | korganizer/kotodoview.cpp | 22 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 1 |
9 files changed, 107 insertions, 7 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3dac20b..1009956 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -226,16 +226,20 @@ CalendarView::CalendarView( Calendar *calendar, mCalendar( calendar ), mResourceManager( 0 ) { mEventEditor = 0; mTodoEditor = 0; - init();} + init(); +} void CalendarView::init() { + + setFocusPolicy ( WheelFocus ); + mViewerCallerIsSearchDialog = false; mBlockShowDates = false; beamDialog = new KOBeamPrefs(); mDatePickerMode = 0; mCurrentSyncDevice = ""; writeLocale(); mViewManager = new KOViewManager( this ); @@ -2617,12 +2621,13 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) mCalendar->addEvent( e ); updateView(); } else { delete e; } } + setActiveWindow(); } void CalendarView::newEvent() { // TODO: Replace this code by a common eventDurationHint of KOBaseView. KOAgendaView *aView = mViewManager->agendaView(); @@ -2674,12 +2679,14 @@ void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) if (filter && filter->showCategories()) { mEventEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mEventEditor->setSecrecy( filter->getSecrecy() ); } + mEventEditor->exec(); + setActiveWindow(); } void CalendarView::todoAdded(Todo * t) { changeTodoDisplay ( t ,KOGlobals::EVENTADDED); updateTodoViews(); @@ -2710,12 +2717,14 @@ void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) if (filter && filter->showCategories()) { mTodoEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mTodoEditor->setSecrecy( filter->getSecrecy() ); } + mTodoEditor->exec(); + setActiveWindow(); } void CalendarView::newTodo() { newTodoDateTime( QDateTime(),true ); } @@ -2728,12 +2737,14 @@ void CalendarView::newSubTodo() void CalendarView::newSubTodo(Todo *parentEvent) { showTodoEditor(); mTodoEditor->newTodo(QDateTime(),parentEvent,true); + mTodoEditor->exec(); + setActiveWindow(); } void CalendarView::newFloatingEvent() { DateList tmpList = mNavigator->selectedDates(); QDate date = tmpList.first(); @@ -2750,12 +2761,15 @@ void CalendarView::editEvent( Event *event ) if ( event->isReadOnly() ) { showEvent( event ); return; } showEventEditor(); mEventEditor->editEvent( event , mFlagEditDescription); + mEventEditor->exec(); + setActiveWindow(); + } void CalendarView::editJournal( Journal *jour ) { if ( !jour ) return; mDialogManager->hideSearchDialog(); mViewManager->showJournalView(); @@ -2768,12 +2782,14 @@ void CalendarView::editTodo( Todo *todo ) if ( todo->isReadOnly() ) { showTodo( todo ); return; } showTodoEditor(); mTodoEditor->editTodo( todo ,mFlagEditDescription); + mTodoEditor->exec(); + setActiveWindow(); } KOEventViewerDialog* CalendarView::getEventViewerDialog() { if ( !mEventViewerDialog ) { @@ -2781,12 +2797,14 @@ KOEventViewerDialog* CalendarView::getEventViewerDialog() connect( mEventViewerDialog, SIGNAL( editIncidence( Incidence* )), this, SLOT(editIncidence( Incidence* ) ) ); connect( this, SIGNAL(configChanged()), mEventViewerDialog, SLOT(updateConfig())); connect( mEventViewerDialog, SIGNAL(jumpToTime( const QDate &)), dateNavigator(), SLOT( selectWeek( const QDate & ) ) ); connect( mEventViewerDialog, SIGNAL(showAgendaView( bool ) ), viewManager(), SLOT( showAgendaView( bool ) ) ); + connect( mEventViewerDialog, SIGNAL(signalViewerClosed()), + this, SLOT( slotViewerClosed() ) ); connect( mEventViewerDialog, SIGNAL( todoCompleted(Todo *) ), this, SLOT( todoChanged(Todo *) ) ); mEventViewerDialog->resize( 640, 480 ); } return mEventViewerDialog; @@ -3735,12 +3753,13 @@ void CalendarView::dialogClosing(Incidence *in) { // mDialogList.remove(in); } void CalendarView::showIncidence() { + mViewerCallerIsSearchDialog = false; Incidence *incidence = currentSelection(); if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { ShowIncidenceVisitor v; v.act( incidence, this ); } @@ -3770,12 +3789,19 @@ void CalendarView::deleteIncidence() deleteIncidence(incidence); } } void CalendarView::showIncidence(Incidence *incidence) { + mViewerCallerIsSearchDialog = false; + //qDebug("%x %x ",sender (), mDialogManager->getSearchDialog() ); + if ( sender() && mDialogManager->getSearchDialog() ) { + if ( sender () == mDialogManager->getSearchDialog()->listview() ) { + mViewerCallerIsSearchDialog = true; + } + } if ( incidence ) { ShowIncidenceVisitor v; v.act( incidence, this ); } } @@ -3919,6 +3945,30 @@ void CalendarView::undo_delete() i18n("\nAre you sure you want\nto restore this?"), i18n("KO/Pi Confirmation"),i18n("Restore"))) { mCalendar->undoDeleteIncidence(); updateView(); } } + +void CalendarView::slotViewerClosed() +{ + QTimer::singleShot( 50, this, SLOT ( resetFocus() ) ); +} + +void CalendarView::resetFocus() +{ + if ( mViewerCallerIsSearchDialog ) { + if ( mDialogManager->getSearchDialog()->isVisible() ){ + mDialogManager->getSearchDialog()->raise(); + mDialogManager->getSearchDialog()->setActiveWindow(); + mDialogManager->getSearchDialog()->listview()->resetFocus(); + } else + mViewerCallerIsSearchDialog = false; + } + if ( !mViewerCallerIsSearchDialog ) { + //mViewManager->currentView()->setFocus(); + //qDebug("sssssssssssssssset focus "); + setActiveWindow(); + //setFocus(); + } + mViewerCallerIsSearchDialog = false; +} diff --git a/korganizer/calendarview.h b/korganizer/calendarview.h index e626ea3..664d700 100644 --- a/korganizer/calendarview.h +++ b/korganizer/calendarview.h @@ -453,12 +453,14 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void removeCategories(); void setSyncDevice( QString ); void setSyncName( QString ); void showDay( QDate ); void undo_delete(); protected slots: + void resetFocus(); + void slotViewerClosed(); void timerAlarm(); void suspendAlarm(); void beamDone( Ir *ir ); /** Select a view or adapt the current view to display the specified dates. */ void showDates( const KCal::DateList & ); void selectWeekNum ( int ); @@ -492,12 +494,13 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void showEventEditor(); void showTodoEditor(); void writeLocale(); Todo *selectedTodo(); private: + bool mViewerCallerIsSearchDialog; bool mBlockShowDates; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index d8142ca..2d4a08e 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 23e62d3..8bada3b 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp @@ -17,12 +17,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include <klocale.h> #include <libkcal/event.h> +#include <qtimer.h> #include <qpushbutton.h> #include "koeventviewer.h" #include "koprefs.h" #include <libkcal/todo.h> #include "qapp.h" @@ -36,13 +37,13 @@ KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) true , #else false, #endif i18n("Event Viewer"),Ok|User1|Close,Close, false, i18n("Agenda")) { - + sendSignalViewerClosed = true; mEventViewer = new KOEventViewer(this); mEventViewer->setFont( KOPrefs::instance()->mEventViewFont ); setMainWidget(mEventViewer); setButtonText(Ok, i18n("Edit") ); QObject::connect(findButton( Ok ),SIGNAL(clicked()), @@ -186,12 +187,13 @@ void KOEventViewerDialog::addText(QString text) mEventViewer->addText(text); mEventViewer->setFocus(); //findButton( Close )->setFocus(); } void KOEventViewerDialog::editIncidence() { + sendSignalViewerClosed = false; if ( mSyncMode ) { mSyncResult = 2; accept(); return; } if ( mIncidence ){ @@ -200,13 +202,13 @@ void KOEventViewerDialog::editIncidence() #endif emit editIncidence( mIncidence ); } } void KOEventViewerDialog::showIncidence() { - + sendSignalViewerClosed = false; if ( mSyncMode ) { mSyncResult = 1; accept(); return; } @@ -261,6 +263,21 @@ void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) default: KDialogBase::keyPressEvent ( e ); break; } } +void KOEventViewerDialog::hideEvent ( QHideEvent * e ) +{ + KDialogBase::hideEvent ( e ); + QTimer::singleShot( 1, this, SLOT (slotViewerClosed() ) ); +} + +void KOEventViewerDialog::slotViewerClosed() +{ + if ( sendSignalViewerClosed ) { + //qDebug("KOEventViewerDialog::hideEvent "); + emit signalViewerClosed(); + } + sendSignalViewerClosed = true; +} + diff --git a/korganizer/koeventviewerdialog.h b/korganizer/koeventviewerdialog.h index b6b4103..36431ad 100644 --- a/korganizer/koeventviewerdialog.h +++ b/korganizer/koeventviewerdialog.h @@ -53,17 +53,21 @@ class KOEventViewerDialog : public KDialogBase { void updateConfig(); signals: void editIncidence( Incidence* ); void jumpToTime( const QDate &); void showAgendaView( bool ); void todoCompleted(Todo*); + void signalViewerClosed(); private slots: + void slotViewerClosed(); void editIncidence(); void showIncidence(); - + protected: + void hideEvent ( QHideEvent * e ); private: + bool sendSignalViewerClosed; bool mSyncMode; int mSyncResult; KOEventViewer *mEventViewer; Incidence* mIncidence; void keyPressEvent ( QKeyEvent * e ); }; diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 4a6e17d..6acee75 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -781,13 +781,16 @@ void KOListView::showDates() } void KOListView::hideDates() { showDates(false); } - +void KOListView::resetFocus() +{ + mListView->setFocus(); +} void KOListView::updateView() { mListView->setFocus(); if ( mListView->firstChild () ) mListView->setCurrentItem( mListView->firstChild () ); } @@ -1072,17 +1075,18 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) case Qt::Key_I: { QListViewItem* cn; cn = currentItem(); if ( cn ) { KOListViewItem* ci = (KOListViewItem*)( cn ); if ( ci ){ - emit showIncidence( ci->data()); + //emit showIncidence( ci->data()); cn = cn->nextSibling(); if ( cn ) { setCurrentItem ( cn ); ensureItemVisible ( cn ); + emit showIncidence( ci->data()); } } } e->accept(); } break; diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index bd5bd12..c86449d 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -251,12 +251,13 @@ class KOListView : public KOEventView void readSettings(KConfig *config, QString setting = "KOListView Layout"); void writeSettings(KConfig *config, QString setting = "KOListView Layout"); void updateList(); void setStartDate(const QDate &start); int count(); QString getWhatsThisText(QPoint p); + void resetFocus(); signals: void signalNewEvent(); void beamIncidenceList(QPtrList<Incidence>); public slots: virtual void updateView(); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 3483e95..5e8ea27 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -602,12 +602,17 @@ void KOTodoView::updateView() displayAllFlat(); return; } //qDebug("update "); // kdDebug() << "KOTodoView::updateView()" << endl; QFont fo = KOPrefs::instance()->mTodoViewFont; + Incidence* oldInc = 0; + mActiveItem = (KOTodoViewItem*)mTodoListView->currentItem(); + if (mActiveItem) + oldInc = mActiveItem->todo(); + mTodoListView->clear(); if ( mName == "todolistsmall" ) { if ( KOPrefs::instance()->mTodoViewUsesSmallFont ) { int ps = fo.pointSize() -2; if ( ps > 12 ) ps -= 2; @@ -683,12 +688,29 @@ void KOTodoView::updateView() //qDebug("for end "); // Restore opened/closed state mTodoListView->blockSignals( true ); if( mDocPrefs ) restoreItemState( mTodoListView->firstChild() ); mTodoListView->blockSignals( false ); mTodoListView->setFocus(); + if ( mTodoListView->firstChild () ) { + if ( oldInc ) { + KOTodoViewItem* item = (KOTodoViewItem*)mTodoListView->firstChild (); + while ( item ) { + if ( item->todo() == oldInc ) { + mTodoListView->setCurrentItem( item ); + mTodoListView->ensureItemVisible( item ); + break; + } + item = (KOTodoViewItem*)item->itemBelow(); + } + if ( ! item ) + mTodoListView->setCurrentItem( mTodoListView->firstChild () ); + } else { + mTodoListView->setCurrentItem( mTodoListView->firstChild () ); + } + } processSelectionChange(); } bool KOTodoView::checkTodo( Todo * todo ) { diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 4f2cccf..2de7f28 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -284,13 +284,12 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : #endif updateWeek( mView->startDate() ); connect( mView->dateNavigator(), SIGNAL( datesSelected( const KCal::DateList & ) ), SLOT( updateWeekNum( const KCal::DateList & ) ) ); mBRdisabled = false; //toggleBeamReceive(); - setFocusPolicy ( WheelFocus ); } MainWindow::~MainWindow() { //qDebug("MainWindow::~MainWindow() "); //save toolbar location delete mCalendar; |