author | zautrix <zautrix> | 2005-06-03 09:53:26 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-06-03 09:53:26 (UTC) |
commit | ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f (patch) (side-by-side diff) | |
tree | fd37448d3cf5d7e5a193a8d4cc8e5421d5e7297a /korganizer | |
parent | ce9b826d7c0d9249751f8fb7b791c3757aff3c39 (diff) | |
download | kdepimpi-ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f.zip kdepimpi-ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f.tar.gz kdepimpi-ab0f6af57ebf5b5a6fa2f7e6209fe04aafbfb14f.tar.bz2 |
popup selection fix
-rw-r--r-- | korganizer/koeventpopupmenu.cpp | 27 | ||||
-rw-r--r-- | korganizer/koeventpopupmenu.h | 3 | ||||
-rw-r--r-- | korganizer/kolistview.cpp | 12 | ||||
-rw-r--r-- | korganizer/kolistview.h | 1 |
4 files changed, 38 insertions, 5 deletions
diff --git a/korganizer/koeventpopupmenu.cpp b/korganizer/koeventpopupmenu.cpp index b274810..17ef81e 100644 --- a/korganizer/koeventpopupmenu.cpp +++ b/korganizer/koeventpopupmenu.cpp @@ -27,50 +27,67 @@ #include <kdebug.h> #include <kiconloader.h> #include <libkcal/event.h> #include "koeventpopupmenu.h" 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()))); mEditOnlyItems.append(insertItem (i18n("&Clone..."), this,SLOT(popupClone()))); mEditOnlyItems.append(insertItem (i18n("&Move..."), this,SLOT(popupMove()))); #ifndef DESKTOP_VERSION mEditOnlyItems.append(insertItem (i18n("&Beam..."), this,SLOT(popupBeam()))); #endif mEditOnlyItems.append(insertItem (i18n("&Toggle Cancel"), this,SLOT(popupCancel()))); + isDisabled = false; + QValueList<int>::Iterator it; + for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { + mSingleOnlyItems.append(*it); + } +} +void KOEventPopupMenu::enableDefault( bool enable ) +{ + isDisabled = !enable; + QValueList<int>::Iterator it; + for( it = mSingleOnlyItems.begin(); it != mSingleOnlyItems.end(); ++it ) { + setItemEnabled(*it,enable); + } + } void KOEventPopupMenu::showIncidencePopup(Incidence *incidence) { mCurrentIncidence = incidence; if (mCurrentIncidence) { // Enable/Disabled menu items only valid for editable events. - QValueList<int>::Iterator it; - for( it = mEditOnlyItems.begin(); it != mEditOnlyItems.end(); ++it ) { - setItemEnabled(*it,!mCurrentIncidence->isReadOnly()); - } + if ( !isDisabled ) { + QValueList<int>::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; } } void KOEventPopupMenu::addAdditionalItem(const QIconSet &icon,const QString &text, const QObject *receiver, const char *member, bool editOnly) { if (!mHasAdditionalItems) { mHasAdditionalItems = true; diff --git a/korganizer/koeventpopupmenu.h b/korganizer/koeventpopupmenu.h index 6993899..8fb51fa 100644 --- a/korganizer/koeventpopupmenu.h +++ b/korganizer/koeventpopupmenu.h @@ -35,39 +35,42 @@ using namespace KCal; class KOEventPopupMenu : public QPopupMenu { Q_OBJECT public: KOEventPopupMenu(); void addAdditionalItem(const QIconSet &icon,const QString &text, const QObject *receiver, const char *member, bool editOnly=false); public slots: void showIncidencePopup(Incidence *); + void enableDefault( bool ); protected slots: void popupShow(); void popupEdit(); void popupDelete(); void popupClone(); void popupCancel(); void popupMove(); void popupBeam(); signals: void editIncidenceSignal(Incidence *); void showIncidenceSignal(Incidence *); void deleteIncidenceSignal(Incidence *); void cloneIncidenceSignal(Incidence *); void cancelIncidenceSignal(Incidence *); void moveIncidenceSignal(Incidence *); void beamIncidenceSignal(Incidence *); private: Incidence *mCurrentIncidence; bool mHasAdditionalItems; QValueList<int> mEditOnlyItems; + QValueList<int> 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 @@ -994,24 +994,25 @@ KOListViewItem *KOListView::getItemForEvent(Event *event) void KOListView::defaultItemAction(QListViewItem *i) { KOListViewItem *item = static_cast<KOListViewItem *>( i ); if ( item ) defaultAction( item->data() ); } 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); /* if ( incidence && incidence->type() == "Event" ) { Event *event = static_cast<Event *>( incidence ); mPopupMenu->showEventPopup(event); } */ } } void KOListView::readSettings(KConfig *config, QString setting) @@ -1186,24 +1187,35 @@ void KOListViewListView::keyPressEvent ( QKeyEvent *e) KOListViewListView::KOListViewListView(KOListView * lv ) : KListView( lv, "kolistlistview", false ) { mYMousePos = 0; mPopupTimer = new QTimer(this); connect(mPopupTimer , SIGNAL(timeout()), this, SLOT(popupMenu())); #ifndef DESKTOP_VERSION //QPEApplication::setStylusOperation(viewport(), QPEApplication::RightOnHold ); #endif 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; QPoint vp = contentsToViewport(e->pos()); QListViewItem *item = itemAt(vp); if (!item) { emit newEvent(); return; } KListView::contentsMouseDoubleClickEvent(e); } #if 0 diff --git a/korganizer/kolistview.h b/korganizer/kolistview.h index 2051d60..dee69f6 100644 --- a/korganizer/kolistview.h +++ b/korganizer/kolistview.h @@ -206,24 +206,25 @@ class ListItemVisitor : public Incidence::Visitor @short multi-column list view of various events. @author Preston Brown <pbrown@kde.org> @see KOBaseView, KODayListView */ class KOListView; class KOListViewListView : public KListView { Q_OBJECT public: KOListViewListView(KOListView * lv ); + bool hasMultiSelection(QListViewItem*); signals: void newEvent(); void showIncidence( Incidence* ); public slots: void popupMenu(); private: QPoint mEventPos; QPoint mEventGlobalPos; QTimer* mPopupTimer; int mYMousePos; void keyPressEvent ( QKeyEvent * ) ; void contentsMouseDoubleClickEvent(QMouseEvent *e); |