23 #include "ExportImagesWorkOrder.h"
26 #include <QFileDialog>
28 #include <QInputDialog>
29 #include <QtConcurrentMap>
34 #include "ImageList.h"
42 ExportImagesWorkOrder::ExportImagesWorkOrder(Project *project) :
44 QAction::setText(tr(
"Export I&mages..."));
48 ExportImagesWorkOrder::ExportImagesWorkOrder(
const ExportImagesWorkOrder &other) :
53 ExportImagesWorkOrder::~ExportImagesWorkOrder() {
58 ExportImagesWorkOrder *ExportImagesWorkOrder::clone()
const {
59 return new ExportImagesWorkOrder(*
this);
72 return (!images->isEmpty());
92 imageListNames.append(list->
name());
95 qSort(imageListNames);
97 QString choice = QInputDialog::getItem(NULL, tr(
"Select Image List"),
98 tr(
"Please choose a list of images to export."), imageListNames, 0,
false, &success);
100 internalData.append(choice);
102 QUndoCommand::setText(tr(
"Export image list [%1]").arg(choice));
105 QUndoCommand::setText(tr(
"Export [%1] images").arg(
imageList()->count()));
108 QString destination = QFileDialog::getExistingDirectory(NULL, tr(
"Export Images"),
".");
110 if (destination.isEmpty()) {
113 internalData.append(destination);
129 if (list->isEmpty()) {
137 QFuture<void *> future = QtConcurrent::mapped(*list, functor);
141 QThreadPool::globalInstance()->releaseThread();
142 for (
int i = 0; i < list->count(); i++) {
149 QThreadPool::globalInstance()->reserveThread();
160 if (!m_warning.isEmpty()) {
174 QString destination) : m_errors(new
IException()), m_numErrors(new int(0)) {
176 m_destination = destination;
188 m_numErrors(other.m_numErrors) {
190 m_destination = other.m_destination;
219 QMutexLocker locker(&m_errorsLock);
239 if (*m_numErrors != 0) {
242 tr(
"Failed to export [%1] images").arg(*m_numErrors),
void setProgressValue(int)
Sets the current progress value for the WorkOrder.
Internalizes a list of images and allows for operations on the entire list.
File name manipulation and expansion.
void postSyncRedo()
Display any warnings that occurred during the asynchronous computations.
QString fileName() const
Get the file name of the cube that this image represents.
void asyncRedo()
Use internalData() and write the images into the output directory.
QString name() const
Get the human-readable name of this image list.
Project * project() const
Returns the Project this WorkOrder is attached to.
void append(const IException &exceptionSource)
Appends the given exception (and its list of previous exceptions) to this exception's causational exc...
QStringList internalData() const
Gets the internal data for this WorkOrder.
IException errors() const
Get the accumulated error list from this functor's run.
#define _FILEINFO_
Macro for the filename and line number.
Manipulate and parse attributes of output cube filenames.
A type of error that cannot be classified as any of the other error types.
This represents a cube in a project-based GUI interface.
ProjectImageExportFunctor(QString destination)
Create an image export functor that will copy the image's cubes into the given destination directory...
bool execute()
Prompts the user for input.
void setProgressRange(int, int)
Sets the progress range of the WorkOrder.
bool isExecutable(ImageList *images)
Currently, this work order only works with either no data (file menu) or with any number of images...
QString toString() const
Returns a string representation of this exception.
This functor is meant for QtConcurrentMap.
Cube * cube()
Get the Cube pointer associated with this display property.
~ProjectImageExportFunctor()
Destroys the functor.
virtual bool execute()
The (child) implementation of this method should prompt the user/gather state by any means necessary...
ImageList * imageList()
a pointer to the ImageList for this WorkOrder.
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
void closeCube()
Cleans up the Cube pointer.
void * operator()(Image *const &imageToExport)
Write the given image's cube into the destination folder (preserves the base name).