author | zautrix <zautrix> | 2005-02-23 18:47:45 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-02-23 18:47:45 (UTC) |
commit | 31f24d21cd23bb7e4033e7ffa000e6c979133ce7 (patch) (side-by-side diff) | |
tree | 2fa81f67efc6544a3664e6039a9602ef6f3466b9 /korganizer | |
parent | faedffc5ce8391204e0340a21eaaf582319ac824 (diff) | |
download | kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.zip kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.gz kdepimpi-31f24d21cd23bb7e4033e7ffa000e6c979133ce7.tar.bz2 |
many focus fixes
-rw-r--r-- | korganizer/calendarview.cpp | 54 | ||||
-rw-r--r-- | korganizer/calendarview.h | 3 | ||||
-rw-r--r-- | korganizer/koeventviewer.h | 2 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.cpp | 21 | ||||
-rw-r--r-- | korganizer/koeventviewerdialog.h | 10 | ||||
-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, 111 insertions, 11 deletions
diff --git a/korganizer/calendarview.cpp b/korganizer/calendarview.cpp index 3dac20b..1009956 100644 --- a/korganizer/calendarview.cpp +++ b/korganizer/calendarview.cpp @@ -224,20 +224,24 @@ CalendarView::CalendarView( Calendar *calendar, QWidget *parent, const char *name ) : CalendarViewBase( parent, name ), 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 ); mDialogManager = new KODialogManager( this ); mEventViewerDialog = 0; @@ -2615,16 +2619,17 @@ void CalendarView::cloneIncidence(Incidence * orgInc ) mEventEditor->editEvent( e ); if ( mEventEditor->exec() ) { 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(); if (aView) { if (aView->selectionStart().isValid()) { @@ -2672,16 +2677,18 @@ void CalendarView::newEvent(QDateTime fromHint, QDateTime toHint, bool allDay) if ( mFilterView->filtersEnabled() ) { CalFilter *filter = mFilterView->selectedFilter(); 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(); } void CalendarView::todoChanged(Todo * t) @@ -2708,16 +2715,18 @@ void CalendarView::newTodoDateTime( QDateTime dt, bool allday ) if ( mFilterView->filtersEnabled() ) { CalFilter *filter = mFilterView->selectedFilter(); if (filter && filter->showCategories()) { mTodoEditor->setCategories(filter->categoryList().join(",") ); } if ( filter ) mTodoEditor->setSecrecy( filter->getSecrecy() ); } + mTodoEditor->exec(); + setActiveWindow(); } void CalendarView::newTodo() { newTodoDateTime( QDateTime(),true ); } void CalendarView::newSubTodo() @@ -2725,17 +2734,19 @@ void CalendarView::newSubTodo() Todo *todo = selectedTodo(); if ( todo ) newSubTodo( todo ); } void CalendarView::newSubTodo(Todo *parentEvent) { showTodoEditor(); - mTodoEditor->newTodo(QDateTime(),parentEvent,true); + mTodoEditor->newTodo(QDateTime(),parentEvent,true); + mTodoEditor->exec(); + setActiveWindow(); } void CalendarView::newFloatingEvent() { DateList tmpList = mNavigator->selectedDates(); QDate date = tmpList.first(); newEvent( QDateTime( date, QTime( 12, 0, 0 ) ), @@ -2748,16 +2759,19 @@ void CalendarView::editEvent( Event *event ) if ( !event ) return; 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(); mNavigator->slotDaySelect( jour->dtStart().date() ); } @@ -2766,29 +2780,33 @@ void CalendarView::editTodo( Todo *todo ) if ( !todo ) return; if ( todo->isReadOnly() ) { showTodo( todo ); return; } showTodoEditor(); mTodoEditor->editTodo( todo ,mFlagEditDescription); + mTodoEditor->exec(); + setActiveWindow(); } KOEventViewerDialog* CalendarView::getEventViewerDialog() { if ( !mEventViewerDialog ) { mEventViewerDialog = new KOEventViewerDialog(this); 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; } void CalendarView::showEvent(Event *event) @@ -3733,16 +3751,17 @@ Todo *CalendarView::selectedTodo() 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 ); } } void CalendarView::editIncidenceDescription() @@ -3768,16 +3787,23 @@ void CalendarView::deleteIncidence() if ( !incidence ) incidence = mTodoList->selectedIncidences().first(); if ( incidence ) { 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 ); } } void CalendarView::editIncidence(Incidence *incidence) { @@ -3917,8 +3943,32 @@ void CalendarView::undo_delete() } if ( KMessageBox::Continue ==KMessageBox::warningContinueCancel(this,undo->summary().left(25) + 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 @@ -451,16 +451,18 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser void manageCategories(); int addCategories(); 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 ); public: @@ -490,16 +492,17 @@ class CalendarView : public KOrg::CalendarViewBase, public KCal::Calendar::Obser // returns KMsgBox::OKCandel() int msgItemDelete(const QString name); void showEventEditor(); void showTodoEditor(); void writeLocale(); Todo *selectedTodo(); private: + bool mViewerCallerIsSearchDialog; bool mBlockShowDates; KSyncManager* mSyncManager; AlarmDialog * mAlarmDialog; QString mAlarmNotification; QString mSuspendAlarmNotification; QTimer* mSuspendTimer; QTimer* mAlarmTimer; QTimer* mRecheckAlarmTimer; diff --git a/korganizer/koeventviewer.h b/korganizer/koeventviewer.h index d8142ca..2d4a08e 100644 --- a/korganizer/koeventviewer.h +++ b/korganizer/koeventviewer.h @@ -65,12 +65,12 @@ class KOEventViewer : public QTextBrowser { private: QTextBrowser *mEventTextView; bool mSyncMode; QString mText; QString mMailSubject; Incidence* mCurrentIncidence; signals: - void launchaddressbook(QString uid); + void launchaddressbook(QString uid); }; #endif diff --git a/korganizer/koeventviewerdialog.cpp b/korganizer/koeventviewerdialog.cpp index 23e62d3..8bada3b 100644 --- a/korganizer/koeventviewerdialog.cpp +++ b/korganizer/koeventviewerdialog.cpp @@ -15,16 +15,17 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software 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" #include "koeventviewerdialog.h" @@ -34,17 +35,17 @@ KOEventViewerDialog::KOEventViewerDialog(QWidget *parent,const char *name) : KDialogBase(parent,name, #ifndef DESKTOP_VERSION 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()), SLOT(editIncidence())); QObject::connect(this,SIGNAL(user1Clicked()), @@ -184,31 +185,32 @@ void KOEventViewerDialog::setJournal(Journal *j) 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 ){ #ifndef DESKTOP_VERSION hide(); #endif emit editIncidence( mIncidence ); } } void KOEventViewerDialog::showIncidence() { - + sendSignalViewerClosed = false; if ( mSyncMode ) { mSyncResult = 1; accept(); return; } if ( mIncidence ){ #ifndef DESKTOP_VERSION @@ -259,8 +261,23 @@ void KOEventViewerDialog::keyPressEvent ( QKeyEvent * e ) accept(); break; 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 @@ -50,22 +50,26 @@ class KOEventViewerDialog : public KDialogBase { void setColorMode( int m ); int executeS( bool ); public slots: void updateConfig(); signals: void editIncidence( Incidence* ); void jumpToTime( const QDate &); void showAgendaView( bool ); - void todoCompleted(Todo*); + void todoCompleted(Todo*); + void signalViewerClosed(); private slots: + void slotViewerClosed(); void editIncidence(); - void showIncidence(); - + void showIncidence(); + protected: + void hideEvent ( QHideEvent * e ); private: + bool sendSignalViewerClosed; bool mSyncMode; int mSyncResult; KOEventViewer *mEventViewer; Incidence* mIncidence; void keyPressEvent ( QKeyEvent * e ); }; #endif diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index 4a6e17d..6acee75 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -779,17 +779,20 @@ void KOListView::showDates() { showDates(true); } void KOListView::hideDates() { showDates(false); } - +void KOListView::resetFocus() +{ + mListView->setFocus(); +} void KOListView::updateView() { mListView->setFocus(); if ( mListView->firstChild () ) mListView->setCurrentItem( mListView->firstChild () ); } void KOListView::updateConfig() { @@ -1070,21 +1073,22 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) e->accept(); break; 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; case Qt::Key_Return: case Qt::Key_Enter: diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index bd5bd12..c86449d 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -249,16 +249,17 @@ class KOListView : public KOEventView const QDate &, const QDate &); 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(); virtual void showDates(const QDate &start, const QDate &end); virtual void showEvents(QPtrList<Event> eventList); diff --git a/korganizer/kotodoview.cpp b/korganizer/kotodoview.cpp index 3483e95..5e8ea27 100644 --- a/korganizer/kotodoview.cpp +++ b/korganizer/kotodoview.cpp @@ -600,16 +600,21 @@ void KOTodoView::updateView() //qDebug("KOTodoView::updateView() %x", this); if ( isFlatDisplay ) { 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; fo.setPointSize( ps ); } @@ -681,16 +686,33 @@ 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 ) { if ( !KOPrefs::instance()->mShowCompletedTodo && todo->isCompleted() ) return false; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 4f2cccf..2de7f28 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -282,17 +282,16 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : #ifndef DESKTOP_VERSION infrared = 0; #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; delete mSyncManager; #ifndef DESKTOP_VERSION |