From ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f Mon Sep 17 00:00:00 2001 From: zautrix Date: Fri, 03 Jun 2005 09:53:26 +0000 Subject: popup selection fix --- diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index b274810..17ef81e 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp @@ -36,7 +36,8 @@ KOEventPopupMenu::KOEventPopupMenu() mCurrentIncidence = 0; mHasAdditionalItems = false; - insertItem (i18n("&Show"),this,SLOT(popupShow())); + + mSingleOnlyItems.append( insertItem (i18n("&Show"),this,SLOT(popupShow()))); mEditOnlyItems.append(insertItem (i18n("&Edit..."),this,SLOT(popupEdit()))); mEditOnlyItems.append(insertItem (i18n("&Delete"), this,SLOT(popupDelete()))); @@ -50,6 +51,20 @@ KOEventPopupMenu::KOEventPopupMenu() #endif mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), this,SLOT(popupCancel()))); + isDisabled = false; + QValueList::Iterator it; + for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { + mSingleOnlyItems.append(*it); + } +} +void KOEventPopupMenu::enableDefault( bool enable ) +{ + isDisabled = !enable; + QValueList::Iterator it; + for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { + setItemEnabled(*it,enable); + } + } void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) @@ -58,10 +73,12 @@ void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) if (mCurrentIncidence) { // Enable/Disabled menu items only valid for editable events. - QValueList::Iterator it; - for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { - setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); - } + if ( !isDisabled ) { + QValueList::Iterator it; + for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { + setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); + } + } popup(QCursor::pos()); } else { kdDebug() << "KOEventPopupMenu::showEventPopup(): No event selected" << endl; diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h index 6993899..8fb51fa 100644 --- a/korganizer/koeventpopupmenu.h +++ b/korganizer/koeventpopupmenu.h @@ -44,6 +44,7 @@ class KOEventPopupMenu : public QPopupMenu { public slots: void showIncidencePopup(Incidence *); + void enableDefault( bool ); protected slots: void popupShow(); @@ -68,6 +69,8 @@ class KOEventPopupMenu : public QPopupMenu { bool mHasAdditionalItems; QValueList mEditOnlyItems; + QValueList mSingleOnlyItems; + bool isDisabled; }; #endif diff --git a/korganizer/kolistview.cpp b/korganizer/kolistview.cpp index b94916a..02247c8 100644 --- a/korganizer/kolistview.cpp +++ b/korganizer/kolistview.cpp @@ -1003,6 +1003,7 @@ void KOListView::popupMenu(QListViewItem *item,const QPoint &,int) mActiveItem = (KOListViewItem *)item; if (mActiveItem) { Incidence *incidence = mActiveItem->data(); + mPopupMenu->enableDefault( !mListView->hasMultiSelection( item ) ); mPopupMenu->showIncidencePopup(incidence); /* @@ -1195,6 +1196,17 @@ KOListViewListView::KOListViewListView(KOListView * lv ) setSelectionMode( QListView::Multi ); setMultiSelection( true); } +bool KOListViewListView::hasMultiSelection(QListViewItem* item) +{ + int selCount = 0; + QListViewItem *qitem = firstChild (); + while ( qitem ) { + if ( qitem->isSelected() && item != qitem ) + return true; + qitem = qitem->nextSibling(); + } + return false; +} void KOListViewListView::contentsMouseDoubleClickEvent(QMouseEvent *e) { if (!e) return; diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index 2051d60..dee69f6 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -215,6 +215,7 @@ class KOListViewListView : public KListView Q_OBJECT public: KOListViewListView(KOListView * lv ); + bool hasMultiSelection(QListViewItem*); signals: void newEvent(); void showIncidence( Incidence* ); -- cgit v0.9.0.2