15#include <QInputDialog>
17#include <QProgressDialog>
18#include <QtConcurrentMap>
19#include <QXmlStreamWriter>
22#include "IException.h"
78 foreach (QString fileName, fileNames) {
105 for (
int i = 0; i < count(); i++) {
106 result.
add((*
this)[i]->fileName());
121 emit countChanged(count());
134 emit countChanged(count());
144 bool countChanging = count();
147 emit countChanged(count());
163 emit countChanged(count());
182 emit countChanged(count());
198 emit countChanged(count());
214 emit countChanged(count());
228 emit countChanged(count());
242 emit countChanged(count());
256 emit countChanged(count());
273 emit countChanged(count());
289 emit countChanged(count());
300 emit countChanged(count());
311 emit countChanged(count());
328 emit countChanged(count());
345 if (count() != other.count()) {
346 emit countChanged(count());
362 emit countChanged(count());
376 emit countChanged(count());
390 emit countChanged(count());
409 emit countChanged(count());
428 emit countChanged(count());
447 emit countChanged(count());
466 emit countChanged(count());
481 bool countChanging = (rhs.count() != count());
485 emit countChanged(count());
500 bool countChanging = (rhs.count() != count());
507 emit countChanged(count());
565 foreach (
Shape *shape, *
this) {
603 stream.writeStartElement(
"shapeList");
604 stream.writeAttribute(
"name",
m_name);
605 stream.writeAttribute(
"path",
m_path);
610 if (!settingsFileName.
dir().mkpath(settingsFileName.
path())) {
612 QString(
"Failed to create directory [%1]")
613 .arg(settingsFileName.
path()),
617 QFile shapeListContentsFile(settingsFileName.
toString());
619 if (!shapeListContentsFile.open(QIODevice::ReadWrite | QIODevice::Truncate)) {
621 QString(
"Unable to save shape information for [%1] because [%2] could not be opened for "
627 QXmlStreamWriter shapeDetailsWriter(&shapeListContentsFile);
628 shapeDetailsWriter.setAutoFormatting(
true);
629 shapeDetailsWriter.writeStartDocument();
631 int countWidth = QString(
"%1L").arg(count()).size() - 1;
632 QChar paddingChar(
'0');
634 QLabel *progressLabel =
new QLabel;
636 QProgressDialog progressDialog;
637 progressDialog.setLabel(progressLabel);
638 progressDialog.setRange(-1, count());
639 progressDialog.setValue(-1);
641 shapeDetailsWriter.writeStartElement(
"shapes");
643 QFuture<void *> future = QtConcurrent::mapped(*
this,
646 for (
int i = 0; i < count(); i++) {
647 int newProgressValue = progressDialog.value() + 1;
648 progressLabel->setText(
649 tr(
"Saving Shape Information for [%1] - %L2/%L3 done")
651 .arg(newProgressValue, countWidth, 10, paddingChar)
653 progressDialog.setValue(newProgressValue);
657 progressLabel->setText(tr(
"Finalizing..."));
658 progressDialog.setRange(0, 0);
659 progressDialog.setValue(0);
661 foreach (
Shape *shape, *
this) {
662 shape->
save(shapeDetailsWriter, project, newProjectRoot);
665 shapeDetailsWriter.writeEndElement();
667 shapeDetailsWriter.writeEndDocument();
669 stream.writeEndElement();
692 m_project = other.m_project;
693 m_newProjectRoot = other.m_newProjectRoot;
713 shapeToCopy->copyToNewProjectRoot(m_project, m_newProjectRoot);
728 m_newProjectRoot = rhs.m_newProjectRoot;
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 shapeDataRoot(QString projectRoot)
Appends the root directory name 'shapes' to the project .
QString shapeDataRoot() const
Accessor for the root directory of the shape model data.
Serial Number list generator.
void add(const QString &filename, bool def2filename=false)
Adds a new filename / serial number pair to the SerialNumberList.
This represents a shape in a project-based GUI interface.
void deleteFromDisk()
Delete the shape data from disk.
void save(QXmlStreamWriter &stream, const Project *project, FileName newProjectRoot) const
Output format:
This functor is used for copying the shapes between two projects quickly.
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.
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.
Internalizes a list of shapes and allows for operations on the entire list.
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.
void clear()
Clears the shape list.
QString m_path
This stores the directory name that contains the shapes in this shape list.
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).
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.
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.