9#include "CnetEditorWidget.h"
12#include <QApplication>
20#include <QItemSelection>
37#include "AbstractMeasureItem.h"
38#include "AbstractPointItem.h"
39#include "AbstractTreeItem.h"
40#include "CnetDisplayProperties.h"
41#include "CnetEditorSortConfigDialog.h"
43#include "ControlMeasure.h"
44#include "ControlNet.h"
45#include "ControlPoint.h"
47#include "FilterWidget.h"
48#include "IException.h"
49#include "ImageImageTreeModel.h"
50#include "ImagePointTreeModel.h"
51#include "MeasureTableModel.h"
52#include "PointMeasureTreeModel.h"
53#include "PointTableModel.h"
56#include "TableViewHeader.h"
58#include "XmlStackedHandler.h"
59#include "XmlStackedHandlerReader.h"
75 CnetEditorWidget::CnetEditorWidget(Control *control, QString pathForSettings) {
87 connect(CnetDisplayProperties::getInstance(), SIGNAL(compositionFinished()),
94 setLayout(mainLayout);
102 installEventFilter(
this);
219 bool ignoreAll =
false;
222 item->deleteSource();
225 QString message = e.what();
228 if (item == itemsToDelete.last()) {
229 QMessageBox::warning(
230 this,
"Failed to delete row", message, QMessageBox::Ok);
233 message +=
"\n\nOkay to continue?";
235 QMessageBox::StandardButton status = QMessageBox::warning(
236 this,
"Failed to delete row", message, QMessageBox::Yes |
237 QMessageBox::YesToAll | QMessageBox::No);
239 if (status == QMessageBox::YesToAll)
241 else if (status == QMessageBox::No)
281 QHBoxLayout *pointTableLayout =
new QHBoxLayout;
287 QHBoxLayout *measureTableLayout =
new QHBoxLayout;
295 QBoxLayout *mainLayout =
new QHBoxLayout;
308 FileName(
"$ISISROOT/appdata/images/icons/ice.png").expanded()),
309 tr(
"&Freeze Tables"),
this);
310 freezeTablesAct->setCheckable(
true);
311 freezeTablesAct->setToolTip(tr(
"Freeze tables (filters will not take "
312 "effect until unfrozen)"));
313 freezeTablesAct->setStatusTip(tr(
"Freeze tables (filters will not take "
314 "effect until unfrozen)"));
315 freezeTablesAct->setWhatsThis(tr(
"<html>When frozen, the contents of the "
316 "tables will be locked. Current filters will not be applied to the "
317 "tables until they are unfrozen.</html>"));
318 connect(freezeTablesAct, SIGNAL(toggled(
bool)),
321 freezeTablesLocation.append(tr(
"&Tables"));
322 m_menuActions->insert(freezeTablesAct, freezeTablesLocation);
325 FileName(
"$ISISROOT/appdata/images/icons/sort.png").expanded()),
326 tr(
"&Sorting Options..."),
this);
327 QString configureSortToolTipText = tr(
"Configure table sorting options");
328 configureSortAct->setToolTip(configureSortToolTipText);
329 configureSortAct->setStatusTip(configureSortToolTipText);
330 configureSortAct->setWhatsThis(tr(
"<html>Click here to configure options "
331 "related to the sorting of table columns.</html>"));
332 connect(configureSortAct, SIGNAL(triggered()),
335 configureSortLocation.append(tr(
"&Tables"));
336 m_menuActions->insert(configureSortAct, configureSortLocation);
338 QAction *whatsThisAct = QWhatsThis::createAction(
this);
340 whatsThisLocation.append(tr(
"&Help"));
344 tbActionList.append(freezeTablesAct);
345 tbActionList.append(configureSortAct);
393 QHBoxLayout *pointFilterLayout =
new QHBoxLayout;
394 pointFilterLayout->addWidget(pointFilter);
396 pointArea->setLayout(pointFilterLayout);
397 QScrollArea *pointFilterScrollArea =
new QScrollArea;
398 pointFilterScrollArea->setWidget(pointArea);
399 pointFilterScrollArea->setWidgetResizable(
true);
407 QHBoxLayout *serialFilterLayout =
new QHBoxLayout;
408 serialFilterLayout->addWidget(serialFilter);
410 serialArea->setLayout(serialFilterLayout);
411 QScrollArea *serialFilterScrollArea =
new QScrollArea;
412 serialFilterScrollArea->setWidget(serialArea);
413 serialFilterScrollArea->setWidgetResizable(
true);
421 QHBoxLayout *connectionFilterLayout =
new QHBoxLayout;
422 connectionFilterLayout->addWidget(connectionFilter);
424 connectionArea->setLayout(connectionFilterLayout);
425 QScrollArea *connectionFilterScrollArea =
new QScrollArea;
426 connectionFilterScrollArea->setWidget(connectionArea);
427 connectionFilterScrollArea->setWidgetResizable(
true);
440 "point. Each column in the table is an attribute of a control "
441 "point.<br/><br/>Cells that are gray are not editable.</html>");
443 this, SIGNAL(cnetModified()));
459 this, SIGNAL(editControlPoint(
ControlPoint *, QString)));
461 for (
int i = 0; i < AbstractPointItem::COLS; i++) {
463 AbstractPointItem::getColumnName((AbstractPointItem::Column) i),
this);
464 act->setCheckable(
true);
470 Qt::ActionsContextMenu);
480 "m_measureTableView");
482 "measure. Each column in the table is an attribute of a control "
483 "measure.<br/><br/>Rows with bold text are reference measures. "
484 "Cells that are gray are not editable.</html>");
486 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
488 SLOT(handleTreeSelectionChanged(QList<AbstractTreeItem *>)));
491 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
493 SLOT(handleTreeSelectionChanged(QList< AbstractTreeItem * >)));
497 this, SIGNAL(cnetModified()));
511 this, SIGNAL(editControlPoint(
ControlPoint *, QString)));
513 for (
int i = 0; i < AbstractMeasureItem::COLS; i++) {
515 (AbstractMeasureItem::Column) i),
this);
516 act->setCheckable(
true);
522 Qt::ActionsContextMenu);
541 for (
int i = 0; i < actions.size(); i++) {
543 actions[i]->isChecked());
554 for (
int i = 0; i < actions.size(); i++)
556 actions[i]->isChecked());
570 int visibleRows,
int totalRows) {
572 "Control Point Table");
586 int visibleRows,
int totalRows) {
588 "Control Measure Table");
601 int visibleRows,
int totalRows, QGroupBox *box, QString initialText) {
603 QString newTitle = initialText +
" (";
604 if (visibleRows > -1)
605 newTitle += QString::number(visibleRows);
609 newTitle +=
" / " + QString::number(totalRows) +
")";
611 box->setTitle(newTitle);
637 m_mainSplitter->restoreState(settings.value(
"mainSplitter").toByteArray());
643 for (
int i = 0; i < actions.size(); i++) {
645 AbstractMeasureItem::getColumnName((AbstractMeasureItem::Column) i);
646 key.replace(
" ",
"_");
647 actions[i]->setChecked(settings.value(key,
true).toBool());
651 for (
int i = 0; i < actions.size(); i++) {
653 AbstractPointItem::getColumnName((AbstractPointItem::Column) i);
654 key.replace(
" ",
"_");
655 actions[i]->setChecked(settings.value(key,
true).toBool());
660 settings.value(
"measureTableSortingEnabled",
true).toBool());
662 settings.value(
"measureTableSortLimit", 500000).toInt());
664 settings.value(
"pointTableSortingEnabled",
true).toBool());
666 settings.value(
"pointTableSortLimit", 100000).toInt());
676 settings.setValue(
"version",
VERSION);
683 for (
int i = 0; i < actions.size(); i++) {
685 AbstractMeasureItem::getColumnName((AbstractMeasureItem::Column) i);
686 key.replace(
" ",
"_");
687 settings.setValue(key, actions[i]->isChecked());
691 for (
int i = 0; i < actions.size(); i++) {
693 AbstractPointItem::getColumnName((AbstractPointItem::Column) i);
694 key.replace(
" ",
"_");
695 settings.setValue(key, actions[i]->isChecked());
699 settings.setValue(
"measureTableSortingEnabled",
701 settings.setValue(
"measureTableSortLimit",
703 settings.setValue(
"pointTableSortingEnabled",
705 settings.setValue(
"pointTableSortLimit",
848 QList<AbstractTreeItem *> networkItems =
m_pointModel->getItems(0, -1,
849 AbstractTreeModel::MeasureItems | AbstractTreeModel::PointItems,
true);
853 for (
int pointIndex = filteredCnet->GetNumPoints() - 1;
856 if (networkItems.isEmpty()) {
860 for (
int measureIndex = 0;
861 measureIndex < cp->GetNumMeasures();
863 cp->GetMeasure(measureIndex)->SetEditLock(
false);
866 filteredCnet->DeletePoint(cp);
868 else if (networkItems.last()->getPointerType() ==
869 AbstractTreeItem::Point) {
873 if (cp->GetId() != networkItemsCp->GetId()) {
876 for (
int measureIndex = 0;
877 measureIndex < cp->GetNumMeasures();
879 cp->GetMeasure(measureIndex)->SetEditLock(
false);
882 filteredCnet->DeletePoint(cp);
885 networkItems.removeLast();
888 else if (networkItems.last()->getPointerType() ==
889 AbstractTreeItem::Measure) {
894 if (cp->GetId() != networkItemsCm->Parent()->GetId()) {
895 cp->SetEditLock(
false);
897 for (
int measureIndex = 0;
898 measureIndex < cp->GetNumMeasures();
900 cp->GetMeasure(measureIndex)->SetEditLock(
false);
903 filteredCnet->DeletePoint(cp);
907 for (
int measureIndex = cp->GetNumMeasures() - 1;
908 networkItemsCm && measureIndex >= 0;
911 if (cm->GetCubeSerialNumber() !=
912 networkItemsCm->GetCubeSerialNumber()) {
913 cm->SetEditLock(
false);
917 networkItems.removeLast();
918 networkItemsCm = NULL;
920 if (networkItems.last()->getPointerType() ==
921 AbstractTreeItem::Measure) {
Translates the tree model into a table model.
Base class for an item in the tree.
Configure user's sorting settings for the cneteditor widget.
ControlNet * controlNet()
Open and return a pointer to the ControlNet for this Control.
void setModified(bool modified=true)
@description Sets the modification state of this control.
Status SetEditLock(bool editLock)
Set the EditLock state.
File name manipulation and expansion.
Tree model for images and images.
Tree model for images and control points.
Table model for control measures.
Tree model for control points and control measures.
Table model for control points.
TableViewHeader * getHorizontalHeader()
Returns the horizontal header.
void setColumnVisible(QString, bool)
Sets the specified column visible or invisible.
This is free and unencumbered software released into the public domain.