29#include <QtConcurrentMap>
32#include "ControlList.h"
33#include "ControlNet.h"
34#include "IException.h"
37#include "ProjectItem.h"
38#include "ProjectItemModel.h"
56 QAction::setText(tr(
"Import &Control Networks..."));
60 m_watcher =
new QFutureWatcher<Control *>;
73 m_watcher =
new QFutureWatcher<Control *>;
110 return (item->text() ==
"Control Networks");
127 QUndoCommand::setText(tr(
"Import Control Networks"));
131 QStringList cnetFileNames = QFileDialog::getOpenFileNames(
132 qobject_cast<QWidget *>(parent()),
133 tr(
"Import Control Networks"),
"",
134 tr(
"Isis control nets (*.net);;All Files (*)"));
136 if (!cnetFileNames.isEmpty()) {
137 QUndoCommand::setText(tr(
"Import %1 Control Networks").arg(cnetFileNames.count()));
156 QList< QPair<FileName, Progress *> > cnetFileNamesAndProgress;
157 foreach (
FileName fileName, cnetFileNames) {
159 cnetFileNamesAndProgress.append(qMakePair(fileName, readProgress));
165 m_watcher->setFuture(QtConcurrent::mapped(cnetFileNamesAndProgress,
170 int totalProgress = 0;
175 if (
m_watcher->future().isResultReadyAt(i)) {
176 totalProgress += 100;
181 totalProgress += qRound(progressPercent * 90);
189 QThread::yieldCurrentThread();
256 const QPair<FileName, Progress *> &cnetFileNameAndProgress) {
260 QString cnetFileName = cnetFileNameAndProgress.first.original();
263 cnet->ReadControl(cnetFileName, cnetFileNameAndProgress.second);
266 QString destination = m_destinationFolder.canonicalPath() +
"/" + baseFilename;
268 cnet->Write(destination);
290 QMutexLocker locker(
project()->workOrderMutex());
This represents an ISIS control net in a project-based GUI interface.
void closeControlNet()
Cleans up the ControlNet pointer.
File name manipulation and expansion.
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
Control * operator()(const QPair< FileName, Progress * > &cnetFilename)
Reads and writes the control network(s) asynchronously.
Project * m_project
The project to import to.
IException errors() const
Indicates if any errors occurred during the import.
CreateControlsFunctor(Project *project, QDir destinationFolder)
CreateControlsFunctor constructor.
QDir m_destinationFolder
The directory to copy the control net too.
Add control networks to a project c Asks the user for a list of control nets and copies them into the...
QList< Progress * > m_readProgresses
Keeps track of import progress.
~ImportControlNetWorkOrder()
Destructor.
ImportControlNetWorkOrder(Project *project)
Creates a work order to import a control network.
void execute()
Imports the control network asynchronously.
void cnetReady(int ready)
Adds the control net to the project.
bool setupExecution()
Sets up the work order for execution.
ControlList * m_list
List of controls added to project.
QString m_warning
String of any errors/warnings that occurred during import.
virtual ImportControlNetWorkOrder * clone() const
This method clones the current ImportControlNetWorkOrder and returns it.
QFutureWatcher< Control * > * m_watcher
QFutureWatcher, allows for asynchronous import.
virtual bool isExecutable(ProjectItem *item)
This method returns true if the user clicked on a project tree node with the text "Control Networks".
void postExecution()
Clears progress.
Program progress reporter.
int MaximumSteps() const
Returns the maximum number of steps of the progress.
void DisableAutomaticDisplay()
Turns off updating the Isis Gui when CheckStatus() is called.
int CurrentStep() const
Returns the current step of the progress.
The main project for ipce.
QDir addCnetFolder(QString prefix)
Create and return the name of a folder for placing control networks.
void addControl(Control *control)
Add the given Control's to the current project.
QList< ControlList * > controls()
Return controls in project.
void setClean(bool value)
Function to change the clean state of the project.
Control * activeControl()
Return the Active Control (control network)
Represents an item of a ProjectItemModel in Qt's model-view framework.
Provide Undo/redo abilities, serialization, and history for an operation.
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
bool m_isSynchronous
This is defaulted to true.
@ WorkOrderFinished
This is used for work orders that will not undo or redo (See createsCleanState())
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
virtual bool setupExecution()
This sets up the state for the work order.
QStringList internalData() const
Gets the internal data for this WorkOrder.
void setModifiesDiskState(bool changesProjectOnDisk)
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Project * project() const
Returns the Project this WorkOrder is attached to.
QPointer< Project > m_project
A pointer to the Project this WorkOrder is attached to.
This is free and unencumbered software released into the public domain.