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 
32 namespace 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 
57 
58  if (images) {
59  return !images->isEmpty();
60  }
61  return false;
62  }
63 
64 
65 
76  bool success = WorkOrder::setupExecution();
77 
78  if (success) {
79  QStringList viewOptions;
80 
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 
125  internalData.append(QString::number(viewToUse));
127  }
128 
129  return success;
130  }
131 
132 
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 }
QString name() const
Get the human-readable name of this image list.
Definition: ImageList.cpp:724
Internalizes a list of images and allows for operations on the entire list.
Definition: ImageList.h:55
ImageFileListWidget * addImageFileListView(QString objectName="")
Add an imageFileList widget to the window.
Definition: Directory.cpp:1040
QList< ImageFileListWidget * > imageFileListViews()
Accessor for the list of ImageFileListWidgets currently available.
Definition: Directory.cpp:1439
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1275
Directory * directory() const
Returns the directory associated with this Project.
Definition: Project.cpp:1229
bool isExecutable(ImageList *images)
Re-implement this method if your work order utilizes images for data in order to operate.
void addImages(ImageList *images)
This method adds the new images to the tree.
bool setupExecution()
This method asks the user what view they want to see their image list in.
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:534
void execute()
This method adds a new image file list to the project&#39;s directory and then adds currentItem() to that...
A colored, grouped cube list.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1314
ImageList * imageList()
Returns a pointer to the ImageList for this WorkOrder.
Definition: WorkOrder.cpp:645
bool m_isSavedToHistory
Set the work order to be shown in the HistoryTreeWidget.
Definition: WorkOrder.h:548
QStringList internalData() const
Gets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1391
void setInternalData(QStringList data)
Sets the internal data for this WorkOrder.
Definition: WorkOrder.cpp:1332
Directory * directory() const
return the workorder project directory Returns the Directory object of the Project this WorkOrder is ...
Definition: WorkOrder.cpp:1304
void setClean(bool value)
Function to change the clean state of the project.
Definition: Project.cpp:1595