Commit fb30d755 authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Set up sizePolicy and sizeHint in the AbstractProjectItemView, removing from...

Set up sizePolicy and sizeHint in the AbstractProjectItemView, removing from child classes. Setup views in tabbed mode initially. Create IpceMainWindow at a fullscrren size in constructor so that any restored views do not have their internal widgets squished. Create unique objectName for views and serialize so that save/restoreState works properly.
parent 6326375c
Loading
Loading
Loading
Loading
+39 −10
Original line number Diff line number Diff line
@@ -25,11 +25,13 @@
#include <QApplication>
#include <QColor>
#include <QDebug>
#include <QDesktopWidget>
#include <QDockWidget>
#include <QMap>
#include <QMapIterator>
#include <QMdiArea>
#include <QObject>
#include <QRect>
#include <QRegExp>
#include <QStringList>
#include <QtWidgets>
@@ -76,25 +78,39 @@ namespace Isis {
      QMainWindow(parent) {
    m_maxThreadCount = -1;

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

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

    //  Set the initialize size of the mainwindow to fullscreen so that created views do not
    //  get squished.  Saved projects with view had the internal widgets squished because the
    //  initial size of this mainwindow was small and it does not get restored to the saved project
    //  size until after views are created.  For instance, the viewports within a CubeDnView were
    //  restored to a small size based on the original mainwindow size.  If the internal state
    //  of the views such as the viewport sizes, zooms, etc get serialized, this code will not be
    //  needed.
    QDesktopWidget deskTop;
    QRect mainScreenSize = deskTop.availableGeometry(deskTop.primaryScreen());
    resize(mainScreenSize.width(), mainScreenSize.height());

    QWidget *centralWidget = new QWidget;
    setCentralWidget(centralWidget);
    //centralWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    //centralWidget->hide();
    setDockNestingEnabled(true);

    //  Set the splitter frames to a reasonable color/size for resizing the docks.
    setStyleSheet("QMainWindow::separator {background: gray; width: 10; height: 10px;}");

    try {
      m_directory = new Directory(this);
      connect(m_directory, SIGNAL( newWidgetAvailable(QWidget *) ),
              this, SLOT( addView(QWidget *) ) );

      // Currently this connection is only used by Directory when a new active is chosen & user
      // chooses to discard any edits in the old active control which is in a CnetEditorWidget.
      // The only view which will not be updated with the new control are any CnetEditorViews
      // showing the old active control.  CnetEditorWidget classes do not have the ability to reload
      // a control net, so the CnetEditor view displaying the old control is removed, then recreated.
      connect(m_directory, SIGNAL(viewClosed(QWidget *)),
              this, SLOT(removeView(QWidget *)));

      connect(m_directory, SIGNAL( directoryCleaned() ),
              this, SLOT( removeAllViews() ) );
      connect(m_directory->project(), SIGNAL(projectLoaded(Project *)),
@@ -119,9 +135,9 @@ namespace Isis {
    projectTreeView->setInternalModel( m_directory->model() );
    projectTreeView->treeView()->expandAll();
    projectTreeView->installEventFilter(this);
    m_projectDock->setWidget(projectTreeView);
    m_projectDock->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    //projectTreeView->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);

    m_projectDock->setWidget(projectTreeView);
    addDockWidget(Qt::LeftDockWidgetArea, m_projectDock, Qt::Horizontal);

    m_warningsDock = new QDockWidget("Warnings", this, Qt::SubWindow);
@@ -189,7 +205,7 @@ namespace Isis {

    QDockWidget *dock = new QDockWidget(newWidget->windowTitle(), this);
    dock->setWidget(newWidget);
    dock->setObjectName(newWidget->windowTitle());
    dock->setObjectName(newWidget->objectName());
    dock->setAttribute(Qt::WA_DeleteOnClose);
    dock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |
                      QDockWidget::DockWidgetFloatable);
@@ -200,7 +216,18 @@ namespace Isis {
      splitDockWidget(m_projectDock, dock, Qt::Vertical);
    }
    else {
      addDockWidget(area, dock, orientation);
      if (m_viewDocks.count() == 0) {
        splitDockWidget(m_projectDock, dock, Qt::Horizontal); 
      }
      else {
        tabifyDockWidget(m_viewDocks.last(), dock);
        dock->show();
        dock->raise();
        //  Keeps expanding IpceMainWindow to fit new dock
        //  Below causes problems if the last dock has been tabbed, then a new view is created. All
        // views except for first disappear.
        //splitDockWidget(m_viewDocks.last(), dock, Qt::Horizontal);
      }
    }

    // When dock widget is destroyed, make sure the view it holds is also destroyed
@@ -214,6 +241,7 @@ namespace Isis {


  void IpceMainWindow::cleanupViewDockList(QObject *obj) {

    QDockWidget *dock = static_cast<QDockWidget *>(obj);
    if (dock) {
      m_viewDocks.removeAll(dock);
@@ -228,6 +256,7 @@ namespace Isis {
   * @param view QWidget* The view to close.
   */
  void IpceMainWindow::removeView(QWidget *view) {

    view->close();
    delete view;
  }
+1 −0
Original line number Diff line number Diff line
@@ -182,6 +182,7 @@ namespace Isis {
      void tabAllViews();

      void raiseWarningTab();

      void cleanupViewDockList(QObject *obj);
    private:
      Q_DISABLE_COPY(IpceMainWindow);
+21 −2
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@
#include <QDropEvent>
#include <QList>
#include <QMainWindow>
#include <QSizePolicy>
#include <QWidget>

#include "ProjectItem.h"
@@ -46,13 +47,31 @@ namespace Isis {

    setWindowFlags(Qt::Widget);


    QSizePolicy policy = sizePolicy();
    policy.setHorizontalPolicy(QSizePolicy::Expanding);
    policy.setVerticalPolicy(QSizePolicy::Expanding);
    setSizePolicy(policy);

    m_internalModel = new ProjectItemProxyModel(this);
    setAcceptDrops(true);
  }


  /**
   * Returns the suggested size
   *
   * @return @b QSize The size hint
   */
  QSize AbstractProjectItemView::sizeHint() const {

    //  Size hint is make ridiculously large as a hack to have the views fill the available dock
    //  space.  SizePolicy alone did not work.
    // TODO:  There should be a better way to do this.
    //return QSize(800, 600);
    return QSize(3000, 1500);
  }


  /**
   * Sets the model used by the view. If the internal model is a proxy
   * model, it sets the source model.
@@ -158,7 +177,7 @@ namespace Isis {

  void AbstractProjectItemView::resizeEvent(QResizeEvent *event) {
    QMainWindow::resizeEvent(event);
    
    //qDebug()<<objectName()<<"  new size = "<<geometry();
    emit windowChangeEvent(false);
  }

+7 −1
Original line number Diff line number Diff line
@@ -68,9 +68,13 @@ namespace Isis {
   *   @history 2018-05-30 Tracie Sucharski - Added the WindowFlag to set this as a Widget.
   *   @history 2018-06-15 Kaitlyn Lee - Removed methods returing toolbar and menu actions because each
   *                            individual has its own toolbar. These methods are not needed anymore.
   *   @History 2018-06-18 Summer Stapleton - Overloaded moveEvent and resizeEvent and added a
   *   @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-07-05 Tracie Sucharski - Added SizePolicy and a large sizeHint.  The large
   *                           sizeHint() is because using sizePolicy with a reasonable sizeHint did
   *                           not work to have views fill the available space in the dock area.
   *                           References #5433.
   */
  class AbstractProjectItemView : public QMainWindow {

@@ -79,6 +83,8 @@ namespace Isis {
    public:
      AbstractProjectItemView(QWidget *parent=0);

      virtual QSize sizeHint() const;

      virtual void setModel(ProjectItemModel *model);
      virtual ProjectItemModel *model();

+2 −10
Original line number Diff line number Diff line
@@ -190,15 +190,6 @@ namespace Isis {
  }


  /**
   * Returns the suggested size for the widget.
   *
   * @return (QSize) The size
   */
  QSize CnetEditorView::sizeHint() const {
    return QSize(800, 600);
  }

  /**
   * This method pushes a new XmlHandler into the parser stack.
   *
@@ -218,7 +209,8 @@ namespace Isis {
   */
  void CnetEditorView::save(QXmlStreamWriter &stream, Project *, FileName) const {

    stream.writeStartElement("control");
    stream.writeStartElement("cnetEditorView");
    stream.writeAttribute("objectName", objectName());
    stream.writeAttribute("id", m_control->id());
    stream.writeEndElement();
  }
Loading