Allow the default context menu for EntityTreeView to be specified
Review Request #104132 - Created March 1, 2012 and submitted
The referenced bug happens because EntityTreeView::contextMenuEvent() looks at the clicked item to see whether it is an Item or a Collection, and chooses the context menu accordingly. However, if the menu button click is over blank space then there is no item to test, so the code at present arbitrarily chooses the collection menu. This is incorrect for the middle column of KAddressBook. This change adds a Boolean flag to the EntityTreeView to specify whether it contains Items or Collections, and for a menu click over blank space this is used to choose the appropriate menu. For a menu click over an item this flag is not used. The default is true (i.e. Collections), so the operation of the library with unmodified applications is the same as before. Some discussion at http://lists.kde.org/?t=133035828400002&r=1&w=2
Built kdepimlibs with this change and modified KAddressBook to call setIsCollection(false) for the middle column. The correct context menu is displayed whether over an address item or over blank space.
I don't think this is the right approach but I like the idea to allow specifying a default context menu. I suggest having a method to allows to set a default context menu name as a string. the default value of the internal property can be the one for collection to be compatible. - if index.isValid() -> either item or collection menu - else try to retrieve default context menu by name. if valid -> show
"item" in this context is IMHO a bit too ambiguous in this context. Maybe something like "This menu is used as a fallback if the context of the menu request is neither an item nor a collection, e.g. click on an empty area inside the view"
Just initialize this with d->mDefaultPopupMenu and make the "else" body the "then" body with inverted condition