Commit b97c5e51 authored by Kaitlyn Lee's avatar Kaitlyn Lee
Browse files

Moved methods to parent class and removed m_actions because QWidgets have a...

Moved methods to parent class and removed m_actions because QWidgets have a stored list of actions already.
parent 3a60bac3
Loading
Loading
Loading
Loading
+44 −6
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "ProjectItem.h"
#include "ProjectItemModel.h"
#include "ProjectItemProxyModel.h"
#include "ToolPad.h"

namespace Isis {

@@ -45,9 +46,6 @@ namespace Isis {
  AbstractProjectItemView::AbstractProjectItemView(QWidget *parent) : QMainWindow(parent) {

    setWindowFlags(Qt::Widget);



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


  /**
   * Enables actions when cursor etners on 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
+2 −1
Original line number Diff line number Diff line
@@ -28,7 +28,8 @@
namespace Isis {

  /**
   * QMenu subclass that overrides the closeEvent.
   * QMenu subclass that overrides the closeEvent. Used in views to disable
   * actions when a menu is visible and a user clicks outside of a view. 
   *
   * @author 2018-06-27 Kaitlyn Lee
   *
+11 −11
Original line number Diff line number Diff line
@@ -598,7 +598,7 @@ namespace Isis {

    QHBoxLayout *rightLayout = new QHBoxLayout();
    m_autoReg = new QPushButton("Register");
    //m_autoReg->setShortcut(Qt::Key_R);
    m_autoReg->setShortcut(Qt::Key_R);
    m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
                          "<strong>Shortcut: R</strong>");
    m_autoReg->setToolTip("Sub-pixel register the right measure to the left");
@@ -742,10 +742,10 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
      // m_autoReg->setText("Register");
      // m_autoReg->setToolTip("Sub-pixel register the right measure to the left."
      //                       "<strong>Shortcut: R</strong>");
      // m_autoReg->setShortcut(Qt::Key_R);
      m_autoReg->setText("Register");
      m_autoReg->setToolTip("Sub-pixel register the right measure to the left."
                            "<strong>Shortcut: R</strong>");
      m_autoReg->setShortcut(Qt::Key_R);
    }

    m_leftMeasure = leftMeasure;
@@ -804,8 +804,8 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
      // m_autoReg->setText("Register");
      // m_autoReg->setShortcut(Qt::Key_R);
      m_autoReg->setText("Register");
      m_autoReg->setShortcut(Qt::Key_R);
    }
    m_autoRegAttempted = false;

@@ -907,10 +907,10 @@ namespace Isis {
      //  Undo Registration
      m_autoRegShown = false;
      m_autoRegExtension->hide();
    //   m_autoReg->setText("Register");
    //   m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
    //                         "<strong>Shortcut: R</strong>");
    //   m_autoReg->setShortcut(Qt::Key_R);
      m_autoReg->setText("Register");
      m_autoReg->setToolTip("Sub-pixel register the right measure to the left. "
                            "<strong>Shortcut: R</strong>");
      m_autoReg->setShortcut(Qt::Key_R);
    }

    QString pos = "Sample: " + QString::number(m_rightView->tackSample()) +
+2 −1
Original line number Diff line number Diff line
@@ -144,7 +144,8 @@ namespace Isis {
    *   @history 2017-08-11 Tracie Sucharski - Created a new ControlMeasure when editing points so
    *                           that the edit ControlPoint is no changed until user selects
    *                           "Save Measures", and colorize save buttons.  Fixes #4984.
    *
    *   @history 2018-06-28 Kaitlyn Lee - Removed shortcuts from zoom buttons because of ambiguous
    *                           shortcut errors.
    *   @todo  Re-think design of the change made on 2012-07-26.  The linking was put into
    *                          ::updateLeftPositionLabel because it was the fastest solution, but
    *                          should this be put somewhere else.
Loading