Isis Developer Reference
ControlList.h
Go to the documentation of this file.
1 #ifndef ControlList_H
2 #define ControlList_H
3 
10 /* SPDX-License-Identifier: CC0-1.0 */
11 
12 #include <QDebug>
13 #include <QList>
14 #include <QMetaType>
15 #include <QObject>
16 
17 #include "Control.h"
19 #include "XmlStackedHandler.h"
20 
21 class QStringList;
22 class QXmlStreamWriter;
23 
24 namespace Isis {
25  class FileName;
26  class XmlStackedHandlerReader;
27 
44  class ControlList : public QObject, public QList<Control *> {
45  Q_OBJECT
46 
47  public:
48 
49  ControlList(QString name, QString path, QObject *parent = NULL);
50  explicit ControlList(QObject *parent = NULL);
51  explicit ControlList(QList<Control *>, QObject *parent = NULL);
52  explicit ControlList(Project *project, XmlStackedHandlerReader *xmlReader,
53  QObject *parent = NULL);
54  explicit ControlList(QStringList &);
55  ControlList(const ControlList &);
56  ~ControlList();
57 
58  // These are overridden (-ish) in order to add notifications to the list changing
59  void append(Control * const &value);
60  void append(const QList<Control *> &value);
61 
62  void clear();
63 
64  iterator erase(iterator pos);
65  iterator erase(iterator begin, iterator end);
66 
67  void insert(int i, Control * const &value);
68  iterator insert(iterator before, Control * const &value);
69 
70  void prepend(Control * const &value);
71  void push_back(Control * const &value);
72  void push_front(Control * const &value);
73  int removeAll(Control * const &value);
74  void removeAt(int i);
75  void removeFirst();
76  void removeLast();
77  bool removeOne(Control * const &value);
78  void swap(QList<Control *> &other);
79  Control *takeAt(int i);
80  Control *takeFirst();
81  Control *takeLast();
82 
84  ControlList &operator+=(Control * const &other);
86  ControlList &operator<<(Control * const &other);
88 
89  // This is our own assignment, but it needs to notify just like the operator=(QList)
90  ControlList &operator=(const ControlList &rhs);
91 
92  // Done overriding (-ish)
93 
94 
97 
98  void setName(QString newName);
99  void setPath(QString newPath);
100 
101  QString name() const;
102  QString path() const;
103 
104  void deleteFromDisk(Project *project);
105  void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const;
106 
107 
108  signals:
109  void countChanged(int newCount);
111 
112  private:
113 
114 
126  class CopyControlDataFunctor : public std::unary_function<Control * const &, void *> {
127  public:
128  CopyControlDataFunctor(const Project *project, FileName newProjectRoot);
129  CopyControlDataFunctor(const CopyControlDataFunctor &other);
130  ~CopyControlDataFunctor();
131 
132  void *operator()(Control * const &controlToCopy);
133 
134  CopyControlDataFunctor &operator=(const CopyControlDataFunctor &rhs);
135 
136  private:
137  const Project *m_project;
138  FileName m_newProjectRoot;
139  };
140 
152  class XmlHandler : public XmlStackedHandler {
153  public:
154  XmlHandler(ControlList *controlList, Project *project);
155 
156  virtual bool startElement(const QString &namespaceURI, const QString &localName,
157  const QString &qName, const QXmlAttributes &atts);
158  virtual bool endElement(const QString &namespaceURI, const QString &localName,
159  const QString &qName);
160 
161  private:
162  Q_DISABLE_COPY(XmlHandler);
163 
164  ControlList *m_controlList;
165  Project *m_project;
166  };
167 
168 
169  private:
170  QString m_name;
171 
182  QString m_path;
183  };
184 }
185 
187 
188 #endif
Isis::ControlList::setPath
void setPath(QString newPath)
Set the relative path (from the project root) to this control list's folder.
Definition: ControlList.cpp:529
operator<<
QDebug operator<<(QDebug dbg, const Isis::Angle &angleToPrint)
Display an Angle for a debugging statement.
Definition: Angle.cpp:368
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(Isis::ControlList *)
FileName.h
Isis::ControlList::operator<<
ControlList & operator<<(const QList< Control * > &other)
Appends a list of other control pointers to this control list.
Definition: ControlList.cpp:440
Isis::ControlList::operator=
ControlList & operator=(const QList< Control * > &rhs)
Assigns another list of control pointers to this control list.
Definition: ControlList.cpp:476
Isis::IException::Io
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:155
Isis::ControlList::save
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this control list into XML format for saving/restoring capabilities.
Definition: ControlList.cpp:599
Isis::Project::cnetRoot
QString cnetRoot() const
Get where control networks ought to be stored inside the project.
Definition: Project.cpp:2029
Isis::ControlList::setName
void setName(QString newName)
Set the human-readable name of this control list.
Definition: ControlList.cpp:518
QList< Control * >
Project.h
Isis::Control::deleteFromDisk
void deleteFromDisk()
Delete the control net from disk.
Definition: Control.cpp:334
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::ControlList
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition: ControlList.h:44
Isis::XmlStackedHandlerReader::pushContentHandler
virtual void pushContentHandler(XmlStackedHandler *newHandler)
Push a contentHandler and maybe continue parsing...
Definition: XmlStackedHandlerReader.cpp:55
Isis::ControlList::ControlList
ControlList(QString name, QString path, QObject *parent=NULL)
Create an control list from a control list name and path (does not read Controls).
Definition: ControlList.cpp:37
Isis::ControlList::~ControlList
~ControlList()
Destructor.
Definition: ControlList.cpp:109
Isis::ControlList::erase
iterator erase(iterator pos)
Erases a control pointer from the control list at the specified position.
Definition: ControlList.cpp:163
Isis::XmlStackedHandler::startElement
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
Definition: XmlStackedHandler.cpp:44
Isis::Project::cnetRoot
static QString cnetRoot(QString projectRoot)
Appends the root directory name 'cnets' to the project.
Definition: Project.cpp:2019
Isis::Control
This represents an ISIS control net in a project-based GUI interface.
Definition: Control.h:66
Isis::ControlList::removeLast
void removeLast()
Removes the last control pointer from the control list.
Definition: ControlList.cpp:309
Color.h
Isis::ControlList::swap
void swap(QList< Control * > &other)
Swaps this control list's control pointers with the other list of control pointers.
Definition: ControlList.cpp:342
QStringList
Isis::XmlStackedHandlerReader
Manage a stack of content handlers for reading XML files.
Definition: XmlStackedHandlerReader.h:30
Isis::ControlList::push_front
void push_front(Control *const &value)
Equivalent to prepend(value)
Definition: ControlList.cpp:254
Isis::ControlList::path
QString path() const
Get the path to these controls in the control list (relative to project root).
Definition: ControlList.cpp:550
Isis::Control::save
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Method to write this Control object's member data to an XML stream.
Definition: Control.cpp:373
ControlList.h
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::ReadWrite
const int ReadWrite
Definition: Process.h:24
_FILEINFO_
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:24
Isis::FileName::dir
QDir dir() const
Returns the path of the file's parent directory as a QDir object.
Definition: FileName.cpp:465
Isis::ControlList::allSupport
bool allSupport(ControlDisplayProperties::Property prop)
Isis::ControlList::removeOne
bool removeOne(Control *const &value)
Removes the first occurence of the control pointer from the control list.
Definition: ControlList.cpp:324
Isis::ControlList::countChanged
void countChanged(int newCount)
Isis::Project::newProjectRoot
QString newProjectRoot() const
Get the top-level folder of the new project.
Definition: Project.cpp:1675
Isis::XmlStackedHandler::endElement
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
Definition: XmlStackedHandler.cpp:55
ControlDisplayProperties.h
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::ControlList::operator+=
ControlList & operator+=(const QList< Control * > &other)
Appends control pointers from the other list to this control list.
Definition: ControlList.cpp:404
Isis::FileName::toString
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Definition: FileName.cpp:515
Isis::Project::projectRoot
QString projectRoot() const
Get the top-level folder of the project.
Definition: Project.cpp:1666
Isis::ControlList::removeAt
void removeAt(int i)
Removes the control pointer at the specified index.
Definition: ControlList.cpp:287
IException.h
Isis::ControlList::clear
void clear()
Clears the control list.
Definition: ControlList.cpp:145
Isis::ControlList::takeFirst
Control * takeFirst()
Removes the first control pointer from the control list and returns it.
Definition: ControlList.cpp:374
Isis::ControlList::supportedActions
QList< QAction * > supportedActions(Project *project=NULL)
Isis::ControlList::prepend
void prepend(Control *const &value)
Prepends a control pointer to the control list.
Definition: ControlList.cpp:226
Isis::ControlList::takeAt
Control * takeAt(int i)
Remove the control pointer at the specified index and returns it.
Definition: ControlList.cpp:360
Isis::ControlList::removeAll
int removeAll(Control *const &value)
Removes all occurences of the control pointer in the control list.
Definition: ControlList.cpp:269
Isis::ControlList::name
QString name() const
Get the human-readable name of this control list.
Definition: ControlList.cpp:539
Isis::XmlStackedHandler
XML Handler that parses XMLs in a stack-oriented way.
Definition: XmlStackedHandler.h:118
Control.h
Isis::ControlList::append
void append(Control *const &value)
Appends a control pointer to the control list.
Definition: ControlList.cpp:121
Isis::ControlList::deleteFromDisk
void deleteFromDisk(Project *project)
Delete all of the contained Controls from disk.
Definition: ControlList.cpp:562
Isis::ControlList::removeFirst
void removeFirst()
Removes the first control pointer from the control list.
Definition: ControlList.cpp:298
Isis::ControlDisplayProperties::Property
Property
This is a list of properties and actions that are possible.
Definition: ControlDisplayProperties.h:65
QObject
Isis::FileName::original
QString original() const
Returns the full file name including the file path.
Definition: FileName.cpp:212
Isis::ControlList::takeLast
Control * takeLast()
Removes the last control pointer from the control list and returns it.
Definition: ControlList.cpp:388
XmlStackedHandlerReader.h
XmlStackedHandler.h
Isis::ControlList::insert
void insert(int i, Control *const &value)
Inserts a control pointer at the specified position in the control list.
Definition: ControlList.cpp:195
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis::ControlList::push_back
void push_back(Control *const &value)
Equivalent to append(value)
Definition: ControlList.cpp:240
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::ControlList::deletingList
void deletingList(ControlList *list)