Isis 3 Programmer Reference
ImageFileListViewWorkOrder.cpp
Go to the documentation of this file.
1
24
25#include <QDebug>
26#include <QInputDialog>
27
28#include "Directory.h"
29#include "Project.h"
30#include "ImageFileListWidget.h"
31
32namespace Isis {
33
34 ImageFileListViewWorkOrder::ImageFileListViewWorkOrder(Project *project) :
35 WorkOrder(project) {
36 QAction::setText(tr("View File &Names..."));
37 m_isSavedToHistory = false;
38 m_isUndoable = false;
39 }
40
41
42 ImageFileListViewWorkOrder::ImageFileListViewWorkOrder(const ImageFileListViewWorkOrder &other) :
43 WorkOrder(other) {
44 }
45
46
47 ImageFileListViewWorkOrder::~ImageFileListViewWorkOrder() {
48 }
49
50
51 ImageFileListViewWorkOrder *ImageFileListViewWorkOrder::clone() const {
52 return new ImageFileListViewWorkOrder(*this);
53 }
54
55
56 bool ImageFileListViewWorkOrder::isExecutable(ImageList *images) {
57
58 if (images) {
59 return !images->isEmpty();
60 }
61 return false;
62 }
63
64
65
75 bool ImageFileListViewWorkOrder::setupExecution() {
76 bool success = WorkOrder::setupExecution();
77
78 if (success) {
79 QStringList viewOptions;
80
81 QList<ImageFileListWidget *> existingViews = project()->directory()->imageFileListViews();
82 int viewToUse = -1;
83
84 if (existingViews.count()) {
85 for (int i = 0; i < existingViews.count(); i++) {
86 viewOptions.append(existingViews[i]->windowTitle());
87 }
88 }
89
90 viewOptions.append(tr("New File List View"));
91
92 if (viewOptions.count() > 1) {
93 QString selected = QInputDialog::getItem(NULL, tr("View to see files in"),
94 tr("Which view would you like your\nimage's file names to be put into?"),
95 viewOptions, viewOptions.count() - 1, false, &success);
96
97 viewToUse = viewOptions.indexOf(selected);
98 }
99 else {
100 viewToUse = viewOptions.count() - 1;
101 }
102
103 if (viewToUse == viewOptions.count() - 1) {
104 if (!imageList()->name().isEmpty()) {
105 QUndoCommand::setText(tr("View image file names of list [%1] in new file list view")
106 .arg(imageList()->name()));
107 }
108 else {
109 QUndoCommand::setText(tr("View [%1] Image File Names in new file list view")
110 .arg(imageList()->count()));
111 }
112 }
113 else if (viewToUse != -1) {
114 if (!imageList()->name().isEmpty()) {
115 QUndoCommand::setText(tr("View image file names of list [%1] in file list view [%2]")
116 .arg(imageList()->name()).arg(existingViews[viewToUse]->windowTitle()));
117 }
118 else {
119 QUndoCommand::setText(tr("View [%1] Image File Names in file list view [%2]")
120 .arg(imageList()->count()).arg(existingViews[viewToUse]->windowTitle()));
121 }
122 }
123
124 QStringList internalData;
125 internalData.append(QString::number(viewToUse));
126 setInternalData(internalData);
127 }
128
129 return success;
130 }
131
132
137 void ImageFileListViewWorkOrder::execute() {
138
139 int viewToUse = internalData().first().toInt();
140
141 ImageFileListWidget *fileListToUse = NULL;
142 if (viewToUse == project()->directory()->imageFileListViews().count()) {
143 fileListToUse = project()->directory()->addImageFileListView();
144 }
145 else {
146 fileListToUse = project()->directory()->imageFileListViews()[viewToUse];
147 }
148
149 fileListToUse->addImages(imageList());
150 project()->setClean(false);
151 }
152}
A colored, grouped cube list.
void addImages(ImageList *images)
This method adds the new images to the tree.
Internalizes a list of images and allows for operations on the entire list.
Definition ImageList.h:55
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16