Commit a5b1dc94 authored by Adam Goins's avatar Adam Goins
Browse files

Modified updateRecentProjects to display a chronologically ordered list of the...

Modified updateRecentProjects to display a chronologically ordered list of the most recently loaded projects. Fixes #5216.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@8337 41f8697f-d340-4b68-9986-7bafba869bb8
parent 050c0791
Loading
Loading
Loading
Loading
+95 −53
Original line number Diff line number Diff line
@@ -129,9 +129,9 @@ namespace Isis {
    //connect( m_project, SIGNAL(guiCamerasAdded(GuiCameraList *) ),
             //this, SLOT(guiCamerasAddedToProject(GuiCameraList *) ) );

//     connect( m_project, SIGNAL(projectLoaded(Project *) ),
//              this, SLOT(updateRecentProjects(Project *) ) );
//
     connect( m_project, SIGNAL(projectLoaded(Project *) ),
              this, SLOT(updateRecentProjects(Project *) ) );


    connect(m_project, SIGNAL(activeControlSet(bool)), this, SLOT(newActiveControl(bool)));

@@ -304,16 +304,61 @@ namespace Isis {
   * @internal
   *   @history Tyler Wilson 2017-10-17 - This function updates the Recent Projects File
   *                                      menu.  References #4492.
   *   @history Adam Goins 2017-11-27 - Updated this function to add the most recent
   *                project to the recent projects menu. References #5216.
   */
  void Directory::updateRecentProjects(){

    if (m_recentProjectsLoaded)  {
      QMenu *recentProjectsMenu = new QMenu("&Recent Projects");

      foreach (QAction *action, m_fileMenuActions) {

        QString actionText(action->text());
        if (actionText == "&Recent Projects") {
          // Grab the pointer to the actual ""&Recent Projects" menu in IPCE
          recentProjectsMenu = qobject_cast<QMenu*>(action->parentWidget());
          break;
        }
      }

      QString projName = m_recentProjects.at(0).split("/").last();

      QAction *openRecentProjectAction = m_openProjectWorkOrder->clone();
      openRecentProjectAction->setText(projName);
      openRecentProjectAction->setToolTip(m_recentProjects.at(0));

      if (recentProjectsMenu->isEmpty())
      {
        recentProjectsMenu->addAction(openRecentProjectAction);
        return;
      }

      QAction *firstAction = recentProjectsMenu->actions().at(0);

      // If the opened project is already the most recent project, return.
      if (firstAction->text() == projName) {
        return;
      }

      // If the action we're placing at the first index already exists,
      // Then point to that action.
      foreach (QAction *action, recentProjectsMenu->actions()) {
        if (action->text() == projName) {
          openRecentProjectAction = action;
          break;
        }
      }

      recentProjectsMenu->insertAction(firstAction, openRecentProjectAction);
      if (recentProjectsMenu->actions().length() > Project::maxRecentProjects())
      {
        recentProjectsMenu->removeAction(recentProjectsMenu->actions().last());
      }
    }
    else {

      QMenu *fileMenu = new QMenu();

      QMenu *recentProjectsMenu = fileMenu->addMenu("&Recent Projects");
      int nRecentProjects = m_recentProjects.size();

@@ -338,9 +383,7 @@ namespace Isis {
        fileMenu->addSeparator();
        m_fileMenuActions.append( fileMenu->actions() );
        m_recentProjectsLoaded = true;

      }

  }

  /**
@@ -1108,7 +1151,6 @@ namespace Isis {
   * @param project A pointer to the Project to add.
   */
  void Directory::updateRecentProjects(Project *project) {
    if ( !m_recentProjects.contains( project->projectRoot() ) )
    m_recentProjects.insert( 0, project->projectRoot() );
  }

+6 −3
Original line number Diff line number Diff line
@@ -200,6 +200,9 @@ namespace Isis {
   *                           not clean. Fixes #5174.
   *   @history 2017-12-01 Summer Stapleton - Commented-out RemoveImagesWorkOrder being created. 
   *                           Fixes #5224
   *   @history 2017-12-01 Adam Goins Modified updateRecentProjects() to update the recent projects
   *                           menu it display a chronologically ordered list of recently loaded 
   *                           projects. Fixes #5216.
   */
  class Directory : public QObject {
    Q_OBJECT