Commit 206d5972 authored by Jeffrey Covington's avatar Jeffrey Covington
Browse files

Redesigned CNetSuiteMainWindow. Added CubeDnView and Footprint2DView.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@6511 41f8697f-d340-4b68-9986-7bafba869bb8
parent 177b58a2
Loading
Loading
Loading
Loading
+463 −103

File changed.

Preview size limit exceeded, changes collapsed.

+53 −3
Original line number Diff line number Diff line
@@ -26,12 +26,16 @@
#include <QMainWindow>
#include <QPointer>
#include <QProgressBar>
#include <QMdiSubWindow>

namespace Isis {
  class AbstractProjectItemView;
  class Directory;
  class Project;

  /**
   * The main window for the cnetsuite appication. This handles most of the top-level GUI aspects of the program.
   *
   * @author 2012-??-?? Steven Lambright and Stuart Sides
   *
   * @internal
@@ -50,6 +54,14 @@ namespace Isis {
   *                          with a ProjectItemTreeView. Added the
   *                          eventFilter() method for intercepting some
   *                          events from views.
   *   @history 2016-01-04 Jeffrey Covington - Added a QMdiArea as the central widget
   *                          of the main window. The menus and toolbars are now solely
   *                          handled by the main window. Menus, context menus, and
   *                          toolbars are populated with actions recieved from the Directory
   *                          the active view, and the main window. Both WorkOrders and
   *                          regular QActions can be used in menus and toolbars. Views can
   *                          now be detached from the main window into their own independent
   *                          window with internalized menus and toolbars.
   */
  class CNetSuiteMainWindow : public QMainWindow {
      Q_OBJECT
@@ -58,8 +70,10 @@ namespace Isis {
      ~CNetSuiteMainWindow();

    public slots:
      void addDock(QWidget *newWidgetForDock, Qt::DockWidgetArea area, Qt::Orientation orientation,
                   Qt::DockWidgetArea allowedAreas = Qt::AllDockWidgetAreas);
      void addView(QWidget *newWidget);
      void setActiveView(AbstractProjectItemView *view);
      void updateMenuActions();
      void updateToolBarActions();
      void readSettings(Project *);

    protected:
@@ -69,7 +83,14 @@ namespace Isis {
    private slots:
      void configureThreadLimit();
      void enterWhatsThisMode();
      void removeCentralWidgetTab(int);
      void onSubWindowActivated(QMdiSubWindow *);

      void toggleViewMode();
      void setTabbedViewMode();
      void setSubWindowViewMode();

      void detachActiveView();
      void reattachView();

    private:
      Q_DISABLE_COPY(CNetSuiteMainWindow);
@@ -78,6 +99,8 @@ namespace Isis {
      void createMenus();
      void writeSettings();

      void initializeActions();

    private:
      /**
       * The directory stores all of the work orders that this program is capable of doing. This
@@ -94,6 +117,33 @@ namespace Isis {
       *   should perform a best-guess for best perfomance.
       */
      int m_maxThreadCount;

      QToolBar *m_permToolBar; //!< The toolbar for actions that rarely need to be changed.
      QToolBar *m_activeToolBar; //<! The toolbar for the actions of the current tool.
      QToolBar *m_toolPad; //<! The toolbar for the actions that activate tools.

      QMenu *m_fileMenu; //!< Menu for the file actions
      QMenu *m_projectMenu; //!< Menu for the project actions
      QMenu *m_editMenu; //!< Menu for edit actions
      QMenu *m_viewMenu; //!< Menu for view and window actions
      QMenu *m_settingsMenu; //!< Menu for settings actions
      QMenu *m_helpMenu; //!< Menu for help actions

      QList<QAction *> m_fileMenuActions; //!< Internal list of file actions
      QList<QAction *> m_projectMenuActions;//!< Internal list of project actions
      QList<QAction *> m_editMenuActions;//!< Internal list of edit actions
      QList<QAction *> m_viewMenuActions;//!< Internal list of view actions
      QList<QAction *> m_settingsMenuActions;//!< Internal list of settings actions
      QList<QAction *> m_helpMenuActions;//!< Internal list of help actions

      QList<QAction *> m_permToolBarActions;//!< Internal list of permanent toolbar actions
      QList<QAction *> m_activeToolBarActions;//!< Internal list of active toolbar actions
      QList<QAction *> m_toolPadActions;//!< Internal list of toolpad actions

      QAction *m_cascadeViewsAction; //!< Action that cascades the mdi area
      QAction *m_tileViewsAction; //!< Action that tiles the mdi area

      AbstractProjectItemView *m_activeView; //!< The active view
  };
}

+165 −32
Original line number Diff line number Diff line
@@ -31,100 +31,230 @@
namespace Isis {

  /**
   * Constructs the AbstractProjectItemView
   * Constructs the AbstractProjectItemView.
   *
   * @param[in] parent (QWidget *)
   * @param[in] parent (QWidget *) The parent widget
   */
  AbstractProjectItemView::AbstractProjectItemView(QWidget *parent) : QWidget(parent) {
    m_proxyModel = new ProjectItemProxyModel(this);
    m_internalModel = new ProjectItemProxyModel(this);
    setAcceptDrops(true);
  }


  /**
   * Sets the model used by the view. If the internal model is a proxy
   * model, it sets the source model.
   *
   *
   * @param[in] model (ProjectItemModel *)
   * @param[in] model (ProjectItemModel *) The new model
   */
  void AbstractProjectItemView::setModel(ProjectItemModel *model) {
    proxyModel()->setSourceModel(model);
    if (ProjectItemProxyModel *proxyModel = 
        qobject_cast<ProjectItemProxyModel *>( internalModel() ) ) {
      proxyModel->setSourceModel(model);
    }
  }


  /**
   * @param[in] event (QDragEnterEvent *)
   * Returns the model used by the view. If the internal model is a
   * proxy model, it returns the source model.
   *
   * @return (ProjectItemModel *) The model.
   */
  ProjectItemModel *AbstractProjectItemView::model() {
    if (ProjectItemProxyModel *proxyModel = 
        qobject_cast<ProjectItemProxyModel *>( internalModel() ) ) {
      return proxyModel->sourceModel();
    }
    return internalModel();
  }

  /**
   * Accepts the drag enter event if the internal model can accept the
   * mime data.
   *
   * @param[in] event (QDragEnterEvent *) The drag event
   */
  void AbstractProjectItemView::dragEnterEvent(QDragEnterEvent *event) {
    if (internalModel()->canDropMimeData( event->mimeData(),
                                          event->dropAction(),
                                          0, 0, QModelIndex() ) ) {
      event->acceptProposedAction();
    }
  }


  /**
   * @param[in] event (QDragMoveEvent *)
   * Accepts the drag event if the internal model can accept the mime
   * data.
   *
   * @param[in] event (QDragMoveEvent *) The drag event
   */
  void AbstractProjectItemView::dragMoveEvent(QDragMoveEvent *event) {
    if (internalModel()->canDropMimeData( event->mimeData(),
                                          event->dropAction(),
                                          0, 0, QModelIndex() ) ) {
      event->acceptProposedAction();
    }
  }

  
  /**
   * @param[in] event (QDropEvent *)
   * Drops the data into the internal model if it can accept the data.
   *
   * @param[in] event (QDropEvent *) The drop event
   */
  void AbstractProjectItemView::dropEvent(QDropEvent *event) {
    addItems( proxyModel()->sourceModel()->selectedItems() );
    if (internalModel()->canDropMimeData( event->mimeData(),
                                          event->dropAction(),
                                          0, 0, QModelIndex() ) ) {
      internalModel()->dropMimeData( event->mimeData(), event->dropAction(),
                                     0, 0, QModelIndex() );
      event->acceptProposedAction();
    }
  }

  
  /**
   * @return (QList<QAction *>)
   * Returns a list of actions appropriate for the permanent tool bar.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::menuActions() {
    return toolBarActions();
  QList<QAction *> AbstractProjectItemView::permToolBarActions() {
    return QList<QAction *>();
  }


  /**
   * @return (QList<QAction *>)
   * Returns a list of actions appropriate for the active tool bar.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::toolBarActions() {
  QList<QAction *> AbstractProjectItemView::activeToolBarActions() {
    return QList<QAction *>();
  }


  /**
   * @return (QList<QAction *>)
   * Returns a list of actions appropriate for the tool pad.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::toolPadActions() {
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for a context menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::contextMenuActions() {
    return menuActions();
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for a file menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::fileMenuActions() {
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for a project menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::projectMenuActions() {
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for an edit menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::editMenuActions() {
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for a view menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::viewMenuActions() {
    return QList<QAction *>();
  }

  
  /**
   * @return (ProjectItem *)
   * Returns a list of actions appropriate for a settings menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::settingsMenuActions() {
    return QList<QAction *>();
  }


  /**
   * Returns a list of actions appropriate for a help menu.
   *
   * @return (QList<QAction *>) The actions
   */
  QList<QAction *> AbstractProjectItemView::helpMenuActions() {
    return QList<QAction *>();
  }

  
  /**
   * Returns the current item of the model.
   * 
   * @return (ProjectItem *) The item
   */
  ProjectItem *AbstractProjectItemView::currentItem() {
    return proxyModel()->sourceModel()->currentItem();
    return model()->currentItem();
  }


  /**
   * @return (QList<ProjectItem *>)
   * Return the selected items of the model.
   *
   * @return (QList<ProjectItem *>) The items
   */
  QList<ProjectItem *> AbstractProjectItemView::selectedItems() {
    return proxyModel()->selectedItems();
    return model()->selectedItems();
  }

  
  /**
   * @param[in] item (ProjectItem *)
   * Adds an item to the view. The item must be part of the view's
   * model. This method can be overriden in a subclass to filter out
   * unneeded items.
   *
   * @param[in] item (ProjectItem *) The item to add.
   */
  void AbstractProjectItemView::addItem(ProjectItem *item) {
    proxyModel()->addItem(item);
        if (ProjectItemProxyModel *proxyModel = 
        qobject_cast<ProjectItemProxyModel *>( internalModel() ) ) {
      proxyModel->addItem(item);
    }
  }


  /**
   * @param[in] items (QList<ProjectItem *>)
   * Adds several items to the view. The items must be a part of the
   * view's model.
   *
   * @param[in] items (QList<ProjectItem *>) The items to add.
   */
  void AbstractProjectItemView::addItems(QList<ProjectItem *> items) {
    foreach (ProjectItem *item, items) {
@@ -134,19 +264,22 @@ namespace Isis {
  

  /**
   * @return (ProjectItemProxyModel *)
   * Returns the internal model of the view. By default it is a proxy
   * model.
   *
   * @return (ProjectItemModel *) The internal model
   */
  ProjectItemProxyModel *AbstractProjectItemView::proxyModel() {
    return m_proxyModel;
  ProjectItemModel *AbstractProjectItemView::internalModel() {
    return m_internalModel;
  }


  /**
   * @param[in] proxyModel (ProjectItemProxyModel *)
   * Sets the internal model of the view.
   *
   * @param[in] model (ProjectItemModel *) The new internal model
   */
  void AbstractProjectItemView::setProxyModel(ProjectItemProxyModel *proxyModel) {
    m_proxyModel = proxyModel;
  void AbstractProjectItemView::setInternalModel(ProjectItemModel *model) {
    m_internalModel = model;
  }


}
+19 −10
Original line number Diff line number Diff line
@@ -60,28 +60,37 @@ namespace Isis {
      AbstractProjectItemView(QWidget *parent=0);

      virtual void setModel(ProjectItemModel *model);
      virtual ProjectItemModel *model();
      
      void dragEnterEvent(QDragEnterEvent *event);
      void dragMoveEvent(QDragMoveEvent *event);
      void dropEvent(QDropEvent *event);
      virtual void dragEnterEvent(QDragEnterEvent *event);
      virtual void dragMoveEvent(QDragMoveEvent *event);
      virtual void dropEvent(QDropEvent *event);

      virtual QList<QAction *> permToolBarActions();
      virtual QList<QAction *> activeToolBarActions();
      virtual QList<QAction *> toolPadActions();
 
      virtual QList<QAction *> toolBarActions();
      virtual QList<QAction *> menuActions();
      virtual QList<QAction *> contextMenuActions();

      virtual QList<QAction *> fileMenuActions();
      virtual QList<QAction *> projectMenuActions();
      virtual QList<QAction *> editMenuActions();
      virtual QList<QAction *> viewMenuActions();
      virtual QList<QAction *> settingsMenuActions();
      virtual QList<QAction *> helpMenuActions();
      
      virtual ProjectItem *currentItem();
      virtual QList<ProjectItem *> selectedItems();

      virtual ProjectItemModel *internalModel();
      virtual void setInternalModel(ProjectItemModel *model);

    public slots:
      virtual void addItem(ProjectItem *item);
      virtual void addItems(QList<ProjectItem *> items);

    protected:
      ProjectItemProxyModel *proxyModel();
      void setProxyModel(ProjectItemProxyModel *proxyModel);

    private:
      ProjectItemProxyModel *m_proxyModel;
      ProjectItemModel *m_internalModel;
  };

}
+500 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading