Isis 3 Programmer Reference
ImageFileListWidget.cpp
1#include "ImageFileListWidget.h"
2
3#include <iostream>
4
5#include <QAction>
6#include <QApplication>
7#include <QContextMenuEvent>
8#include <QDebug>
9#include <QFileDialog>
10#include <QInputDialog>
11#include <QHBoxLayout>
12#include <QLabel>
13#include <QMenu>
14#include <QPoint>
15#include <QPushButton>
16#include <QScrollArea>
17#include <QSettings>
18#include <QSize>
19#include <QToolBar>
20#include <QVBoxLayout>
21#include <QXmlStreamWriter>
22
23#include "Directory.h"
24#include "FileName.h"
25#include "IException.h"
26#include "Image.h"
27#include "ImageTreeWidget.h"
28#include "ImageTreeWidgetItem.h"
29#include "IString.h"
30#include "ProgressBar.h"
31#include "Project.h"
32#include "PvlObject.h"
33#include "Shape.h"
34#include "TextFile.h"
35#include "XmlStackedHandlerReader.h"
36
37namespace Isis {
38
47 QWidget *parent) : QWidget(parent) {
48 QWidget *treeWidget = new QWidget();
49 m_directory = directory;
50 QHBoxLayout *layout = new QHBoxLayout();
51
52 m_tree = new ImageTreeWidget(directory);
53 m_tree->setObjectName("Tree");
54 layout->addWidget(m_tree);
55
56 layout->setContentsMargins(0, 0, 0, 0);
57
58 setWhatsThis("This is the image file list. Opened "
59 "cubes show up here. You can arrange your cubes into groups (that you "
60 "name) to help keep track of them. Also, you can configure multiple "
61 "files at once. Finally, you can sort your files by any of the visible "
62 "columns (use the view menu to show/hide columns of data).");
63
64 treeWidget->setLayout(layout);
65
67 m_progress->setVisible(false);
68
69 m_searchToolbar = new QToolBar("Search Tool", this);
70 m_searchToolbar->setObjectName("Search Tool");
71 m_searchToolbar->setWhatsThis("This contains all the fields for searching the active file list");
72
73 m_searchLineEdit = new QLineEdit();
74 QPushButton *okButton = new QPushButton("Search");
75 connect(okButton, SIGNAL(clicked()), this, SLOT(filterFileList()));
76 QPushButton *clearButton = new QPushButton("Clear");
77 connect(clearButton, SIGNAL(clicked()), this, SLOT(clear()));
78 QHBoxLayout *actionLayout = new QHBoxLayout();
79 m_fileCount = new QLabel("File Matches: 0");
80 actionLayout->addWidget(m_searchLineEdit);
81 actionLayout->addWidget(okButton);
82 actionLayout->addWidget(clearButton);
83 actionLayout->addWidget(m_fileCount);
84 actionLayout->addStretch(1);
85 actionLayout->setMargin(0);
86 QWidget *toolBarWidget = new QWidget;
87 toolBarWidget->setLayout(actionLayout);
88 m_searchToolbar->addWidget(toolBarWidget);
89 QVBoxLayout *fileListWidgetLayout = new QVBoxLayout();
90 fileListWidgetLayout->addWidget(m_searchToolbar);
91 fileListWidgetLayout->addWidget(treeWidget);
92 setLayout(fileListWidgetLayout);
93 }
94
102
111
120 if (pvl.name() == "ImageFileList") {
121 m_serialized.reset(new PvlObject(pvl));
122 ImageTreeWidgetItem::TreeColumn col =
123 ImageTreeWidgetItem::FootprintColumn;
124 while (col < ImageTreeWidgetItem::BlankColumn) {
125 IString key = ImageTreeWidgetItem::treeColumnToString(col) + "Visible";
126 key = key.Convert(" ", '_');
127
128 if (pvl.hasKeyword(key.ToQt())) {
129 bool visible = toBool(pvl[key.ToQt()][0]);
130
131 if (visible) {
132 m_tree->showColumn(col);
133 }
134 else {
135 m_tree->hideColumn(col);
136 }
137 }
138
139 col = (ImageTreeWidgetItem::TreeColumn)(col + 1);
140 }
141
142 m_tree->updateViewActs();
143 m_tree->sortItems(pvl["SortColumn"], Qt::AscendingOrder);
144
145 QList<QTreeWidgetItem *> allCubes;
146
147 // Take all of the cubes out of the tree
148 while (m_tree->topLevelItemCount() > 0) {
149 QTreeWidgetItem *group = m_tree->takeTopLevelItem(0);
150 allCubes.append(group->takeChildren());
151
152 delete group;
153 group = NULL;
154 }
155
156 // Now re-build the tree items
157 for (int cubeGrp = 0; cubeGrp < pvl.objects(); cubeGrp ++) {
158 PvlObject &cubes = pvl.object(cubeGrp);
159
160 QTreeWidgetItem *newCubeGrp = m_tree->addGroup("", cubes.name());
161
162 if (cubes.hasKeyword("Expanded")) {
163 bool expanded = (cubes["Expanded"][0] != "No");
164 newCubeGrp->setExpanded(expanded);
165 }
166 }
167
168 if (allCubes.size()) {
169 m_tree->addGroup("", "Unknown")->addChildren(allCubes);
170 }
171 }
172 else {
173 throw IException(IException::Io, "Unable to read image file's "
174 "list widget settings from Pvl", _FILEINFO_);
175 }
176 }
177
184 PvlObject output("ImageFileList");
185
186 ImageTreeWidgetItem::TreeColumn col =
187 ImageTreeWidgetItem::FootprintColumn;
188 while (col < ImageTreeWidgetItem::BlankColumn) {
189 IString key = ImageTreeWidgetItem::treeColumnToString(col) + "Visible";
190 key = key.Convert(" ", '_');
191 bool visible = !m_tree->isColumnHidden(col);
192
193 output += PvlKeyword(key.ToQt(), toString((int)visible));
194 col = (ImageTreeWidgetItem::TreeColumn)(col + 1);
195 }
196
197 output += PvlKeyword("SortColumn", toString(m_tree->sortColumn()));
198
199 // Now store groups and the cubes that are in those groups
200 for (int i = 0; i < m_tree->topLevelItemCount(); i++) {
201 QTreeWidgetItem *group = m_tree->topLevelItem(i);
202 PvlObject cubeGroup(
203 group->text(ImageTreeWidgetItem::NameColumn));
204 cubeGroup += PvlKeyword("Expanded", group->isExpanded() ? "Yes" : "No");
205
206 for (int j = 0; j < group->childCount(); j++) {
207 QTreeWidgetItem *item = group->child(j);
208
209 if (item->type() == QTreeWidgetItem::UserType) {
210 ImageTreeWidgetItem *cubeItem = (ImageTreeWidgetItem *)item;
211
212 cubeGroup += PvlKeyword("Image", cubeItem->image()->id());
213 }
214 }
215
216 output += cubeGroup;
217 }
218
219 return output;
220 }
221
230 QList<QAction *> ImageFileListWidget::actions() {
231 return m_tree->actions();
232 }
233
241 return m_tree->getViewActions();
242 }
243
251 QList<QAction *> exportActs;
252
253 QAction *saveList = new QAction(this);
254 saveList->setText(
255 "Save Entire Cube List (ordered by &file list/groups)...");
256 connect(saveList, SIGNAL(triggered()), this, SLOT(saveList()));
257
258 exportActs.append(saveList);
259
260 return exportActs;
261 }
262
269 QScrollArea *longHelpWidgetScrollArea = new QScrollArea;
270
271 QWidget *longHelpWidget = new QWidget;
272 longHelpWidgetScrollArea->setWidget(longHelpWidget);
273
274 QVBoxLayout *longHelpLayout = new QVBoxLayout;
275 longHelpLayout->setSizeConstraint(QLayout::SetFixedSize);
276 longHelpWidget->setLayout(longHelpLayout);
277
278 QLabel *title = new QLabel("<h2>Image File List</h2>");
279 longHelpLayout->addWidget(title);
280
281 QPixmap preview;
282 if (!fileListContainer) {
283// QWeakPointer<ImageFileListWidget> tmp = new ImageFileListWidget;
284// tmp.data()->resize(QSize(500, 200));
285// preview = tmp.data().grab();
286// delete tmp.data();
288 tmp->resize(QSize(500, 200));
289 preview = tmp->grab();
290 delete tmp;
291 }
292 else {
293 QPixmap previewPixmap = fileListContainer->grab().scaled(
294 QSize(500, 200), Qt::KeepAspectRatio, Qt::SmoothTransformation);
295
296 QLabel *previewWrapper = new QLabel;
297 previewWrapper->setPixmap(previewPixmap);
298 longHelpLayout->addWidget(previewWrapper);
299 }
300
301 QLabel *previewWrapper = new QLabel;
302 previewWrapper->setPixmap(preview);
303 longHelpLayout->addWidget(previewWrapper);
304
305 QLabel *overview = new QLabel(tr("The mosaic file list is designed to help "
306 "to organize your files within the %1 project. The file list supports changing multiple "
307 "files simultaneously using the right-click menus after selecting "
308 "several images or groups.<br>"
309 "<h3>Groups</h3>"
310 "<p>Every cube must be inside of a group. These groups can be "
311 "renamed by double clicking on them. To move a cube between groups, "
312 "click and drag it to the group you want it in. This works "
313 "for multiple cubes also. You can change all of the cubes in a "
314 "group by right clicking on the group name. You can add a group "
315 "by right clicking in the white space below the last cube or on "
316 "an existing group.</p>"
317 "<h3>Columns</h3>"
318 "Show and hide columns by using the view menu. These "
319 "columns show relevant data about the cube, including statistical "
320 "information. Some of this information will be blank if you do "
321 "not run the application, <i>camstats</i>, before opening the cube."
322 "<h3>Sorting</h3>"
323 "Sort cubes within each group in ascending or descending order "
324 "by clicking on the column "
325 "title of the column that you want to sort on. Clicking on the "
326 "title again will reverse the sorting order. You can also drag and "
327 "drop a cube between two other cubes to change where it is in the "
328 "list.").arg(QApplication::applicationName()));
329 overview->setWordWrap(true);
330
331 longHelpLayout->addWidget(overview);
332 longHelpLayout->addStretch();
333
334 return longHelpWidgetScrollArea;
335 }
336
343 m_progress->setText("Loading file list");
344 m_progress->setRange(0, images->size() - 1);
345 m_progress->setValue(0);
346 m_progress->setVisible(true);
347
348 QList<QTreeWidgetItem *> selected = m_tree->selectedItems();
349
350 ImageList alreadyViewedImages = m_tree->imagesInView();
351
352
353 // Expanded states are forgotten when removed from the tree; hence the bool.
354 QList<QTreeWidgetItem *> groups;
355
356
357 // It's very slow to add/insertChild() on tree items when they are in the tree, so let's
358 // take them out of the tree, call add/insertChild() over and over, then give the
359 // groups (tree items) back to the tree. Expanded states are lost... so save/restore them
360 QVariant expandedStates = saveExpandedStates(m_tree->invisibleRootItem());
361 while (m_tree->topLevelItemCount()) {
362 groups.append(m_tree->takeTopLevelItem(0));
363 }
364
365 QTreeWidgetItem *selectedGroup = NULL;
366
367 foreach (Image *image, *images) {
368 if (alreadyViewedImages.indexOf(image) == -1) {
370
371 if (!m_serialized.isNull()) {
372 pos = find(image);
373 }
374
375 QTreeWidgetItem *newImageItem = m_tree->prepCube(images, image);
376
377 if (!pos.isValid()) {
378 if (m_tree->groupInList(selected)) {
379 QListIterator<QTreeWidgetItem *> it(selected);
380 while (it.hasNext() && !selectedGroup) {
381 QTreeWidgetItem *item = it.next();
382 if (item->data(0, Qt::UserRole).toInt() == ImageTreeWidget::ImageGroupType) {
383 selectedGroup = item;
384 }
385 }
386 }
387
388 if (!selectedGroup) {
389 QTreeWidgetItem *imageListNameItem = NULL;
390 QString groupName;
391
392 if (images->name().isEmpty()) {
393 imageListNameItem = m_tree->invisibleRootItem();
394 groupName = QString("Group %1").arg(groups.count() + 1);
395 }
396 else {
397 for (int i = 0; !imageListNameItem && i < groups.count(); i++) {
398 QTreeWidgetItem *group = groups[i];
399 if (group->data(0, Qt::UserRole).toInt() == ImageTreeWidget::ImageListNameType &&
400 group->text(0) == images->name()) {
401 imageListNameItem = group;
402 }
403 }
404
405 if (!imageListNameItem) {
406 imageListNameItem = m_tree->createImageListNameItem(images->name());
407 groups.append(imageListNameItem);
408 }
409 }
410
411 selectedGroup = m_tree->createGroup(imageListNameItem, groupName);
412 }
413
414 selectedGroup->addChild(newImageItem);
415 }
416 else {
417 QTreeWidgetItem *groupItem = groups[pos.group()];
418 if (groupItem->childCount() < pos.index())
419 groupItem->addChild(newImageItem);
420 else
421 groupItem->insertChild(pos.index(), newImageItem);
422 }
423 }
424
425 m_progress->setValue(m_progress->value() + 1);
426 }
427
428 foreach (QTreeWidgetItem *group, groups) {
429 m_tree->addTopLevelItem(group);
430 }
431 restoreExpandedStates(expandedStates, m_tree->invisibleRootItem());
432
433 if (selectedGroup)
434 selectedGroup->setSelected(true);
435
436 m_tree->refit();
437 m_progress->setVisible(false);
438 }
439
447 foreach (Image* image, *images) {
448
449 for (int i = 0; i < m_tree->topLevelItemCount(); i++) {
450 QTreeWidgetItem *group = m_tree->topLevelItem(i);
451
452 for (int j = 0; j < group->childCount(); j++) {
453 QTreeWidgetItem *item = group->child(j);
454
455 if (item->type() == QTreeWidgetItem::UserType && !item->isHidden()) {
456 ImageTreeWidgetItem *cubeItem = (ImageTreeWidgetItem *)item;
457 if (cubeItem->image() == image){
458 item->setHidden(true);
459 }
460 }
461 }
462 }
463 }
464 m_tree->repaint();
465 }
466
467
474 void ImageFileListWidget::contextMenuEvent(QContextMenuEvent *event) {
475 QMenu menu;
476
477 QList<QAction *> actions = m_tree->getViewActions();
478
479 foreach (QAction *act, actions) {
480 if (act) {
481 menu.addAction(act);
482 }
483 else {
484 menu.addSeparator();
485 }
486 }
487
488 menu.exec(event->globalPos());
489 }
490
495 QString output =
496 QFileDialog::getSaveFileName((QWidget *)parent(),
497 "Choose output file",
498 QDir::currentPath() + "/files.lis",
499 QString("List File (*.lis);;Text File (*.txt);;All Files (*.*)"));
500 if (output.isEmpty()) return;
501
502 TextFile file(output, "overwrite");
503
504 for (int i = 0; i < m_tree->topLevelItemCount(); i++) {
505 QTreeWidgetItem *group = m_tree->topLevelItem(i);
506
507 for (int j = 0; j < group->childCount(); j++) {
508 QTreeWidgetItem *item = group->child(j);
509
510 if (item->type() == QTreeWidgetItem::UserType) {
511 ImageTreeWidgetItem *cubeItem = (ImageTreeWidgetItem *)item;
512 file.PutLine(cubeItem->image()->fileName());
513 }
514 }
515 }
516 }
517
526 QString id = image->id();
527
529 for (int objIndex = 0; !result.isValid() && objIndex < m_serialized->objects(); objIndex++) {
530 PvlObject &obj = m_serialized->object(objIndex);
531
532 int imageKeyOffset = 0;
533 for (int fileKeyIndex = 0;
534 !result.isValid() && fileKeyIndex < obj.keywords();
535 fileKeyIndex++) {
536 PvlKeyword &key = obj[fileKeyIndex];
537
538 if (key.isNamed("Image")) {
539 if (key[0] == id) {
540 result = ImageTreeWidget::ImagePosition(objIndex, imageKeyOffset);
541 }
542 else {
543 imageKeyOffset++;
544 }
545 }
546 }
547 }
548
549 return result;
550 }
551
558 void ImageFileListWidget::restoreExpandedStates(QVariant expandedStates, QTreeWidgetItem *item) {
559 QMap<QString, QVariant> states = expandedStates.toMap();
560
561 if (states.contains("Expanded")) {
562 item->setExpanded(states["Expanded"].toBool());
563 }
564 else {
565 item->setExpanded(true);
566 }
567
568 QList<QVariant> childrenStates = states["Children"].toList();
569
570 int i = 0;
571 while (i < item->childCount() && i < childrenStates.count()) {
572 restoreExpandedStates(childrenStates[i], item->child(i));
573 i++;
574 }
575
576 while (i < item->childCount()) {
577 restoreExpandedStates(QVariant(), item->child(i));
578 i++;
579 }
580 }
581
590 QMap<QString, QVariant> result;
591
592 result["Expanded"] = item->isExpanded();
593
594 if (item->childCount()) {
595 QList<QVariant> childrenStates;
596
597 for (int i = 0; i < item->childCount(); i++) {
598 childrenStates.append(saveExpandedStates(item->child(i)));
599 }
600
601 result["Children"] = childrenStates;
602 }
603
604 return result;
605 }
606
607
614 xmlReader->pushContentHandler(new XmlHandler(this));
615 }
616
617
626 void ImageFileListWidget::save(QXmlStreamWriter &stream, Project *project,
627 FileName newProjectRoot) const {
628
629 stream.writeStartElement("imageFileList");
630 stream.writeAttribute("objectName", objectName());
631
632 // Write QSettings
633// stream.writeStartElement("widgetGeometry");
634// QString geom = saveGeometry();
635// //qDebug()<<"ImageFileListWidget::save geometry = "<<geom;
636// stream.writeAttribute("value", saveGeometry());
637// stream.writeEndElement();
638
639// stream.writeStartElement("geometry");
640// //qDebug()<<"ImageFileListWidget::save Geometry = "<<geometry();
641// //qDebug()<<"ImageFileListWidget::save saveGeometry = "<<saveGeometry();
642// stream.writeAttribute("x", QString::number(pos().x()));
643// stream.writeAttribute("y", QString::number(pos().y()));
644// stream.writeEndElement();
645//
646// stream.writeStartElement("position");
647// //qDebug()<<"ImageFileListWidget::save Position = "<<QVariant(pos()).toString();
648// stream.writeAttribute("x", QString::number(pos().x()));
649// stream.writeAttribute("y", QString::number(pos().y()));
650// stream.writeEndElement();
651//
652// stream.writeStartElement("size");
653// //qDebug()<<"ImageFileListWidget::save Size = "<<size();
654// stream.writeAttribute("width", QString::number(size().width()));
655// stream.writeAttribute("height", QString::number(size().height()));
656// stream.writeEndElement();
657// stream.writeEndElement();
658
659
660 ImageTreeWidgetItem::TreeColumn col =
661 ImageTreeWidgetItem::FootprintColumn;
662 while (col < ImageTreeWidgetItem::BlankColumn) {
663 bool visible = !m_tree->isColumnHidden(col);
664 bool sorted = (m_tree->sortColumn() == col);
665
666 stream.writeStartElement("column");
667 stream.writeAttribute("name", ImageTreeWidgetItem::treeColumnToString(col));
668 stream.writeAttribute("visible", (visible? "true" : "false"));
669 stream.writeAttribute("sorted", (sorted? "true" : "false"));
670 stream.writeEndElement();
671
672 col = (ImageTreeWidgetItem::TreeColumn)(col + 1);
673 }
674
675 // Now store groups and the cubes that are in those groups
676 save(stream, NULL);
677
678 stream.writeEndElement();
679 }
680
681
689 void ImageFileListWidget::save(QXmlStreamWriter &stream, QTreeWidgetItem *itemToWrite) const {
690 bool done = false;
691
692 // Start the element - image or group with attributes
693 if (!itemToWrite) {
694 stream.writeStartElement("treeLayout");
695 }
696 else if (itemToWrite->type() == QTreeWidgetItem::UserType) {
697 ImageTreeWidgetItem *imageItemToWrite = (ImageTreeWidgetItem *)itemToWrite;
698
699 stream.writeStartElement("image");
700 stream.writeAttribute("id", imageItemToWrite->image()->id());
701 }
702 else {
703 bool groupIsImageList =
704 (itemToWrite->data(0, Qt::UserRole).toInt() == ImageTreeWidget::ImageListNameType);
705
706 stream.writeStartElement("group");
707 stream.writeAttribute("name", itemToWrite->text(ImageTreeWidgetItem::NameColumn));
708 stream.writeAttribute("expanded", itemToWrite->isExpanded() ? "true" : "false");
709 stream.writeAttribute("isImageList", groupIsImageList? "true" : "false");
710 }
711
712 // Write any child XML elements (groups in groups)
713 int i = 0;
714 while (!done) {
715 QTreeWidgetItem *childItemToWrite = NULL;
716
717 if (itemToWrite == NULL && i < m_tree->topLevelItemCount()) {
718 childItemToWrite = m_tree->topLevelItem(i);
719 }
720 else if (itemToWrite != NULL && i < itemToWrite->childCount()) {
721 childItemToWrite = itemToWrite->child(i);
722 }
723
724 if (childItemToWrite) {
725 save(stream, childItemToWrite);
726 }
727
728 done = (childItemToWrite == NULL);
729 i++;
730 }
731
732 // Close the initial image or group element
733 stream.writeEndElement();
734 }
735
747
753
765 bool ImageFileListWidget::XmlHandler::startElement(const QString &namespaceURI,
766 const QString &localName, const QString &qName, const QXmlAttributes &atts) {
767 bool result = XmlStackedHandler::startElement(namespaceURI, localName, qName, atts);
768
769 if (result) {
770
771// if (localName == "geometry") {
772// QByteArray
773// restoreGeometry(atts.value("value").toLatin1());
774// }
775
776 if (localName == "position") {
777 QPoint pos = QPoint(atts.value("x").toInt(), atts.value("y").toInt());
778 //qDebug()<<" ::startElement pos = "<<pos;
779 m_fileList->move(pos);
780 }
781 else if (localName == "size") {
782 QSize size = QSize(atts.value("width").toInt(), atts.value("height").toInt());
783 //qDebug()<<" ::startElement size = "<<size;
784 m_fileList->resize(size);
785 }
786 else if (localName == "column") {
787 QString colName = atts.value("name");
788 QString colVisibleStr = atts.value("visible");
789 QString colSortedStr = atts.value("sorted");
790
791
792 ImageTreeWidgetItem::TreeColumn col =
793 ImageTreeWidgetItem::NameColumn;
794 while (col < ImageTreeWidgetItem::BlankColumn) {
795 QString curColName = ImageTreeWidgetItem::treeColumnToString(col);
796
797 if (curColName == colName) {
798 if (colVisibleStr != "false") {
799 m_fileList->m_tree->showColumn(col);
800 }
801 else {
802 m_fileList->m_tree->hideColumn(col);
803 }
804
805 if (colSortedStr == "true") {
806 m_fileList->m_tree->sortItems(col, Qt::AscendingOrder);
807 }
808 }
809
810 col = (ImageTreeWidgetItem::TreeColumn)(col + 1);
811 }
812 }
813
814 else if (localName == "group") {
815 if (atts.value("isImageList") == "true") {
816 if (!m_currentImageList) {
817 QString name = atts.value("name");
818 m_currentImageListItem = m_fileList->m_tree->createImageListNameItem(name);
819 m_currentImageList = m_fileList->m_directory->project()->imageList(name);
820 m_fileList->m_tree->addTopLevelItem(m_currentImageListItem);
821 m_currentImageListItem->setExpanded(true);
822 }
823 }
824 else {
825 m_currentGroup = m_fileList->m_tree->createGroup(m_currentImageListItem,
826 atts.value("name"));
827 }
828 }
829
830 else if (localName == "image" && m_currentGroup) {
831 Image *image = m_fileList->m_directory->project()->image(atts.value("id"));
832 // If Image for id doesn't exist, check shapes. If corresponds to Shape, new Image will
833 // need to be created.
834 if (!image) {
835 Shape *shape = m_fileList->m_directory->project()->shape(atts.value("id"));
836 if (shape) {
837 image = new Image(shape->cube(), shape->footprint(), atts.value("id"));
838 }
839 }
840 m_currentGroup->addChild(m_fileList->m_tree->prepCube(m_currentImageList, image));
841 }
842
843 }
844
845 return result;
846 }
847
858 bool ImageFileListWidget::XmlHandler::endElement(const QString &namespaceURI,
859 const QString &localName, const QString &qName) {
860 bool result = XmlStackedHandler::endElement(namespaceURI, localName, qName);
861
862 if (result) {
863 if (localName == "group") {
864 if (m_currentGroup) {
865 m_currentGroup = NULL;
866 }
867 else {
868 m_currentImageList = NULL;
869 m_currentImageListItem = NULL;
870 }
871 }
872 }
873
874 return result;
875 }
876
877
878 void ImageFileListWidget::filterFileList() {
879 QString filterString = m_searchLineEdit->text();
880 int numMatches = 0;
881
882 for (int i = 0; i < m_tree->topLevelItemCount(); i++) {
883 QTreeWidgetItem *group = m_tree->topLevelItem(i);
884
885 for (int j = 0; j < group->childCount(); j++) {
886 QTreeWidgetItem *item = group->child(j);
887 group->setSelected(false);
888 if (item->type() == QTreeWidgetItem::UserType) {
889
890 ImageTreeWidgetItem *cubeItem = (ImageTreeWidgetItem *)item;
891 if (cubeItem->image()->fileName().contains(filterString)){
892 cubeItem->setSelected(true);
893 m_tree->scrollToItem(cubeItem);
894 numMatches++;
895 }
896 else {
897 cubeItem->setSelected(false);
898 }
899 }
900 }
901 }
902 m_fileCount->setText("File Matches: " + QString::number(numMatches));
903 }
904
905
906 void ImageFileListWidget::clear() {
907 m_searchLineEdit->setText("");
908 m_fileCount->setText("File Matches: 0");
909
910 for (int i = 0; i < m_tree->topLevelItemCount(); i++) {
911 QTreeWidgetItem *group = m_tree->topLevelItem(i);
912
913 for (int j = 0; j < group->childCount(); j++) {
914 QTreeWidgetItem *item = group->child(j);
915 group->setSelected(false);
916 if (item->type() == QTreeWidgetItem::UserType) {
917 item->setSelected(false);
918 }
919 }
920 }
921 }
922}
File name manipulation and expansion.
Definition FileName.h:100
Isis exception class.
Definition IException.h:91
@ Io
A type of error that occurred when performing an actual I/O operation.
Definition IException.h:155
Adds specific functionality to C++ strings.
Definition IString.h:165
IString Convert(const std::string &listofchars, const char &to)
Returns the string with all occurrences of any character in the "from" argument converted to the "to"...
Definition IString.cpp:1196
QString ToQt() const
Retuns the object string as a QString.
Definition IString.cpp:869
ImageFileListWidget * m_fileList
The widget we are working with.
XmlHandler(ImageFileListWidget *fileList)
Creates a XmlHandler for fileList.
QTreeWidgetItem * m_currentGroup
The group of cubes being worked on.
QTreeWidgetItem * m_currentImageListItem
The image being worked on.
virtual bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName)
This method calls XmlStackedHandler's endElement() and dereferences pointers according to the value o...
virtual bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts)
This method calls XmlStackedHandler's startElement() and retrieves attributes from atts according to ...
ImageList * m_currentImageList
The list of images being worked on.
A colored, grouped cube list.
QToolBar * m_searchToolbar
Tool bar for the FileList widget to search.
void restoreExpandedStates(QVariant expandedStates, QTreeWidgetItem *item)
This method returns the QTreeWidgetItem to it's expanded state.
virtual ~ImageFileListWidget()
Destructor.
void addImages(ImageList *images)
This method adds the new images to the tree.
QList< QAction * > actions()
This method calls ImageTreeWidget::actions() which sets up a QAction that sets a default for the file...
ImageTreeWidget::ImagePosition find(const Image *image) const
This method takes an image and finds it's position.
QPointer< ProgressBar > m_progress
The ProgressBar of the ImageFileListWidget Serialized (file) version of this object.
void saveList()
This method saves the list to the choosen output file.
QVariant saveExpandedStates(QTreeWidgetItem *item)
This method saves the the expanded state of item.
void removeImages(ImageList *images)
Removes an imagelist from the FileListWidget.
void contextMenuEvent(QContextMenuEvent *event)
This method takes an event and gets all of the FootprintColumns, adds them to the menu,...
PvlObject toPvl() const
This method writes the state of this class to a pvl.
static QWidget * getLongHelp(QWidget *fileListContainer=NULL)
This method creates a QWidget that displays a long help message explaining the tool.
QList< QAction * > getViewActions()
This method calls ImageTreeWidget::getViewActions() which returns a list of FootprintColumns.
ImageTreeWidget * m_tree
Tree item associated with this mosaic item.
ImageFileListWidget(Directory *directory=0, QWidget *parent=0)
Constructor.
Directory * m_directory
The directory of the project.
void load(XmlStackedHandlerReader *xmlReader)
This method pushes a new XmlHandler into the parser stack.
QProgressBar * getProgress()
This method returns the progress bar.
void fromPvl(PvlObject &pvl)
This method loads the state of this class from the pvl.
void save(QXmlStreamWriter &stream, Project *project, FileName newProjectRoot) const
This method saves the FootprintColumns in the project and the settings associated with every column.
QList< QAction * > getExportActions()
This method creates a new QAction which is connected and when triggered will save the cube list.
This represents a cube in a project-based GUI interface.
Definition Image.h:107
QString id() const
Get a unique, identifying string associated with this image.
Definition Image.cpp:445
Internalizes a list of images and allows for operations on the entire list.
Definition ImageList.h:55
QString name() const
Get the human-readable name of this image list.
The main project for ipce.
Definition Project.h:289
A single keyword-value pair.
Definition PvlKeyword.h:87
bool isNamed(QString name) const
Determines whether two PvlKeywords have the same name or not.
Definition PvlKeyword.h:115
Contains Pvl Groups and Pvl Objects.
Definition PvlObject.h:61
PvlObject & object(const int index)
Return the object at the specified index.
This represents a shape in a project-based GUI interface.
Definition Shape.h:68
Cube * cube()
Get the Cube * associated with this display property.
Definition Shape.cpp:324
geos::geom::MultiPolygon * footprint()
Get the footprint of this shape (if available).
Definition Shape.cpp:394
Provides access to sequential ASCII stream I/O.
Definition TextFile.h:38
Manage a stack of content handlers for reading XML files.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
bool toBool(const QString &string)
Global function to convert from a string to a boolean.
Definition IString.cpp:38