[Differential] [Commented On] D4216: Enable "Open Config"/"Close Project" always if just one project is loaded

Friedrich W. H. Kossebau noreply at phabricator.kde.org
Fri Jan 20 13:11:23 UTC 2017


kossebau added a comment.


  In https://phabricator.kde.org/D4216#78841, @flherne wrote:
  
  > More generally, it might be better to create a `selectedProjects()` (or so) method instead and use it instead of all the `Core::self()->selectionController()->currentSelection()` stuff?
  >
  > EDIT: I meant including the single-project-always-selected behaviour, so perhaps my suggested name is misleading.
  >
  > As I mentioned on IRC, there are other features that act on the currently-selected project, adding this sort of logic in every such call would be quite ugly.
  
  
  Agreed, this should see some general improvement, not only for consistency. Partially this patch is also testing acceptance of if-one-project-then-always-selected-one :)
  Let's get this one in already though, so it is fixed for now.

INLINE COMMENTS

> flherne wrote in projectcontroller.cpp:228
> Aargh. Maybe something like this?
> 
>   int itemCount = m_projects.size();
>   if ( itemCount > 1 ) {
>       // if only one project loaded, this is always our target, otherwise base on selection
>       if ( auto itemContext = dynamic_cast<ProjectItemContext*>(ICore::self()->selectionController()->currentSelection()) ) {
>           itemCount = itemContext->items().count();
>       }
>   }
>   m_openConfig->setEnabled(itemCount == 1);
>   m_closeProject->setEnabled(itemCount > 0);

Smaller code looks nice :)
But:
What if itemContext is nullptr? I have no idea when this could happen, but if it does, itemCount would not be updated, so `m_openConfig->setEnabled(itemCount == 1);` would not behave as wanted.

REPOSITORY
  R33 KDevPlatform

BRANCH
  enableOpenConfigCloseForSingleProject

REVISION DETAIL
  https://phabricator.kde.org/D4216

EMAIL PREFERENCES
  https://phabricator.kde.org/settings/panel/emailpreferences/

To: kossebau, #kdevelop, brauch
Cc: flherne, kdevelop-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20170120/2aa3f556/attachment.html>


More information about the KDevelop-devel mailing list