Isis 3 Programmer Reference
ShapeList.h
1#ifndef ShapeList_H
2#define ShapeList_H
3
4#include <QDebug>
5#include <QObject>
6#include <QList>
7#include <QMetaType>
8
9#include "Shape.h"
10#include "ShapeDisplayProperties.h"
11#include "SerialNumberList.h"
12#include "WorkOrder.h"
13
14class QStringList;
15class QXmlStreamWriter;
16
17namespace Isis {
18 class FileName;
19
31 class ShapeList : public QObject, public QList<Shape *> {
32 Q_OBJECT
33
34 public:
35 ShapeList(QString name, QString path, QObject *parent = NULL);
36 explicit ShapeList(QObject *parent = NULL);
37 explicit ShapeList(QList<Shape *>, QObject *parent = NULL);
38 explicit ShapeList(QStringList &);
39 ShapeList(const ShapeList &);
40 ~ShapeList();
41
43
44 // These are overridden (-ish) in order to add notifications to the list changing
45 void append(Shape * const & value);
46 void append(const QList<Shape *> &value);
47
48 void clear();
49
50 iterator erase(iterator pos);
51 iterator erase(iterator begin, iterator end);
52
53 void insert(int i, Shape * const & value);
54 iterator insert(iterator before, Shape * const & value);
55
56 void prepend(Shape * const & value);
57 void push_back(Shape * const & value);
58 void push_front(Shape * const & value);
59 int removeAll(Shape * const & value);
60 void removeAt(int i);
61 void removeFirst();
62 void removeLast();
63 bool removeOne(Shape * const & value);
64 void swap(QList<Shape *> &other);
65 Shape *takeAt(int i);
67 Shape *takeLast();
68
69 ShapeList &operator+=(const QList<Shape *> &other);
70 ShapeList &operator+=(Shape * const &other);
71 ShapeList &operator<<(const QList<Shape *> &other);
72 ShapeList &operator<<(Shape * const &other);
73 ShapeList &operator=(const QList<Shape *> &rhs);
74
75 // This is our own assignment, but it needs to notify just like the operator=(QList)
76 ShapeList &operator=(const ShapeList &rhs);
77
78 // Done overriding (-ish)
79
80 void setName(QString newName);
81 void setPath(QString newPath);
82
83 QString name() const;
84 QString path() const;
85
86 void deleteFromDisk(Project *project);
87 void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const;
88
89
90 signals:
91 void countChanged(int newCount);
92
93 private:
94
104 class CopyShapeDataFunctor : public std::function<void *(Shape * const &)> {
105 public:
106 CopyShapeDataFunctor(const Project *project, FileName newProjectRoot);
109
110 void *operator()(Shape * const &shapeToCopy);
111
113
114 private:
123 };
124
125 private slots:
126
127 private:
131 QString m_name;
132
143 QString m_path;
144 };
145
146}
147
148Q_DECLARE_METATYPE(Isis::ShapeList *);
149
150#endif
File name manipulation and expansion.
Definition FileName.h:100
The main project for ipce.
Definition Project.h:287
Serial Number list generator.
This represents a shape in a project-based GUI interface.
Definition Shape.h:66
This functor is used for copying the shapes between two projects quickly.
Definition ShapeList.h:104
CopyShapeDataFunctor(const Project *project, FileName newProjectRoot)
Constructor for CopyShapeDataFunctor.
CopyShapeDataFunctor & operator=(const CopyShapeDataFunctor &rhs)
Assignment operator for CopyShapeDataFunctor.
FileName m_newProjectRoot
This stores the path to the root of the project that is going to be copied to.
Definition ShapeList.h:122
void * operator()(Shape *const &shapeToCopy)
Copies the cub/ecub files for an shape into m_project.
~CopyShapeDataFunctor()
Destructor for CopyShapeDataFunctor.
const Project * m_project
This stores the name of the project that is going to be copied to.
Definition ShapeList.h:118
Internalizes a list of shapes and allows for operations on the entire list.
Definition ShapeList.h:31
void insert(int i, Shape *const &value)
Inserts an shape into the shape list at an index.
void append(Shape *const &value)
Appends an shape to the shape list.
void deleteFromDisk(Project *project)
Delete all of the contained Shapes from disk.
void removeAt(int i)
Removes the shape at an index.
void setName(QString newName)
Set the human-readable name of this shape list.
Shape * takeLast()
Removes and returns the last shape.
iterator erase(iterator pos)
Erases a single shape from the shape list.
SerialNumberList serialNumberList()
Creates a SerialNumberList from the shape list.
void swap(QList< Shape * > &other)
Swaps the shape list with another list of shapes.
QString m_name
This stores the shape list's name.
Definition ShapeList.h:131
void clear()
Clears the shape list.
QString m_path
This stores the directory name that contains the shapes in this shape list.
Definition ShapeList.h:143
void push_back(Shape *const &value)
Appends an shape to the end of the shape list.
void removeFirst()
Removes the shape at the front of the shape list.
void removeLast()
Removes the shape at the end of the shape list.
QString path() const
Get the path to the shapes in the shape list (relative to project root).
int removeAll(Shape *const &value)
Removes all occurances of an shape.
QString name() const
Get the human-readable name of this shape list.
void prepend(Shape *const &value)
Inserts an shape at the beginning of the shape list.
Shape * takeAt(int i)
Removes the shape at an index and returns it.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Convert this shape list into XML format for saving/restoring capabilities.
ShapeList(QString name, QString path, QObject *parent=NULL)
Creates an shape list from an shape list name and path (does not read Shapes).
Definition ShapeList.cpp:34
void push_front(Shape *const &value)
Prepends an shape to the beginning of the shape list.
ShapeList & operator<<(const QList< Shape * > &other)
Appends a list of shapes to the end of the shape list.
~ShapeList()
Destructor.
Definition ShapeList.cpp:92
bool removeOne(Shape *const &value)
Removes the first occurance of an shape.
ShapeList & operator=(const QList< Shape * > &rhs)
Assigns another list of shapes to the shape list.
void setPath(QString newPath)
Set the relative path (from the project root) to this shape list's folder.
Shape * takeFirst()
Removes and returns the first shape.
ShapeList & operator+=(const QList< Shape * > &other)
Appends a list of shapes to the end of the shape list.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16