Commit 375aa0ee authored by Tracie Sucharski's avatar Tracie Sucharski
Browse files

Added functionality to allow user to double-click the project name on the...

Added functionality to allow user to double-click the project name on the Project tree and change the name.  Fixes #2295.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce_FY17-Sprint1@7576 41f8697f-d340-4b68-9986-7bafba869bb8
parent abedeb7a
Loading
Loading
Loading
Loading
+23 −1
Original line number Diff line number Diff line
@@ -123,6 +123,7 @@ namespace Isis {
// 
    m_projectItemModel = new ProjectItemModel(this);
    m_projectItemModel->addProject(m_project);

//  qDebug()<<"Directory::Directory  model row counter after addProject = "<<m_projectItemModel->rowCount();

    try {
@@ -750,10 +751,31 @@ namespace Isis {
    ProjectItemTreeView *result = new ProjectItemTreeView(); 
    result->setModel(m_projectItemModel);
   
    //  The model emits this signal when the user double-clicks on the project name, the parent
    //  node located on the ProjectTreeView. 
    connect(m_projectItemModel, SIGNAL(projectNameEdited(QString)),
            this, SLOT(initiateRenameProjectWorkOrder(QString)));

    return result;
  }


/** 
 * Slot which is connected to the model's signal, projectNameEdited, which is emitted when the user 
 * double-clicks the project name, the parent node located on the ProjectTreeView.  A 
 * RenameProjectWorkOrder is created then passed to the Project which executes the WorkOrder.
 *  
 * @param QString projectName New project name
 */
  void Directory::initiateRenameProjectWorkOrder(QString projectName) {

    //  Create the WorkOrder and add it to the Project.  The Project will then execute the
    //  WorkOrder.
    RenameProjectWorkOrder *workOrder = new RenameProjectWorkOrder(projectName, project());
    project()->addToProject(workOrder);
  }
  

  /**
   * @brief Gets the ProjectItemModel for this directory.
   * @return @b (ProjectItemModel *) Returns a pointer to the ProjectItemModel.
+6 −0
Original line number Diff line number Diff line
@@ -115,6 +115,9 @@ namespace Isis {
   *                           Footprint2DView.  This is done as an application setting so that all
   *                           views use the same colors.  Directory stores the colors so that any
   *                           registered view can get the current colors.
   *   @history 2017-04-17 Tracie Sucharski - Added connection between model's projectNameEdited,
   *                           initiated by double-clicking the project name on the ProjectTreeView
   *                           and Directory's slot, initiateRenameProjectWorkOrder.  Fixes #2295.
   */
  class Directory : public QObject {
    Q_OBJECT
@@ -250,6 +253,9 @@ namespace Isis {

      void updateRecentProjects(Project *project);

    private slots:
      void initiateRenameProjectWorkOrder(QString projectName);

    private:
      /**
       * @author 2012-08-?? Steven Lambright
+23 −1
Original line number Diff line number Diff line
@@ -45,7 +45,9 @@ namespace Isis {
  /**
   * Constructs an item without children, a parent, or a model.
   */
  ProjectItem::ProjectItem() : QStandardItem() {}
  ProjectItem::ProjectItem() : QStandardItem() {
    setEditable(false);
  }

  
  /**
@@ -56,6 +58,7 @@ namespace Isis {
   * @param[in] item (ProjectItem *) The item to copy.
   */
  ProjectItem::ProjectItem(ProjectItem *item) {
    item->setEditable(false);
    setProjectItem(item);
    for (int i=0; i < item->rowCount(); i++) {
      appendRow(new ProjectItem( item->child(i) ) );
@@ -70,6 +73,7 @@ namespace Isis {
   *                                          construct from.
   */
  ProjectItem::ProjectItem(BundleResults bundleResults) {
    setEditable(false);
    setBundleResults(bundleResults);
    appendRow( new ProjectItem( bundleResults.correlationMatrix() ) );
  }
@@ -82,6 +86,7 @@ namespace Isis {
   *                                               construct from.
   */
  ProjectItem::ProjectItem(BundleSettingsQsp bundleSettings) {
    setEditable(false);
    setBundleSettings(bundleSettings);
  }

@@ -93,6 +98,7 @@ namespace Isis {
   *                                                      to construct from.
   */
  ProjectItem::ProjectItem(BundleSolutionInfo *bundleSolutionInfo) {
    setEditable(false);
    setBundleSolutionInfo(bundleSolutionInfo);
    
    QString cNetFileName = bundleSolutionInfo->controlNetworkFileName();
@@ -110,6 +116,7 @@ namespace Isis {
   * @param[in] control (Control *) The Control to construct from.
   */
  ProjectItem::ProjectItem(Control *control) {
    setEditable(false);
    setControl(control);
  }

@@ -120,6 +127,7 @@ namespace Isis {
   * @param[in] controlList (ControlList *) The ControlList to construct from.
   */
  ProjectItem::ProjectItem(ControlList *controlList) {
    setEditable(false);
    setControlList(controlList);
    foreach (Control *control, *controlList) {
      appendRow( new ProjectItem(control) );
@@ -133,6 +141,7 @@ namespace Isis {
   * @param[in] controls (QList<ControlList *>) The list to construct from.
   */
  ProjectItem::ProjectItem(QList<ControlList *> controls) {
    setEditable(false);
    setControls();
    foreach (ControlList *controlList, controls) {
      appendRow( new ProjectItem(controlList) );
@@ -147,6 +156,7 @@ namespace Isis {
   *                                                  construct from.
   */
  ProjectItem::ProjectItem(CorrelationMatrix correlationMatrix) {
    setEditable(false);
    setCorrelationMatrix(correlationMatrix);
  }

@@ -157,6 +167,7 @@ namespace Isis {
   * @param[in] image (Image *) The Image to construct from.
   */
  ProjectItem::ProjectItem(Image *image) {
    setEditable(false);
    setImage(image);
  }

@@ -167,6 +178,7 @@ namespace Isis {
   * @param[in] imageList (ImageList *) The ImageList to construct from.
   */
  ProjectItem::ProjectItem(ImageList *imageList) {
    setEditable(false);
    setImageList(imageList);
    foreach (Image *image, *imageList) {
      appendRow( new ProjectItem(image) );
@@ -180,6 +192,7 @@ namespace Isis {
   * @param[in] images (QList<ImageList *>) The list to construct from.
   */
  ProjectItem::ProjectItem(QList<ImageList *> images) {
    setEditable(false);
    setImages();
    foreach (ImageList *imageList, images) {
      appendRow( new ProjectItem(imageList) );
@@ -193,6 +206,7 @@ namespace Isis {
   * @param[in] shape (Shape *) The Shape to construct from.
   */
  ProjectItem::ProjectItem(Shape *shape) {
    setEditable(false);
    setShape(shape);
  }

@@ -203,6 +217,7 @@ namespace Isis {
   * @param[in] shapeList (ShapeList *) The ShapeList to construct from.
   */
  ProjectItem::ProjectItem(ShapeList *shapeList) {
    setEditable(false);
    setShapeList(shapeList);
    foreach (Shape *shape, *shapeList) {
      appendRow(new ProjectItem(shape));
@@ -216,6 +231,7 @@ namespace Isis {
   * @param[in] shapes (QList<ShapeList *>) The list to construct from.
   */
  ProjectItem::ProjectItem(QList<ShapeList *> shapes) {
    setEditable(false);
    setShapes();
    foreach (ShapeList *shapeList, shapes) {
      appendRow( new ProjectItem(shapeList) );
@@ -229,6 +245,7 @@ namespace Isis {
   * @param[in] guiCamera (GuiCameraQsp) The camera to construct from.
   */
  ProjectItem::ProjectItem(GuiCameraQsp guiCamera) {
    setEditable(false);
    setGuiCamera(guiCamera);
  }

@@ -240,6 +257,7 @@ namespace Isis {
   *                                            construct from.
   */
  ProjectItem::ProjectItem(GuiCameraList *guiCameraList) {
    setEditable(false);
    setGuiCameraList();
    foreach (GuiCameraQsp guiCamera, *guiCameraList) {
      appendRow( new ProjectItem(guiCamera) );
@@ -284,6 +302,7 @@ namespace Isis {
   *                                                  from.
   */
  ProjectItem::ProjectItem(QList<BundleSolutionInfo *> results) {
    setEditable(false);
    setResults();
    foreach (BundleSolutionInfo *bundleSolutionInfo, results) {
      appendRow( new ProjectItem( bundleSolutionInfo) );
@@ -297,6 +316,7 @@ namespace Isis {
   * @param[in] targetBody (TargetBodyQsp) The target body to construct from.
   */
  ProjectItem::ProjectItem(TargetBodyQsp targetBody) {
    setEditable(false);
    setTargetBody(targetBody);
  }

@@ -307,6 +327,7 @@ namespace Isis {
   * @param[in] targetBodyList (TargetBodyList *) The list to construct from.
   */
  ProjectItem::ProjectItem(TargetBodyList *targetBodyList) {
    setEditable(false);
    setTargetBodyList();
    foreach (TargetBodyQsp targetBody, *targetBodyList) {
      appendRow( new ProjectItem(targetBody) );
@@ -604,6 +625,7 @@ namespace Isis {
    setText( item->text() );
    setIcon( item->icon() );
    setData( item->data() );
    setEditable(item->isEditable());
  }


+3 −1
Original line number Diff line number Diff line
@@ -110,6 +110,8 @@ namespace Isis {
   *                               to show up on the command line when cnetsuite is launched, 
   *                               and this fixed it.  Fixes #3982.
   *     @history 2016-12-02 Tracie Sucharski - Added ability to change text color for and item.
   *     @history 2017-04-17 Tracie Sucharski - Turn off editing on all items except for the project
   *                               name.
   */
  class ProjectItem : public QStandardItem {
    public:
+18 −0
Original line number Diff line number Diff line
@@ -639,5 +639,23 @@ namespace Isis {
    }
//  qDebug()<<"ProjectItemModel::onRowsRemoved  Source model : "<<this<<"  row count = "<<rowCount();
  }


  bool ProjectItemModel::setData(const QModelIndex &index, const QVariant &value, int role) {

    ProjectItem *item = itemFromIndex(index);
    if (item->isProject() && role == Qt::EditRole) {

      QString name = value.toString();
      emit projectNameEdited(name);
    }
    return true;
  }


  Qt::ItemFlags ProjectItemModel::flags(const QModelIndex &index) const {

    return Qt::ItemIsEditable | QStandardItemModel::flags(index);
  }
}
Loading