Commit 7644650d authored by chrisryancombs's avatar chrisryancombs
Browse files

Merged ipceDocks into ipceBundleWindow

parents 7a9ddb52 a80cd0be
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -42,3 +42,4 @@ print.prt
*/tsts/*/input/*
*/tsts/*/truth/*
*/tsts/*/output/*
data/
+117 −93
Original line number Diff line number Diff line
@@ -79,13 +79,6 @@ namespace Isis {
      QMainWindow(parent) {
    m_maxThreadCount = -1;

//  QMdiArea *centralWidget = new QMdiArea;
//  centralWidget->setActivationOrder(QMdiArea::StackingOrder);

//  connect(centralWidget, SIGNAL( subWindowActivated(QMdiSubWindow *) ),
//          this, SLOT( onSubWindowActivated(QMdiSubWindow *) ) );


    QWidget *centralWidget = new QWidget;
    setCentralWidget(centralWidget);
    setTabPosition(Qt::LeftDockWidgetArea, QTabWidget::North);
@@ -214,12 +207,10 @@ namespace Isis {
      addDockWidget(area, dock, orientation);
    }

    // Connections for cleanup in both directions to make sure both views and docks are cleaned up
    connect(newWidget, SIGNAL(destroyed(QObject *)), dock, SLOT(deleteLater()));
    // When dock widget is destroyed, make sure the view it holds is also destroyed
    connect(dock, SIGNAL(destroyed(QObject *)), newWidget, SLOT(deleteLater()));
    // The list of dock widgets needs cleanup as each view is destroyed
    connect(dock, SIGNAL(destroyed(QObject *)),
            this, SLOT(cleanupViewDockList(QObject *)));
    connect(dock, SIGNAL(destroyed(QObject *)), this, SLOT(cleanupViewDockList(QObject *)));

    // Save view docks for cleanup during a project close
    m_viewDocks.append(dock);
@@ -270,6 +261,22 @@ namespace Isis {
  }


  /**
   * This is needed so that the project clean flag is not set to false when move and resize events
   * are emitted from ipce.cpp when IpceMainWindow::show() is called.
   * The non-spontaneous or internal QShowEvent is only emitted once from ipce.cpp, so the project
   * clean flag can be reset.
   *
   * @param event QShowEvent*
   *
   */
  void IpceMainWindow::showEvent(QShowEvent *event) {
    if (!event->spontaneous()) {
      m_directory->project()->setClean(true);
    }
  }


  /**
   * Filters out events from views so they can be handled by the main
   * window. Filters out DragEnter Drop and ContextMenu events from
@@ -362,17 +369,6 @@ namespace Isis {
    m_editMenuActions.append(undoAction);
    m_editMenuActions.append(redoAction);

//  m_cascadeViewsAction = new QAction("Cascade Views", this);
//  connect(m_cascadeViewsAction, SIGNAL( triggered() ),
//          centralWidget(), SLOT( cascadeSubWindows() ) );
//  m_viewMenuActions.append(m_cascadeViewsAction);
//
//  m_tileViewsAction = new QAction("Tile Views", this);
//  connect(m_tileViewsAction, SIGNAL( triggered() ),
//          centralWidget(), SLOT( tileSubWindows() ) );
//  m_viewMenuActions.append(m_tileViewsAction);


    QAction *threadLimitAction = new QAction("Set Thread &Limit", this);
    connect(threadLimitAction, SIGNAL(triggered()),
            this, SLOT(configureThreadLimit()));
@@ -492,49 +488,18 @@ namespace Isis {


  /**
   * Write the window positioning and state information out to a
   * config file. This allows us to restore the settings when we
   * create another main window (the next time this program is run).
   *
   * The state will be saved according to the currently loaded project and its name.
   *
   * When no project is loaded (i.e. the default "Project" is open), the config file used is
   * $HOME/.Isis/$APPNAME/$APPNAME_Project.config.
   * When a project, ProjectName, is loaded, the config file used is
   * $HOME/.Isis/$APPNAME/$APPNAME_ProjectName.config.
   *
   * @param[in] project Pointer to the project that is currently loaded (default is "Project")
   *
   * @internal
   *   @history 2016-11-09 Ian Humphrey - Settings are now written according to the loaded project.
   *                           References #4358.
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   * Writes the global settings like recent projects and thread count.
   */
  void IpceMainWindow::writeSettings(Project *project) {
  void IpceMainWindow::writeGlobalSettings(Project *project) {

    // Ensure that we are not using a NULL pointer
    if (!project) {
      QString msg = "Cannot write settings with a NULL Project pointer.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    QString appName = QApplication::applicationName();
    QSettings projectSettings(
        FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + project->name() + ".config")
          .expanded(),
        QSettings::NativeFormat);

    QSettings globalSettings(
        FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + "Project.config")
          .expanded(),
    QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    projectSettings.setValue("geometry", QVariant(geometry()));
    projectSettings.setValue("windowState", saveState());
//  projectSettings.setValue("size", size());
//  projectSettings.setValue("pos", pos());

    projectSettings.setValue("maxThreadCount", m_maxThreadCount);
    if (project->isTemporaryProject()) {
      globalSettings.setValue("geometry", QVariant(geometry()));
    }

    globalSettings.setValue("maxThreadCount", m_maxThreadCount);
    globalSettings.setValue("maxRecentProjects",m_maxRecentProjects);
@@ -596,12 +561,49 @@ namespace Isis {
      QString projName = project->name();
      QString t0String=QString::number(t0);

      if (!project->projectRoot().contains("tmpProject") &&
      if (!project->isTemporaryProject() &&
          !projectPaths.contains( project->projectRoot())) {
        globalSettings.setValue(t0String+"%%%%%"+projName,project->projectRoot());
      }
    }
    globalSettings.endGroup();
    globalSettings.sync();
  }


  /**
   * Write the window positioning and state information out to a
   * config file. This allows us to restore the settings when we
   * create another main window (the next time this program is run).
   *
   * The state will be saved according to the currently loaded project and its name.
   *
   * When no project is loaded (i.e. the default "Project" is open), the config file used is
   * $HOME/.Isis/$APPNAME/ipce.config.
   * When a project, ProjectName, is loaded, the config file used is
   * project->projectRoot()/ipce.config.
   *
   * @param[in] project Pointer to the project that is currently loaded (default is "Project")
   *
   * @internal
   *   @history 2016-11-09 Ian Humphrey - Settings are now written according to the loaded project.
   *                           References #4358.
   *   @history 2017-10-17 Tyler Wilson Added a [recent projects] group for the saving and
   *                           restoring of recently opened projects.  References #4492.
   */
  void IpceMainWindow::writeSettings(Project *project) {

    // Ensure that we are not using a NULL pointer
    if (!project) {
      QString msg = "Cannot write settings with a NULL Project pointer.";
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }
    QSettings projectSettings(FileName(project->newProjectRoot() + "/ipce.config").expanded(),
        QSettings::NativeFormat);

    projectSettings.setValue("geometry", QVariant(geometry()));
    projectSettings.setValue("windowState", saveState());
    projectSettings.sync();
  }


@@ -609,9 +611,9 @@ namespace Isis {
   * Read the window positioning and state information from the config file.
   *
   * When running ipce without opening a project, the config file read is
   * $HOME/.Isis/$APPNAME/$APPNAME_Project.config
   * Otherwise, when running ipce and opening a project (ProjectName), the config file read is
   * $HOME/.Isis/$APPNAME/$APPNAME_ProjectName.config
   * $HOME/.Isis/$APPNAME/ipce.config
   * When running ipce and opening a project (ProjectName), the config file read is
   * project->projectRoot()/ipce.config
   *
   * @param[in] project (Project *) The project that was loaded.
   *
@@ -619,8 +621,10 @@ namespace Isis {
   *   @history Ian Humphrey - Settings are now read on a project name basis. References #4358.
   *   @history Tyler Wilson 2017-11-02 - Settings now read recent projects.  References #4492.
   *   @history Tyler Wilson 2017-11-13 - Commented out a resize call near the end because it
   *                                      was messing with the positions of widgets after a
   *                                      project was loaded.  Fixes #5075.
   *                was messing with the positions of widgets after a project was loaded.
   *                Fixes #5075.
   *   @history Makayla Shepherd 2018-06-10 - Settings are read from the project root ipce.config.
   *                If that does not exist then we read from .Isis/ipce/ipce.config.
   */
  void IpceMainWindow::readSettings(Project *project) {
    // Ensure that the Project pointer is not NULL
@@ -629,31 +633,59 @@ namespace Isis {
      throw IException(IException::Programmer, msg, _FILEINFO_);
    }

    // Set the path of the settings file
    // The default is to assume that the project has an ipce.config in it
    // If the file does not exist then we read settings from .Isis/ipce/ipce.config
    QString appName = QApplication::applicationName();
    QString filePath = project->projectRoot() + "/ipce.config";
    bool isFullScreen = false;
    if (!FileName(filePath).fileExists()) {
      filePath = "$HOME/.Isis/" + appName + "/ipce.config";
      // If the $HOME/.Isis/ipce/ipce.config does not exist then we want ipce to show up in
      // in full screen. In other words the default geometry is full screen
      if (!FileName(filePath).fileExists()) {
        isFullScreen = true;
      }
    }

    QSettings settings(
        FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + project->name() + ".config")
          .expanded(), QSettings::NativeFormat);

    // General settings
    if (project->name() == "Project") {
      setWindowTitle("ipce");
    }
    else {
      setWindowTitle( project->name() );
    }

    QSettings projectSettings(FileName(filePath).expanded(), QSettings::NativeFormat);

    if (!isFullScreen) {
      setGeometry(projectSettings.value("geometry").value<QRect>());
      if (!project->isTemporaryProject()) {
        restoreState(projectSettings.value("windowState").toByteArray());
      }
    }
    else {
      this->showMaximized();
    }

    if (project->name() == "Project") {
      QSettings globalSettings(FileName("$HOME/.Isis/" + appName + "/ipce.config").expanded(),
                              QSettings::NativeFormat);

      QStringList projectNameList;
      QStringList projectPathList;
      settings.beginGroup("recent_projects");
      QStringList keys = settings.allKeys();
      globalSettings.beginGroup("recent_projects");
      QStringList keys = globalSettings.allKeys();
      QRegExp underscore("%%%%%");

      foreach (QString key, keys) {
        QString childKey = "recent_projects/"+key;
        QString projectPath = settings.value(key).toString();
        QString projectPath = globalSettings.value(key).toString();
        QString projectName = projectPath.split("/").last();
        projectPathList.append(projectPath) ;
        projectNameList.append(projectName);
      }

      settings.endGroup();
      globalSettings.endGroup();

      QStringList projectPathReverseList;
      for (int i = projectPathList.count() - 1; i >= 0; i--) {
@@ -675,26 +707,17 @@ namespace Isis {

      m_directory->setRecentProjectsList(projectPathListTruncated);
      m_directory->updateRecentProjects();
      m_maxThreadCount = settings.value("maxThreadCount", m_maxThreadCount).toInt();
      m_maxThreadCount = globalSettings.value("maxThreadCount", m_maxThreadCount).toInt();
      applyMaxThreadCount();
    }
    //  Project specific settings
    else {
      setWindowTitle( project->name() );
      if (settings.contains("geometry")) {
        setGeometry(settings.value("geometry").value<QRect>());
      }
      if (settings.contains("windowState")) {
        restoreState(settings.value("windowState").toByteArray());
      }

    // The geom/state isn't enough for main windows to correctly remember
    //   their position and size, so let's restore those on top of
    //   the geom and state.
      if (!settings.value("pos").toPoint().isNull()) {
        move(settings.value("pos").toPoint());
      }
    if (!projectSettings.value("pos").toPoint().isNull()) {
      move(projectSettings.value("pos").toPoint());
    }
//    m_directory->project()->setClean(true);
  }


@@ -724,7 +747,8 @@ namespace Isis {
        m_directory->project()->save();
      }
    }
    writeSettings(m_directory->project());
    //  Write global settings, for now this is for the project "Project"
    writeGlobalSettings(m_directory->project());
    m_directory->project()->clear();

    QMainWindow::closeEvent(event);
+12 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@
 */

#include "ViewSubWindow.h"
#include <QEvent>
#include <QMainWindow>
#include <QPointer>
#include <QProgressBar>
@@ -149,6 +150,8 @@ namespace Isis {
   *   @history 2018-06-15 Tracie Sucharski - Fixed break to recent projects.  The readSettings
   *                           must be called before initializeActions to get the recent projects
   *                           from the config file.
   *   @history 2018-06-18 Makayla Shepherd - Set the QApplication name so that BundleAdjust does 
   *                           not output text to the command line for ipce. Fixes #4171.
   *   @history 2018-06-19 Kaitlyn Lee - Added tabViews() and the menu option under the View menu to
   *                           tab the views. Currently, this can tab all attached/detached views. I
   *                           left the line setting dock options to allow grouped dragging, but tabbing
@@ -156,11 +159,12 @@ namespace Isis {
   *                           type of a view will randomly change and setting its type has no effect.
   *                           Use windowType() to get the type. Also added the toolbar title in the
   *                           permanent toolbar constructor. 
   *
   *
   *   @history 2018-06-18 Makayla Shepherd - Set the QApplication name so that BundleAdjust does 
   *                           not output text to the command line for ipce. Fixes #4171.
   *  
   *   @history 2018-06-22 Tracie Sucharski - Cleanup destruction of dock widgets and the views they
   *                           hold.  Extra destroy slots were causing double deletion of memory.
   *   @history 2018-06-22 Tracie Sucharski - Added a showEvent handler so that the project clean
   *                           state can be reset after the IpceMainWindow::show() causes resize and
   *                           move events which in turn cause the project clean flag to be false
   *                           even though the project has just opened.
   */
  class IpceMainWindow : public QMainWindow {
      Q_OBJECT
@@ -176,8 +180,10 @@ namespace Isis {

      void readSettings(Project *);
      void writeSettings(Project *project);
      void writeGlobalSettings(Project *project);

    protected:
      void showEvent(QShowEvent *event);
      void closeEvent(QCloseEvent *event);
      bool eventFilter(QObject *watched, QEvent *event);

@@ -189,6 +195,7 @@ namespace Isis {

      void raiseWarningTab();
      void cleanupViewDockList(QObject *obj);

    private:
      Q_DISABLE_COPY(IpceMainWindow);

@@ -198,7 +205,6 @@ namespace Isis {
      void createMenus();
      void createToolBars();


    private:
      /**
       * The directory stores all of the work orders that this program is capable of doing. This
+43 −6
Original line number Diff line number Diff line
@@ -45,9 +45,6 @@ namespace Isis {
  AbstractProjectItemView::AbstractProjectItemView(QWidget *parent) : QMainWindow(parent) {

    setWindowFlags(Qt::Widget);



    m_internalModel = new ProjectItemProxyModel(this);
    setAcceptDrops(true);
  }
@@ -163,6 +160,46 @@ namespace Isis {
  }


  /**
   * Enables actions when cursor enters the view
   *
   * @param event The enter event
   */
  void AbstractProjectItemView::enterEvent(QEvent *event) {
    enableActions();
  }


  /**
   * Disables actions when cursor leaves the view.
   *
   * @param event The leave event
   */
  void AbstractProjectItemView::leaveEvent(QEvent *event) {
    disableActions();
  }


  /**
   * Disables toolbars and toolpad actions
   */
  void AbstractProjectItemView::disableActions() {
    foreach (QAction *action, actions()) {
      action->setDisabled(true);
    }
  }


  /**
   * Enables toolbars and toolpad actions
   */
  void AbstractProjectItemView::enableActions() {
    foreach (QAction *action, actions()) {
      action->setEnabled(true);
    }
  }


  /**
   * Returns a list of actions appropriate for a context menu.
   *
+15 −7
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ namespace Isis {

  class ProjectItem;
  class ProjectItemModel;

  /**
   * AbstractProjectItemView is a base class for views of a
   * ProjectItemModel in Qt's model-view
@@ -43,11 +44,6 @@ namespace Isis {
   * ProjectItemProxyModel that represents the items appropriately for
   * the view.
   *
   * An AbstractProjectItemView may provide QActions for manipulating
   * the view. These actions can be accessed in different contexts
   * through toolBarActions(), menuActions(), and
   * contextMenuActions().
   *
   * When mime data is dropped on a view the view adds the selected
   * items from the source model to the view.
   *
@@ -71,6 +67,13 @@ namespace Isis {
   *   @History 2018-06-18 Summer Stapleton - Overloaded moveEvent and resizeEvent and added a
   *                           windowChangeEvent signal to allow project to recognize a new save
   *                           state. Fixes #5114
   *   @history 2018-06-25 Kaitlyn Lee - When multiple views are open, there is a possibility of getting
   *                           ambiguous shortcut errors. To counter this, we need a way to focus on one
   *                           widget. Giving the views focus did not work completely. Instead,
   *                           enabling/disabling actions was the best option. Added enableActions(),
   *                           disableActions(), enterEvent(), and leaveEvent(). On default, a view's
   *                           actions are disabled. To enable the actions, move the cursor over the view.
   *                           When a user moves the cursor outside of the view, the actions are disabled.
   */
  class AbstractProjectItemView : public QMainWindow {

@@ -89,6 +92,10 @@ namespace Isis {
      virtual void moveEvent(QMoveEvent *event);
      virtual void resizeEvent(QResizeEvent *event);

      virtual void enterEvent(QEvent *event);
      virtual void leaveEvent(QEvent *event);
      virtual void enableActions();

      virtual QList<QAction *> contextMenuActions();

      virtual ProjectItem *currentItem();
@@ -107,10 +114,11 @@ namespace Isis {
      virtual void removeItem(ProjectItem *item);
      virtual void removeItems(QList<ProjectItem *> items);

      virtual void disableActions();

    private:
      ProjectItemModel *m_internalModel; //!< The internal model used by the view
  };

}

#endif
Loading