Commit 319c37b7 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Refactored IpceMainWindow for the new ipce user interface using docked views...

Refactored IpceMainWindow for the new ipce user interface using docked views rather than mdi sub-windows.  Fixes #5433.
parent 3097479c
Loading
Loading
Loading
Loading
+44 −48
Original line number Diff line number Diff line
@@ -93,8 +93,6 @@ namespace Isis {

    try {
      m_directory = new Directory(this);
      connect(m_directory, SIGNAL(newDockAvailable(QMainWindow *)),
              this, SLOT(addDock(QMainWindow *)));
      connect(m_directory, SIGNAL( newWidgetAvailable(QWidget *) ),
              this, SLOT( addView(QWidget *) ) );
      connect(m_directory, SIGNAL(viewClosed(QWidget *)), this, SLOT(removeView(QWidget *)));
@@ -170,6 +168,8 @@ namespace Isis {
//  setTabbedViewMode();
//  centralWidget->setTabsMovable(true);
//  centralWidget->setTabsClosable(true);
    // Read default app settings
    readSettings(m_directory->project() );

    QStringList args = QCoreApplication::arguments();

@@ -180,49 +180,41 @@ namespace Isis {
  }


  void IpceMainWindow::addDock(QMainWindow *newWidgetForDock) {

    QDockWidget *dock = new QDockWidget(newWidgetForDock->windowTitle(), this, Qt::SubWindow);
    dock->setWidget(newWidgetForDock);
    dock->setObjectName(newWidgetForDock->windowTitle());

    // This needs to eventually be a work order...
    dock->setAttribute(Qt::WA_DeleteOnClose);

    connect(newWidgetForDock, SIGNAL(destroyed(QObject *)),
            dock, SLOT(deleteLater()));

    addDockWidget(Qt::LeftDockWidgetArea, dock, Qt::Horizontal);
//    addDockWidget(area, dock, orientation);
  }


  /**
   * This is connected from Directory's newWidgetAvailable signal and called when re-attaching a
   * view which was detached from the MDI main window.
   * This is connected from Directory's newWidgetAvailable signal
   *
   * @param[in] newWidget (QWidget *)
   */
  void IpceMainWindow::addView(QWidget *newWidget) {
  void IpceMainWindow::addView(QWidget *newWidget, Qt::DockWidgetArea area,
                               Qt::Orientation orientation) {

    QDockWidget *dock = new QDockWidget(newWidget->windowTitle(), this);
    dock->setWidget(newWidget);
    dock->setObjectName(newWidget->windowTitle());
    dock->setAttribute(Qt::WA_DeleteOnClose);
    dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |
                      QDockWidget::DockWidgetFloatable);

    if ( qobject_cast<SensorInfoWidget *>(newWidget) ||
         qobject_cast<TargetInfoWidget *>(newWidget) ||
         qobject_cast<TemplateEditorWidget *>(newWidget)) {
      QDockWidget *dock = new QDockWidget( newWidget->windowTitle() );
      dock->setAttribute(Qt::WA_DeleteOnClose, true);
      dock->setWidget(newWidget);
      dock->setObjectName(newWidget->windowTitle());
      splitDockWidget(m_projectDock, dock, Qt::Vertical);
    }
    else {

      addDockWidget(area, dock, orientation);
    }
//    m_dockedWidgets.append

    // Connections for cleanup in both directions to make sure both views and docks are cleaned up
    connect(newWidget, SIGNAL(destroyed(QObject *)), dock, SLOT(deleteLater()));
    connect(dock, SIGNAL(destroyed(QObject *)), newWidget, SLOT(deleteLater()));
    // Save view docks for cleanup during a project close
    m_viewDocks.append(dock);
  }


  /**
   * @description This slot is connected from Directory::viewClosed(QWidget *) signal.  It will 
   * close the given view and delete the view.
   * close the given view and delete the view. This was written to handle
   * 
   * @param view QWidget* 
   *
@@ -239,17 +231,23 @@ namespace Isis {
   */
  void IpceMainWindow::removeAllViews() {
    setWindowTitle("ipce");
//  qDebug()<<"IpceMainWindow::removeAllViews  directory footprint count = "<<m_directory->footprint2DViews().count();
//  qDebug()<<"                                directory cube disp count = "<<m_directory->cubeDnViews().count();



    QList<QDockWidget *> docks = tabifiedDockWidgets(m_projectDock);
    if(docks.count() > 1) {
      foreach ( QDockWidget* widget, docks ) {
        if(widget != m_projectDock) {
          delete widget;
        }
      }
    // Find all children of IpceMainWindow and close
    QList<QDockWidget *> dockedWidgets = findChildren<QDockWidget *>();
//  qDebug()<<"           # docks before removal = "<<dockedWidgets.count();
    foreach (QDockWidget *dock, m_viewDocks) {
      removeDockWidget(dock);
      m_viewDocks.removeAll(dock);
      delete dock;
    }

    QList<QDockWidget *> dockedWidgets2 = findChildren<QDockWidget *>();
//  qDebug()<<"           any docks left"<<dockedWidgets2.count();
//  qDebug()<<"IpceMainWindow::removeAllViews  directory footprint count = "<<m_directory->footprint2DViews().count();
//  qDebug()<<"                                directory cube disp count = "<<m_directory->cubeDnViews().count();
    m_viewDocks.clear();
  }


@@ -400,8 +398,6 @@ namespace Isis {
    connect(activateWhatsThisAct, SIGNAL(triggered()), this, SLOT(enterWhatsThisMode()));

    m_helpMenuActions.append(activateWhatsThisAct);

    readSettings(m_directory->project() );
  }


@@ -561,10 +557,10 @@ namespace Isis {
          .expanded(),
        QSettings::NativeFormat);

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

    projectSettings.setValue("maxThreadCount", m_maxThreadCount);

@@ -674,8 +670,8 @@ namespace Isis {
        FileName("$HOME/.Isis/" + appName + "/" + appName + "_" + project->name() + ".config")
        .expanded(), QSettings::NativeFormat);

    restoreGeometry(settings.value("geometry").toByteArray());
    //restoreState(settings.value("windowState").toByteArray());
    setGeometry(settings.value("geometry").value<QRect>());
    restoreState(settings.value("windowState").toByteArray());

    QStringList projectNameList;
    QStringList projectPathList;
+9 −5
Original line number Diff line number Diff line
@@ -132,8 +132,11 @@ namespace Isis {
   *                           Fixes #5412.
   *   @history 2018-05-30 Tracie Sucharski - Fix to handle the re-factored docked views.
   *                           Changed from MDI to SDI, changing the centralWidget to a dumy, unused
   *                           widget. Added addDock method. Remove all methods having to do with
   *                           MDI sub-windows, detached views.
   *                           widget. Remove all methods having to do with MDI sub-windows,
   *                           detached views.  The dock widgets holding the views are saved off
   *                           for cleanup because there is no way to get the dock from the view.
   *                           Cleanup connections are made for the views and the docks to ensure
   *                           that cleanup happens for both.  Fixes #5433.
   *  
   */
  class IpceMainWindow : public QMainWindow {
@@ -143,8 +146,8 @@ namespace Isis {
      ~IpceMainWindow();

    public slots:
      void addView(QWidget *newWidget);
      void addDock(QMainWindow *newWidgetForDock);
      void addView(QWidget *newWidget, Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
                   Qt::Orientation orientation = Qt::Horizontal);
      void removeView(QWidget *view);
      void removeAllViews();

@@ -182,7 +185,8 @@ namespace Isis {
      QDockWidget *m_projectDock;
      QDockWidget *m_warningsDock;

      QList<QDockWidget *> m_dockedWidgets;
      QList<QDockWidget *> m_viewDocks; //!< QDockWidgets holding the views

      /**
       * This is the "goal" or "estimated" maximum number of active threads running in this program
       *   at once. For now, the GUI consumes 1 thread and QtConcurrent
+19 −18
Original line number Diff line number Diff line
@@ -288,6 +288,8 @@ namespace Isis {
   * to allow for a new project to be opened in IPCE.
   */
  void Directory::clean() {
    emit directoryCleaned();

    m_historyTreeWidget->clear();
    m_warningTreeWidget->clear();
    m_bundleObservationViews.clear();
@@ -302,7 +304,6 @@ namespace Isis {
    m_templateEditorWidgets.clear();

    m_projectItemModel->clean();
    emit directoryCleaned();
  }


@@ -679,7 +680,7 @@ namespace Isis {
    result->setWindowTitle(title);
    result->setObjectName(title);

    emit newDockAvailable(result);
    emit newWidgetAvailable(result);

    return result;
  }
@@ -699,7 +700,7 @@ namespace Isis {
    result->setWindowTitle("Cube DN View");
    result->setWindowTitle( tr("Cube DN View %1").arg(m_cubeDnViewWidgets.count() ) );

    emit newDockAvailable(result);
    emit newWidgetAvailable(result);

    //  Connections between mouse button events from view and control point editing
    connect(result, SIGNAL(modifyControlPoint(ControlPoint *, QString)),
@@ -751,7 +752,7 @@ namespace Isis {
    connect(result, SIGNAL(destroyed(QObject *)),
            this, SLOT(cleanupFootprint2DViewWidgets(QObject *)));

    emit newDockAvailable(result);
    emit newWidgetAvailable(result);

    //  Connections between mouse button events from footprint2DView and control point editing
    connect(result, SIGNAL(modifyControlPoint(ControlPoint *)),
@@ -823,7 +824,7 @@ namespace Isis {

      connect(result, SIGNAL(destroyed(QObject *)),
              this, SLOT(cleanupControlPointEditViewWidget(QObject *)));
      emit newDockAvailable(result);
      emit newWidgetAvailable(result);

// 2017-06-09 Ken commented out for Data Workshop demo
//      m_chipViewports = new ChipViewportsWidget(result);
+0 −8
Original line number Diff line number Diff line
@@ -238,14 +238,6 @@ namespace Isis {
   *   @history 2018-05-14 Tracie Sucharski - Serialize Footprint2DView rather than
   *                           MosaicSceneWidget. This will allow all parts of Footprint2DView to be
   *                           saved/restored including the ImageFileListWidget. Fixes #5422.
   *   @history 2018-05-30 Kaitlyn Lee - addControlPointEditView() and addCnetEditorView() now emit
   *                           newDockAvailable().
   *   @history 2018-05-30 Summer Stapleton - updated the emit in addFootprint2DView from 
   *                           newWidgetAvailable to newDockAvailable to handle new signal from 
   *                           IpceMainWindow. References #5433.
   *   @history 2018-05-30 Tracie Sucharski - Changed for re-factored docked views. Added signal to
   *                           let IpceMainWindow know there is a new view available for docking.
   *                           This needs further work to cleanup and change the mdi interface.
   */
  class Directory : public QObject {
    Q_OBJECT
+0 −1
Original line number Diff line number Diff line
@@ -153,7 +153,6 @@ namespace Isis {
   */
  Footprint2DView::~Footprint2DView() {
    delete m_fileListWidget;
    delete m_window;
    delete m_permToolBar;
    delete m_activeToolBar;
    delete m_toolPad;
Loading