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

Francis Herne noreply at phabricator.kde.org
Fri Jan 20 09:44:56 UTC 2017


flherne added a comment.


  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?
  
  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.

INLINE COMMENTS

> projectcontroller.cpp:228
> +        // if only one project loaded, this is always our target
> +        int itemCount = (m_projects.size() == 1) ? 1 : 0;
> +

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);

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/03396e4f/attachment-0001.html>


More information about the KDevelop-devel mailing list