9#include "ControlList.h"
12#include <QColorDialog>
17#include <QInputDialog>
19#include <QProgressDialog>
20#include <QtConcurrentMap>
21#include <QXmlStreamWriter>
25#include "IException.h"
80 foreach (QString fileName, fileNames) {
95 emit deletingList(
this);
108 emit countChanged(count());
121 emit countChanged(count());
131 bool countChanging = count();
134 emit countChanged(count());
150 emit countChanged(count());
167 emit countChanged(count());
183 emit countChanged(count());
199 emit countChanged(count());
213 emit countChanged(count());
227 emit countChanged(count());
241 emit countChanged(count());
258 emit countChanged(count());
274 emit countChanged(count());
285 emit countChanged(count());
296 emit countChanged(count());
313 emit countChanged(count());
330 if (count() != other.count()) {
331 emit countChanged(count());
347 emit countChanged(count());
361 emit countChanged(count());
375 emit countChanged(count());
393 emit countChanged(count());
411 emit countChanged(count());
429 emit countChanged(count());
447 emit countChanged(count());
462 bool countChanging = (rhs.count() != count());
466 emit countChanged(count());
483 bool countChanging = (rhs.count() != count());
490 emit countChanged(count());
548 foreach (
Control *control, *
this) {
553 QFile::remove(project->
cnetRoot() +
"/" +
m_path +
"/controlNetworks.xml");
586 stream.writeStartElement(
"controlList");
587 stream.writeAttribute(
"name",
m_name);
588 stream.writeAttribute(
"path",
m_path);
592 "/controlNetworks.xml");
594 if (!settingsFileName.
dir().mkpath(settingsFileName.
path())) {
596 QString(
"Failed to create directory [%1]")
597 .arg(settingsFileName.
path()),
601 QFile controlListContentsFile(settingsFileName.
toString());
603 if (!controlListContentsFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
605 QString(
"Unable to save control information for [%1] because [%2] could not be opened "
611 QXmlStreamWriter controlDetailsWriter(&controlListContentsFile);
612 controlDetailsWriter.setAutoFormatting(
true);
613 controlDetailsWriter.writeStartDocument();
615 int countWidth = QString(
"%1L").arg(count()).size() - 1;
616 QChar paddingChar(
'0');
618 QLabel *progressLabel =
new QLabel;
620 QProgressDialog progressDialog;
621 progressDialog.setLabel(progressLabel);
622 progressDialog.setRange(-1, count());
623 progressDialog.setValue(-1);
625 controlDetailsWriter.writeStartElement(
"controls");
629 QFuture<void *> future = QtConcurrent::mapped(*
this,
631 for (
int i = 0; i < count(); i++) {
632 int newProgressValue = progressDialog.value() + 1;
633 progressLabel->setText(
634 tr(
"Saving Control Information for [%1] - %L2/%L3 done")
636 .arg(newProgressValue, countWidth, 10, paddingChar)
638 progressDialog.setValue(newProgressValue);
642 progressLabel->setText(tr(
"Finalizing..."));
643 progressDialog.setRange(0, 0);
644 progressDialog.setValue(0);
647 foreach (
Control *control, *
this) {
648 control->
save(controlDetailsWriter, project, newProjectRoot);
651 controlDetailsWriter.writeEndElement();
653 controlDetailsWriter.writeEndDocument();
655 stream.writeEndElement();
678 m_project = other.m_project;
679 m_newProjectRoot = other.m_newProjectRoot;
696 controlToCopy->copyToNewProjectRoot(m_project, m_newProjectRoot);
711 m_newProjectRoot = rhs.m_newProjectRoot;
This represents an ISIS control net in a project-based GUI interface.
void deleteFromDisk()
Delete the control net from disk.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Control object's member data to an XML stream.
This functor is used for copying the control nets between two projects quickly.
CopyControlDataFunctor & operator=(const CopyControlDataFunctor &rhs)
CopyControlDataFunctor assignment operator.
~CopyControlDataFunctor()
CopyControlDataFunctor destructor.
void * operator()(Control *const &controlToCopy)
Copies the Control from one project to another.
const Project * m_project
Project to copy the control list to.
FileName m_newProjectRoot
The filename of the destination project's root.
CopyControlDataFunctor(const Project *project, FileName newProjectRoot)
CopyControlDataFunctor constructor.
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
void deleteFromDisk(Project *project)
Delete all of the contained Controls from disk.
void removeLast()
Removes the last control pointer from the control list.
iterator erase(iterator pos)
Erases a control pointer from the control list at the specified position.
void append(Control *const &value)
Appends a control pointer to the control list.
~ControlList()
Destructor.
void push_back(Control *const &value)
Equivalent to append(value)
ControlList & operator+=(const QList< Control * > &other)
Appends control pointers from the other list to this control list.
void insert(int i, Control *const &value)
Inserts a control pointer at the specified position in the control list.
QString path() const
Get the path to these controls in the control list (relative to project root).
QString name() const
Get the human-readable name of this control list.
void setName(QString newName)
Set the human-readable name of this control list.
void removeAt(int i)
Removes the control pointer at the specified index.
bool removeOne(Control *const &value)
Removes the first occurence of the control pointer from the control list.
void push_front(Control *const &value)
Equivalent to prepend(value)
Control * takeAt(int i)
Remove the control pointer at the specified index and returns it.
Control * takeFirst()
Removes the first control pointer from the control list and returns it.
ControlList & operator=(const QList< Control * > &rhs)
Assigns another list of control pointers to this control list.
int removeAll(Control *const &value)
Removes all occurences of the control pointer in the control list.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this control list into XML format for saving/restoring capabilities.
void setPath(QString newPath)
Set the relative path (from the project root) to this control list's folder.
void prepend(Control *const &value)
Prepends a control pointer to the control list.
QString m_name
Name of the ControlList.
ControlList & operator<<(const QList< Control * > &other)
Appends a list of other control pointers to this control list.
void swap(QList< Control * > &other)
Swaps this control list's control pointers with the other list of control pointers.
void clear()
Clears the control list.
QString m_path
This stores the directory name that contains the controls in this control list.
Control * takeLast()
Removes the last control pointer from the control list and returns it.
void removeFirst()
Removes the first control pointer from the control list.
ControlList(QString name, QString path, QObject *parent=NULL)
Create an control list from a control list name and path (does not read Controls).
File name manipulation and expansion.
QString path() const
Returns the path of the file name.
QDir dir() const
Returns the path of the file's parent directory as a QDir object.
QString original() const
Returns the full file name including the file path.
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
@ Io
A type of error that occurred when performing an actual I/O operation.
The main project for ipce.
static QString cnetRoot(QString projectRoot)
Appends the root directory name 'cnets' to the project.
QString newProjectRoot() const
Get the top-level folder of the new project.
QString cnetRoot() const
Get where control networks ought to be stored inside the project.
QString projectRoot() const
Get the top-level folder of the project.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.