Isis 3 Programmer Reference
RenameProjectWorkOrder.cpp
Go to the documentation of this file.
1
22
23#include <QtDebug>
24
25#include <QFileDialog>
26#include <QInputDialog>
27#include <QMessageBox>
28
29#include "Directory.h"
30#include "MosaicSceneItem.h"
31#include "MosaicSceneWidget.h"
32#include "Project.h"
33
34namespace Isis {
35
45 WorkOrder(project) {
46
47 m_isUndoable = true;
48
49 QAction::setText(tr("&Rename Project..."));
50 QUndoCommand::setText(tr("Rename Project"));
51
52
54 internalData.append(project->name());
55 internalData.append(newName);
57 }
58
59
66 WorkOrder(project) {
67
68 m_isUndoable = true;
69
70 QAction::setText(tr("&Rename Project..."));
71 QUndoCommand::setText(tr("Rename Project"));
72 }
73
74
83 WorkOrder(other) {
84
85 m_isUndoable = other.m_isUndoable;
86 }
87
88
96
97
106
107
120 return (context == ProjectContext);
121 }
122
123
132 bool success = WorkOrder::setupExecution();
133
134 // Prompt for new project name. This will only happen if user initiated by right-clicking on
135 // project name from the project tree or selecting "Rename Project" from the Project menu.
136 // Otherwise, they double-clicked on the project name on the tree and entered a name through
137 // Qt's line edit.
138 if (success && internalData().count() == 0) {
139 QString newName;
140
141 do {
142 newName = QInputDialog::getText(NULL, tr("Enter Project Name"),
143 tr("Please enter the new project name"), QLineEdit::Normal,
144 project()->name(), &success);
145
146 if (success && !isNameValid(newName)) {
147 QMessageBox::critical(NULL, tr("Invalid Project Name"),
148 tr("Project name [%1] is not valid").arg(newName));
149 }
150 }
151 while (success && !isNameValid(newName));
152
154 internalData.append(project()->name());
155 internalData.append(newName);
157 }
158
159 QUndoCommand::setText(tr("Rename Project from [%1] to [%2]").
160 arg(internalData()[0]).arg(internalData()[1]));
161
162 return success && (internalData()[1] != project()->name());
163 }
164
165
170 bool RenameProjectWorkOrder::isNameValid(QString nameToCheck) {
171 return !nameToCheck.isEmpty();
172 }
173
174
184 // depend on types of ourselves only.
185 return dynamic_cast<RenameProjectWorkOrder *>(other);
186 }
187
188
195 project()->setClean(false);
196 }
197
198
210}
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
The main project for ipce.
Definition Project.h:289
void setName(QString newName)
Change the project's name (GUI only, doesn't affect location on disk).
Definition Project.cpp:1683
QString name() const
Get the project's GUI name.
Definition Project.cpp:1624
void setClean(bool value)
Function to change the clean state of the project.
Definition Project.cpp:1594
Change the project's GUI name.
virtual bool isExecutable(Context context)
This method returns true if the user clicked on the project name on the project tree,...
static bool isNameValid(QString nameToCheck)
Check the validity of the given (proposed) project name.
virtual bool setupExecution()
Setup this WorkOrder for execution.
RenameProjectWorkOrder(QString newName, Project *project)
Creates a work order to rename the project using the given new project name.
virtual RenameProjectWorkOrder * clone() const
This method clones the current RenameProjectWorkOrder and returns it.
virtual void undoExecution()
Changes the project name back to the old name.
bool dependsOn(WorkOrder *other) const
This WorkOrder is only dependent on another RenameProjectWorkOrder.
virtual void execute()
This will rename the project.
Provide Undo/redo abilities, serialization, and history for an operation.
Definition WorkOrder.h:311
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition WorkOrder.h:523
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
Context
This enumeration is for recording the context of the current Workorder (whether it is part of a proje...
Definition WorkOrder.h:339
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16