Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
TableViewContent.cpp
1
6
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "TableViewContent.h"
10
11#include <cmath>
12#include <iostream>
13
14#include <QAction>
15#include <QApplication>
16#include <QDebug>
17#include <QLabel>
18#include <QMenu>
19#include <QMessageBox>
20#include <QMutex>
21#include <QPainter>
22#include <QPaintEvent>
23#include <QRect>
24#include <QScrollBar>
25#include <QSize>
26#include <QStyle>
27#include <QThread>
28#include <QVBoxLayout>
29
30#include "ControlMeasure.h"
31#include "IException.h"
32#include "IString.h"
33
34#include "AbstractTableDelegate.h"
35#include "AbstractTableModel.h"
36#include "AbstractTreeItem.h"
37#include "TableColumn.h"
38#include "TableColumnList.h"
39#include <ControlPoint.h>
40
41
42namespace Isis {
49 nullify();
50
51 m_model = someModel;
52 connect(m_model, SIGNAL(modelModified()), this, SLOT(refresh()));
53 connect(m_model, SIGNAL(filterProgressChanged(int)),
54 this, SLOT(updateItemList()));
55 connect(this, SIGNAL(modelDataChanged()),
56 m_model, SLOT(applyFilter()));
57 connect(this,
58 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
59 m_model,
60 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)));
61 connect(m_model, SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
63
64 m_columns = getModel()->getColumns();
65 for (int i = 0; i < m_columns->size(); i++) {
66 TableColumn *column = (*m_columns)[i];
67
68 connect(column, SIGNAL(visibilityChanged()), this, SLOT(refresh()));
69 connect(column, SIGNAL(visibilityChanged()),
70 this, SLOT(updateHorizontalScrollBar()));
71 connect(column, SIGNAL(widthChanged()), this, SLOT(refresh()));
72 }
73
75 m_activeCell = new QPair<AbstractTreeItem *, int>(NULL, -1);
77 m_lastShiftSelection = new QList<AbstractTreeItem *>;
78 m_lastShiftArrowSelectedCell = new QPair< AbstractTreeItem *, int >;
79 m_lastShiftArrowSelectedCell->first = NULL;
80
81 verticalScrollBar()->setSingleStep(1);
82
83 m_rowHeight = QFontMetrics(font()).height() + ITEM_PADDING;
84
85 connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
86 this, SIGNAL(horizontalScrollBarValueChanged(int)));
87
88 setMouseTracking(true);
90
92
93 setContextMenuPolicy(Qt::CustomContextMenu);
94 connect(this, SIGNAL(customContextMenuRequested(QPoint)),
95 this, SLOT(showContextMenu(QPoint)));
96
97 m_activeControlNet = false;
98 }
99
100
105 delete m_items;
106 m_items = NULL;
107
108 delete m_activeCell;
109 m_activeCell = NULL;
110
111 delete m_editWidget;
112 m_editWidget = NULL;
113
114 delete m_lastShiftSelection;
115 m_lastShiftSelection = NULL;
116
119
120 delete m_applyToAllAct;
121 m_applyToAllAct = NULL;
122
125
128
129 delete m_lastShiftArrowSelectedCell;
130 m_lastShiftArrowSelectedCell = NULL;
131
132 m_columns = NULL;
133 }
134
135
142 return QWidget::minimumSizeHint();
143 }
144
145
154 return minimumSizeHint();
155 }
156
157
164 return m_model;
165 }
166
167
168 // void TableViewContent::setModel(AbstractTableModel * someModel)
169 // {
170 // if (!someModel)
171 // {
172 // IString msg = "Attempted to set a NULL m_model!";
173 // throw iException::Message(iException::Programmer, msg, _FILEINFO_);
174 // }
175 //
176 // if (getModel())
177 // {
178 // disconnect(getModel(), SIGNAL(m_modelModified()), this, SLOT(refresh()));
179 // disconnect(getModel(), SIGNAL(filterProgressChanged(int)),
180 // this, SLOT(updateItemList()));
181 // disconnect(this,
182 // SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
183 // getModel(),
184 // SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)));
185 // disconnect(getModel(), SIGNAL(selectionChanged(QList<AbstractTreeItem*>)),
186 // this, SLOT(scrollTo(QList<AbstractTreeItem*>)));
187 // }
188 //
189 // m_model = someModel;
190 // m_columns = someModel->getColumns();
191 //
192 // connect(m_model, SIGNAL(m_modelModified()), this, SLOT(refresh()));
193 // connect(m_model, SIGNAL(filterProgressChanged(int)),
194 // this, SLOT(updateItemList()));
195 // connect(this, SIGNAL(m_modelDataChanged()),
196 // m_model, SLOT(applyFilter()));
197 // connect(this, SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
198 // m_model, SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)));
199 // connect(m_model, SIGNAL(treeSelectionChanged(QList<AbstractTreeItem*>)),
200 // this, SLOT(scrollTo(QList<AbstractTreeItem*>)));
201 //
202 // refresh();
203 // }
204
205
212 m_activeControlNet = activeNet;
213 }
214
215
220 if (m_model) {
221 if (!m_model->isFiltering()) {
222 int rowCount = m_model->getVisibleRowCount();
223 verticalScrollBar()->setRange(0, qMax(rowCount - 1, 0));
224 }
225
228 m_lastShiftSelection->clear();
229
230 if (m_model->getSelectedItems().size() &&
234 }
235
236 viewport()->update();
237 }
238 }
239
240
247 if (m_columns) {
248 int range = 0;
249 TableColumnList visibleCols = m_columns->getVisibleColumns();
250 for (int i = 0; i < visibleCols.size(); i++)
251 range += visibleCols[i]->getWidth() - 1;
252
253 // For the border...
254 range -= 2;
255 horizontalScrollBar()->setRange(0, range - viewport()->width());
256 horizontalScrollBar()->setPageStep(viewport()->width());
257
258 if (scrollRight)
259 horizontalScrollBar()->setValue(horizontalScrollBar()->maximum());
260 }
261 }
262
263
270 QList< AbstractTreeItem * > newlySelectedItems) {
271 if (newlySelectedItems.size())
272 scrollTo(newlySelectedItems.last());
273 }
274
275
282 int row = getModel()->indexOfVisibleItem(newlySelectedItem);
283
284 if (row >= 0) {
285 int topRow = verticalScrollBar()->value();
286
287 if (row < topRow) {
288 verticalScrollBar()->setValue(row);
289 }
290 else {
291 int wholeVisibleRowCount = viewport()->height() / m_rowHeight;
292 int bottomRow = topRow + wholeVisibleRowCount;
293 if (row > bottomRow)
294 verticalScrollBar()->setValue(row - wholeVisibleRowCount + 1);
295 }
296 }
297
298 viewport()->update();
299 }
300
301
310 bool TableViewContent::eventFilter(QObject *target, QEvent *event) {
311 return QObject::eventFilter(target, event);
312 }
313
314
321 if (event->buttons() & Qt::LeftButton) {
322 int rowNum = event->pos().y() / m_rowHeight;
323
324 if (m_activeCell->first && cellIsEditable(rowNum, m_activeCell->second)) {
325 const AbstractTableDelegate *delegate = m_model->getDelegate();
326 TableColumn *col =
327 m_columns->getVisibleColumns()[m_activeCell->second];
328
329 delete m_editWidget;
330 m_editWidget = NULL;
331 m_editWidget = delegate->getWidget(col);
332 delegate->readData(m_editWidget, m_activeCell->first, col);
333 m_editWidget->setParent(this);
334 m_editWidget->setFocus(Qt::OtherFocusReason);
335 }
336
337 viewport()->update();
338 }
339 }
340
341
347 void TableViewContent::mousePressEvent(QMouseEvent *event) {
348
349 if (event->buttons() & Qt::LeftButton) {
350 // FIXME refactor this file (lol)
351 if (!(event->modifiers() & Qt::ShiftModifier))
352 updateActiveCell(event->pos());
353
354 int rowNum = event->pos().y() / m_rowHeight;
355 int colNum = getColumnFromScreenX(event->pos().x());
356
357 // HACK
358 // BUG
359 // TODO
360 // FIXME
361 if (colNum == 0)
363
364 if (rowNum >= 0 && rowNum < m_items->size() && m_activeCell->first) {
365 // The user clicked on a valid item, handle selection of individual
366 // cells (not rows).
367
368 // Deselect all rows, as this will now be a cell selection.
369 m_model->setGlobalSelection(false);
370
371 if (cellIsEditable(rowNum, m_activeCell->second)) {
372 if (event->modifiers() & Qt::ControlModifier) {
373 if (rowsWithActiveColumnSelected->indexOf(m_activeCell->first) < 0)
374 rowsWithActiveColumnSelected->append(m_activeCell->first);
375 else
376 rowsWithActiveColumnSelected->removeAll(m_activeCell->first);
377 m_lastDirectlySelectedRow = m_activeCell->first;
378
379 m_lastShiftSelection->clear();
380 }
381 else {
382 if (event->modifiers() & Qt::ShiftModifier) {
383 updateColumnGroupSelection((*m_items)[rowNum]);
384 }
385 else {
386 // Normal click, no modifiers.
388 rowsWithActiveColumnSelected->append(m_activeCell->first);
389 m_lastDirectlySelectedRow = m_activeCell->first;
390 m_lastShiftSelection->clear();
391 }
392 }
393 }
394 }
395 else {
396 // row selections
397 if (rowNum >= 0 && rowNum < m_items->size()) {
398 int columnNum = getColumnFromScreenX(event->pos().x());
399
400 if (columnNum != -1) {
401 TableColumn *column = m_columns->getVisibleColumns()[columnNum];
402 if (column->getTitle().isEmpty()) {
404
405 AbstractTreeItem *const &item = m_items->at(rowNum);
406 QList< AbstractTreeItem * > newlySelectedItems;
407
408 if (event->modifiers() & Qt::ControlModifier) {
409 if (item->getPointerType() == AbstractTreeItem::Measure)
410 item->parent()->setSelected(!item->isSelected());
411
412 item->setSelected(!item->isSelected());
414 newlySelectedItems.append(item);
415 }
416 else {
417 if (event->modifiers() & Qt::ShiftModifier) {
418 newlySelectedItems = updateRowGroupSelection(rowNum);
419 }
420 else {
421 QList<AbstractTreeItem *> selectedItems =
422 m_model->getSelectedItems();
423
424 foreach (AbstractTreeItem * selectedItem, selectedItems) {
425 if (selectedItem->getPointerType() ==
426 AbstractTreeItem::Measure)
427 selectedItem->parent()->setSelected(false);
428 }
429
430 m_model->setGlobalSelection(false);
431
432 if (item->getPointerType() == AbstractTreeItem::Measure)
433 item->parent()->setSelected(true);
434
435 item->setSelected(true);
437 newlySelectedItems.append(item);
438 }
439 }
440
441 QList< AbstractTreeItem * > tmp = newlySelectedItems;
442 newlySelectedItems.clear();
443 foreach (AbstractTreeItem * i, tmp) {
444 newlySelectedItems.append(i);
445 if (i->getPointerType() == AbstractTreeItem::Point) {
446 foreach (AbstractTreeItem * child, i->getChildren()) {
447 child->setSelected(true);
448 newlySelectedItems.append(child);
449 }
450 }
451 }
452
453 emit tableSelectionChanged(newlySelectedItems);
454 }
455 }
456 }
457 }
458
459 delete m_editWidget;
460 m_editWidget = NULL;
461
462 viewport()->update();
463 emit tableSelectionChanged();
464 }
465 }
466
467
473 void TableViewContent::mouseReleaseEvent(QMouseEvent *event) {
474 }
475
476
482 void TableViewContent::mouseMoveEvent(QMouseEvent *event) {
483 if (!m_editWidget) {
484 if (event->buttons() & Qt::LeftButton) {
485 int rowNum = event->pos().y() / m_rowHeight;
486
487 // used to make sure that the mouse position is inside the content
488 int yPos = event->pos().y();
489 if (yPos >= 0 && rowNum < m_items->size() && m_activeCell->first) {
490 // The user clicked on a valid item,
491 // handle selection of individual cells (not rows).
492 if (cellIsEditable(rowNum, m_activeCell->second)) {
493 updateColumnGroupSelection((*m_items)[rowNum]);
494 }
495 }
496 else {
497 // row selections
498 if (yPos >= 0 && rowNum < m_items->size()) {
499 // There is no active cell,
500 // maybe they clicked on the row number column.
501 int columnNum = getColumnFromScreenX(event->pos().x());
502
503 if (columnNum != -1) {
505
508 QList< AbstractTreeItem * > newlySelectedItems;
509 foreach (AbstractTreeItem * i, tmp) {
510 newlySelectedItems.append(i);
511 if (i->getPointerType() == AbstractTreeItem::Point) {
512 foreach (AbstractTreeItem * child, i->getChildren()) {
513 child->setSelected(true);
514 newlySelectedItems.append(child);
515 }
516 }
517 }
518
519 emit tableSelectionChanged(newlySelectedItems);
520 }
521 }
522 }
523
524 QScrollBar *vertScroll = verticalScrollBar();
525
526 if (yPos > viewport()->height() &&
527 vertScroll->value() < vertScroll->maximum()) {
528 // Scroll down to allow for more drag selections.
529 vertScroll->setValue(vertScroll->value() + 1);
530 }
531 else {
532 if (yPos < 0 && vertScroll->value() > vertScroll->minimum())
533 vertScroll->setValue(vertScroll->value() - 1);
534 }
535
536 viewport()->update();
537 emit tableSelectionChanged();
538 }
539 }
540 }
541
542
548 void TableViewContent::leaveEvent(QEvent *event) {
549 // viewport()->update();
550 }
551
552
558 void TableViewContent::keyPressEvent(QKeyEvent *event) {
559 Qt::Key key = (Qt::Key) event->key();
560
561 // Handle Ctrl-A (selects all rows)
562 if (key == Qt::Key_A && event->modifiers() == Qt::ControlModifier) {
565 m_model->setGlobalSelection(true);
566 viewport()->update();
567
568 emit tableSelectionChanged();
569 }
570
571 // Handle esc key (cancel editing)
572 else if (key == Qt::Key_Escape) {
573 if (m_editWidget) {
574 delete m_editWidget;
575 m_editWidget = NULL;
576 setFocus(Qt::ActiveWindowFocusReason);
577 viewport()->update();
578 }
579 }
580
581 // Handle delete key (delete row(s) if any are selected)
582 else if (key == Qt::Key_Delete) {
583 if (hasRowSelection())
585 }
586
587 // Handle return or enter (stop editing)
588 else if (key == Qt::Key_Return || key == Qt::Key_Enter) {
591 }
592
593 // Handle
594 else if (key == Qt::Key_Tab) {
597 }
598
599 // Handle arrow key navigation
600 else if (key == Qt::Key_Up || key == Qt::Key_Down ||
601 key == Qt::Key_Left || key == Qt::Key_Right) {
602 if (!hasActiveCell()) {
603 if (m_items && m_items->size()) {
604 m_activeCell->first = (*m_items)[0];
605 m_activeCell->second = 1;
606 }
607 }
608
609 if (hasActiveCell() && !m_editWidget) {
610
611 // Handle up arrow with shift pressed
612 if (key == Qt::Key_Up && event->modifiers() == Qt::ShiftModifier) {
613
614 AbstractTreeItem *prevCell = m_lastShiftArrowSelectedCell->first ?
615 m_lastShiftArrowSelectedCell->first : m_activeCell->first;
616
617 int prevCellIndex = getModel()->indexOfVisibleItem(prevCell);
618
619 if (prevCellIndex > 0) {
621 getModel()->getItems(prevCellIndex - 1, prevCellIndex);
622
623 if (itemList.size()) {
624 AbstractTreeItem *curItem = itemList[0];
625
626 if (rowsWithActiveColumnSelected->contains(curItem) ||
627 curItem == m_activeCell->first)
628 rowsWithActiveColumnSelected->removeAll(prevCell);
629 else
630 rowsWithActiveColumnSelected->append(curItem);
631
632 if (curItem == m_activeCell->first)
633 m_lastShiftArrowSelectedCell->first = NULL;
634 else
635 m_lastShiftArrowSelectedCell->first = curItem;
636 m_lastShiftArrowSelectedCell->second = m_activeCell->second;
637
638 // scroll if needed
639 int m_itemsPrevIndex = m_items->indexOf(prevCell);
640 int m_itemsCurIndex = m_items->indexOf(curItem);
641 if (m_itemsCurIndex == -1) {
642 if (m_itemsPrevIndex == 0) { // then need to scroll up!
643 verticalScrollBar()->setValue(qMax(0, prevCellIndex - 1));
644 }
645 else {
646 //int m_itemsLastIndex = m_items->size() - 1;
647 //verticalScrollBar()->setValue(qMin(prevCell + 1, ));
648 }
649 }
650
651 viewport()->update();
652 }
653 }
654 }
655
656 // Handle down arrow with shift pressed
657 else if (key == Qt::Key_Down && event->modifiers() == Qt::ShiftModifier) {
658 AbstractTreeItem *prevCell = m_lastShiftArrowSelectedCell->first ?
659 m_lastShiftArrowSelectedCell->first : m_activeCell->first;
660
661 int prevCellIndex = getModel()->indexOfVisibleItem(prevCell);
662
663 if (prevCellIndex >= 0 &&
664 prevCellIndex < getModel()->getVisibleRowCount() - 1) {
666 getModel()->getItems(prevCellIndex + 1, prevCellIndex + 2);
667
668 if (itemList.size()) {
669 AbstractTreeItem *curItem = itemList[0];
670
671 if (rowsWithActiveColumnSelected->contains(curItem) ||
672 curItem == m_activeCell->first)
673 rowsWithActiveColumnSelected->removeAll(prevCell);
674 else
675 rowsWithActiveColumnSelected->append(curItem);
676
677 if (curItem == m_activeCell->first)
678 m_lastShiftArrowSelectedCell->first = NULL;
679 else
680 m_lastShiftArrowSelectedCell->first = curItem;
681 m_lastShiftArrowSelectedCell->second = m_activeCell->second;
682 viewport()->update();
683
684 // scroll if needed
685 int m_itemsPrevIndex = m_items->indexOf(prevCell);
686 int m_itemsCurIndex = m_items->indexOf(curItem);
687 if (m_itemsCurIndex == -1) {
688 if (m_itemsPrevIndex == m_items->size() - 1) {
689 int visibleItemCount = getModel()->getVisibleRowCount();
690 verticalScrollBar()->setValue(qMin(visibleItemCount,
691 getModel()->indexOfVisibleItem(m_items->at(1))));
692 }
693 else {
694 //int m_itemsLastIndex = m_items->size() - 1;
695 //verticalScrollBar()->setValue(qMin(prevCell + 1, ));
696 }
697 }
698 }
699 }
700 }
701
702 // Handle up arrow
703 else if (key == Qt::Key_Up) {
705 }
706
707 // Handle down arrow
708 else if (key == Qt::Key_Down) {
710 }
711
712 // Handle left arrow
713 else if (key == Qt::Key_Left) {
715 }
716
717 // Handle right arrow
718 else if (key == Qt::Key_Right) {
720 }
721 }
722 }
723
724 // start editing the active cell
725 else {
726 // event->text() will be empty if a modifier was pressed.
727 if (hasActiveCell() && !event->text().isEmpty()) {
728 if (!m_items->contains(m_activeCell->first))
729 scrollTo(m_activeCell->first);
730
731 if (m_items->contains(m_activeCell->first) &&
732 cellIsEditable(m_items->indexOf(m_activeCell->first),
733 m_activeCell->second)) {
734 AbstractTableDelegate const *delegate = m_model->getDelegate();
735 TableColumn *col =
736 m_columns->getVisibleColumns()[m_activeCell->second];
737
738 delete m_editWidget;
739 m_editWidget = NULL;
740 m_editWidget = delegate->getWidget(col);
741 delegate->readData(m_editWidget, m_activeCell->first, col, event->text());
742 m_editWidget->setParent(this);
743 m_editWidget->setFocus(Qt::OtherFocusReason);
744 }
745
746 viewport()->update();
747 }
748 }
749 }
750
751
756 if (m_editWidget) {
757 TableColumn *col =
758 m_columns->getVisibleColumns()[m_activeCell->second];
759 getModel()->getDelegate()->saveData(
760 m_editWidget, m_activeCell->first, col);
761 delete m_editWidget;
762 m_editWidget = NULL;
763
764 cellDataChanged(col);
765 setFocus(Qt::ActiveWindowFocusReason);
766 }
767 }
768
769
774 int activeIndex = m_items->indexOf(m_activeCell->first);
775 if (activeIndex != -1) {
776 if (activeIndex == 0) {
777 int row = qMax(0, getModel()->indexOfVisibleItem(
778 m_activeCell->first) - 1);
779
780 verticalScrollBar()->setValue(row);
781 }
782
783 m_activeCell->first = (*m_items)[qMax(0, activeIndex - 1)];
785 viewport()->update();
786 }
787 }
788
789
794 int activeIndex = m_items->indexOf(m_activeCell->first);
795 if (activeIndex != -1) {
796 if (activeIndex == m_items->size() - 1) {
797 int row = qMin(getModel()->getVisibleRowCount() - 1,
798 getModel()->indexOfVisibleItem(m_items->at(0)));
799
800 verticalScrollBar()->setValue(row + 1);
801 activeIndex = m_items->indexOf(m_activeCell->first);
802 }
803
804 m_activeCell->first = (*m_items)[qMin(activeIndex + 1, m_items->size() - 1)];
806 viewport()->update();
807 }
808 }
809
810
815 m_activeCell->second = qMax(1, m_activeCell->second - 1);
816 int leftMostVisibleCol = getColumnFromScreenX(0);
817 if (leftMostVisibleCol == m_activeCell->second) {
818 horizontalScrollBar()->setValue(horizontalScrollBar()->value() -
819 m_columns->getVisibleColumns()[m_activeCell->second]->getWidth());
820 }
821
823 viewport()->update();
824 }
825
826
831 m_activeCell->second = qMin(m_columns->getVisibleColumns().size() - 1,
832 m_activeCell->second + 1);
833 int rightMostVisibleCol = getColumnFromScreenX(viewport()->width());
834 if (rightMostVisibleCol == m_activeCell->second) {
835 horizontalScrollBar()->setValue(horizontalScrollBar()->value() +
836 m_columns->getVisibleColumns()[m_activeCell->second]->getWidth());
837 }
838
840 viewport()->update();
841 }
842
843
849 void TableViewContent::paintEvent(QPaintEvent *event) {
850 if (m_model && m_columns) {
851 // int startRow = verticalScrollBar()->value();
852 int rowCount = (int) ceil(viewport()->height() / (double) m_rowHeight);
853
854 QPainter painter(viewport());
855 painter.setRenderHint(QPainter::Antialiasing, false);
856 // painter.setRenderHints(QPainter::NonCosmeticDefaultPen, true);
857
858 bool editWidgetVisible = false;
859 for (int i = 0; i < rowCount; i++) {
860 // define the top left corner of the row and also how big the row is
861 QPoint relativeTopLeft(0, i * m_rowHeight);
862 QPoint scrollBarPos(horizontalScrollBar()->value(),
863 verticalScrollBar()->value());
864 QPoint absoluteTopLeft(relativeTopLeft + scrollBarPos);
865 QSize rowSize(viewport()->width(), (int) m_rowHeight);
866
867 // Fill in the background with the background color
868 painter.fillRect(QRect(relativeTopLeft, rowSize), palette().base());
869
870 if (i < m_items->size()) {
871
872
873
874
875
876
877 // ********************************************************
878 // HACK: FIXME: ask tree m_items if background needs to be
879 // darkened, instead figuring that out here. Also, change
880 // composition mode so that ref measure rows look different
881 // when they are highlighted as well
882 /*
883 if (m_items->at(i)->getPointerType() == AbstractTreeItem::Measure)
884 {
885 ControlMeasure * cm = (ControlMeasure *) m_items->at(i)->getPointer();
886 if (cm->Parent()->GetRefMeasure() == cm)
887 {
888 QPoint selectionTopLeft(-absoluteTopLeft.x(), relativeTopLeft.y());
889 QSize selectionSize(m_columns->getVisibleWidth(), (int) m_rowHeight);
890
891 QRect selectionRect(selectionTopLeft, selectionSize);
892 QColor color = palette().base().color();
893 painter.fillRect(selectionRect, color.darker(110));
894 }
895 }
896 */
897 //*********************************************************
898
899
900
901
902
903
904
905
906
907
908
909
910 if (m_items->at(i)->isSelected()) {
911 QPoint selectionTopLeft(-absoluteTopLeft.x(), relativeTopLeft.y());
912 QSize selectionSize(m_columns->getVisibleWidth(), (int) m_rowHeight);
913
914 QRect selectionRect(selectionTopLeft, selectionSize);
915 painter.fillRect(selectionRect, palette().highlight().color());
916 }
917
918 paintRow(&painter, i, absoluteTopLeft, relativeTopLeft);
919 }
920 }
921
922 for (int i = 0; i < rowCount; i++) {
923 if (i < m_items->size()) {
924 QPoint relativeTopLeft(0, i * m_rowHeight);
925 if (m_editWidget && m_activeCell->first == m_items->at(i)) {
926 QPair<int, int> xRange(
927 m_columns->getVisibleXRange(m_activeCell->second));
928
929 m_editWidget->move(
930 QPoint(xRange.first - horizontalScrollBar()->value() - 1,
931 relativeTopLeft.y() + 1));
932 m_editWidget->resize(xRange.second - xRange.first, m_rowHeight + 1);
933 m_editWidget->setVisible(true);
934 editWidgetVisible = true;
935 }
936 else {
937 if (m_activeCell->first == m_items->at(i)) {
938 QPair<int, int> activeXArea =
939 m_columns->getVisibleXRange(m_activeCell->second);
940
941 QRect activeArea(activeXArea.first, relativeTopLeft.y(),
942 activeXArea.second - activeXArea.first, m_rowHeight);
943
944 activeArea.moveLeft(
945 activeArea.left() - horizontalScrollBar()->value());
946 activeArea.adjust(-1, -1, -2, -1);
947 QPen pen(Qt::black);
948 pen.setWidth(3);
949 painter.setPen(pen);
950 painter.drawRect(activeArea);
951 }
952 }
953 }
954 }
955
956 if (m_editWidget && !editWidgetVisible)
957 m_editWidget->setVisible(false);
958 }
959 else {
960 QWidget::paintEvent(event);
961 }
962 }
963
964
970 void TableViewContent::resizeEvent(QResizeEvent *event) {
971 QAbstractScrollArea::resizeEvent(event);
974 }
975
976
984 QAbstractScrollArea::scrollContentsBy(dx, dy);
986 }
987
988
993 m_parentView = NULL;
994 m_model = NULL;
995 m_items = NULL;
996 m_activeCell = NULL;
997 m_lastShiftArrowSelectedCell = NULL;
998 m_editWidget = NULL;
1000 m_lastShiftSelection = NULL;
1001 m_columns = NULL;
1003 m_applyToSelectionAct = NULL;
1004 m_applyToAllAct = NULL;
1006 m_editControlPointAct = NULL;
1007 }
1008
1009
1016 if (col->hasNetworkStructureEffect())
1017 emit rebuildModels(QList< AbstractTreeItem * >());
1018
1019 emit modelDataChanged();
1020 }
1021
1022
1027 m_activeCell->first = NULL;
1028 m_activeCell->second = -1;
1029 }
1030
1031
1036 m_lastShiftArrowSelectedCell->first = NULL;
1038 }
1039
1040
1047 if (hasActiveCell()) {
1048 TableColumn *col = m_columns->getVisibleColumns()[m_activeCell->second];
1049
1050 QString colTitle = col->getTitle();
1051
1052 // Grab the active cell's data and copy it to the selected cells that are
1053 // in the same column as the active cell.
1054 QString cellData = m_activeCell->first->getFormattedData(colTitle);
1055
1056 QList< AbstractTreeItem * > selection = allCells ? m_model->getItems(
1057 0, m_model->getVisibleRowCount()) : *rowsWithActiveColumnSelected;
1058
1059 bool needsDialog = true;
1060 bool done = false;
1061 for (int i = 0; !done && i < selection.size(); i++) {
1062 AbstractTreeItem *row = selection[i];
1063 bool changeData = true;
1064
1065 QString warningText =
1066 m_model->getWarningMessage(row, col, cellData);
1067 if (needsDialog && warningText.size()) {
1068 QMessageBox::StandardButton status = QMessageBox::warning(
1069 this, "Change cells?", warningText, QMessageBox::Yes |
1070 QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll);
1071
1072 switch (status) {
1073 case QMessageBox::YesToAll:
1074 needsDialog = false;
1075 break;
1076 case QMessageBox::NoToAll:
1077 done = true;
1078 case QMessageBox::No:
1079 changeData = false;
1080 default:
1081 ;
1082 }
1083 }
1084
1085 if (changeData)
1086 row->setData(colTitle, cellData);
1087 }
1088
1089 viewport()->update();
1090 cellDataChanged(col);
1091 }
1092 }
1093
1094
1099 m_applyToSelectionAct = new QAction(tr("Copy to selected cells"), this);
1100 m_applyToSelectionAct->setStatusTip(tr("Copy the contents of this cell to the"
1101 "selected cells"));
1102 connect(m_applyToSelectionAct, SIGNAL(triggered()),
1103 this, SLOT(copySelection()));
1104
1105 m_applyToAllAct = new QAction(tr("Copy to all cells"), this);
1106 m_applyToAllAct->setStatusTip(tr("Copy the contents of this cell to all"
1107 "cells in the current column"));
1108 connect(m_applyToAllAct, SIGNAL(triggered()),
1109 this, SLOT(copyAll()));
1110
1111 m_deleteSelectedRowsAct = new QAction(tr("Delete selected rows"), this);
1112 m_deleteSelectedRowsAct->setStatusTip(
1113 tr("Delete the currently selected rows"));
1114 connect(m_deleteSelectedRowsAct, SIGNAL(triggered()),
1115 this, SLOT(deleteSelectedRows()));
1116
1117 m_editControlPointAct = new QAction(tr("Edit selected control point"), this);
1118 m_editControlPointAct->setStatusTip(
1119 tr("Edit the selected control point or the parent control point of control measure"));
1120 connect(m_editControlPointAct, SIGNAL(triggered()),
1121 this, SLOT(editControlPoint()));
1122 }
1123
1124
1133
1134 for (int i = 0; i < m_columns->getVisibleColumns().size(); i++) {
1135 QPair<int, int> cellXRange(m_columns->getVisibleXRange(i));
1136 int deltaX = -horizontalScrollBar()->value();
1137
1138 if (cellXRange.first + deltaX < screenX &&
1139 cellXRange.second + deltaX > screenX) {
1140 return i;
1141 }
1142 }
1143
1144 return -1;
1145 }
1146
1147
1156 int calculatedRowNum = screenY / m_rowHeight;
1157
1158 if (calculatedRowNum >= 0 && calculatedRowNum < m_items->size() &&
1159 screenY >= 0 && screenY <= viewport()->height())
1160 return calculatedRowNum;
1161
1162 return -1;
1163 }
1164
1165
1172 return (m_activeCell->first && m_activeCell->second >= 0);
1173 }
1174
1175
1182 return (m_model->getSelectedItems().size());
1183 }
1184
1185
1193 bool TableViewContent::mouseInCellSelection(QPoint mousePos) const {
1194 int colNum = getColumnFromScreenX(mousePos.x());
1195 AbstractTreeItem *row = m_items->at(getRowFromScreenY(mousePos.y()));
1196
1197 return (rowsWithActiveColumnSelected->contains(row) &&
1198 m_activeCell->second == colNum);
1199 }
1200
1201
1209 bool TableViewContent::mouseInRowSelection(QPoint mousePos) const {
1210 AbstractTreeItem *row = m_items->at(getRowFromScreenY(mousePos.y()));
1211
1212 return (m_model->getSelectedItems().contains(row));
1213 }
1214
1215
1223 bool TableViewContent::rowIsValid(int rowNum) const {
1224 bool valid = false;
1225
1226 if (rowNum >= 0 && rowNum < m_items->size())
1227 valid = true;
1228
1229 return valid;
1230 }
1231
1232
1240 bool TableViewContent::columnIsValid(int colNum) const {
1241 bool valid = false;
1242
1243 if (colNum >= 0 && colNum < m_columns->getVisibleColumns().size())
1244 valid = true;
1245
1246 return valid;
1247 }
1248
1249
1258 bool TableViewContent::cellIsEditable(int rowNum, int colNum) const {
1259
1260 bool editable = false;
1261
1262 QString colName = m_columns->getVisibleColumns()[colNum]->getTitle();
1263 if (m_items->at(rowNum)->isSelectable() &&
1264 m_items->at(rowNum)->isDataEditable(colName) &&
1265 !m_columns->getVisibleColumns()[colNum]->isReadOnly())
1266 editable = true;
1267
1268 return editable;
1269 }
1270
1271
1279 bool TableViewContent::isDataColumn(int colNum) const {
1280 //TODO: Figure out what this does and if we can do it in a less confusing and roundabout way
1281 return m_columns->getVisibleColumns()[colNum]->getTitle().size();
1282 }
1283
1284
1293 void TableViewContent::paintRow(QPainter *painter, int rowNum,
1294 QPoint absolutePosition, QPoint relativePosition) {
1295
1296 QPoint point(-absolutePosition.x(), relativePosition.y());
1297
1298 AbstractTreeItem *item = (*m_items)[rowNum];
1299
1300 // should always be true, but prevents segfault in case of bug
1301 if (item) {
1302 QPen originalPen = painter->pen();
1303
1304 QPoint textPoint(point.x() + ITEM_INDENTATION,
1305 point.y() + ITEM_PADDING / 2);
1306
1307 // finally draw the text
1308 int textHeight = m_rowHeight - ITEM_PADDING;
1309
1310 QFontMetrics metrics(font());
1311
1312 QPen gridPen(Qt::gray);
1313
1314 TableColumnList visibleCols = m_columns->getVisibleColumns();
1315 for (int i = 0; i < visibleCols.size(); i++) {
1316 // draw text
1317 QPair<int, int> cellXRange(visibleCols.getVisibleXRange(i));
1318 QRect cellRect(cellXRange.first, point.y(),
1319 cellXRange.second - cellXRange.first, m_rowHeight);
1320 cellRect.moveLeft(cellRect.left() - horizontalScrollBar()->value() - 1);
1321
1322 QString columnTitle = visibleCols[i]->getTitle();
1323 QRect textRect(textPoint, QSize(cellRect.right() - textPoint.x(),
1324 textHeight));
1325 QString text;
1326 bool textCentered = false;
1327 if (!columnTitle.isEmpty()) {
1328 text = item->getFormattedData(columnTitle);
1329
1330 if (rowsWithActiveColumnSelected->indexOf(item) != -1 &&
1331 m_activeCell->second == i) {
1332 // This cell is selected, so render it as such.
1333 if (m_activeCell->first != item) {
1334 painter->fillRect(cellRect,
1335 QBrush(palette().highlight().color()));
1336 painter->setPen(palette().highlightedText().color());
1337 }
1338 else {
1339 painter->setPen(palette().text().color());
1340 }
1341 }
1342 else {
1343 if (item->isSelected()) {
1344 painter->setPen(palette().highlightedText().color());
1345 }
1346 else {
1347 // If the current column is not editable (i.e. read-only), or it
1348 // is locked (think edit-locked control point or measure), then
1349 // it should be grayed out.
1350 //
1351 // NOTE: The following two lines provide for graying out of edit
1352 // locked data. This is commented out because this functionality
1353 // is not fully working yet.
1354 //if (!cellIsEditable(rowNum, i) ||
1355 // item->isDataLocked(columnTitle))
1356 if (!cellIsEditable(rowNum, i)) {
1357 painter->setPen(palette().color(QPalette::Disabled,
1358 QPalette::Text));
1359 }
1360 else {
1361 painter->setPen(palette().text().color());
1362 }
1363 }
1364 }
1365 }
1366 else {
1367 // Draw the row number.
1368 text = QString::number(rowNum + verticalScrollBar()->value() + 1);
1369 textCentered = true;
1370
1371 // We need to paint the row number column.
1372 int x = cellRect.center().x();
1373 QLinearGradient gradient(x, cellRect.top(), x, cellRect.bottom());
1374
1375 bool selected = item->isSelected();
1376 QColor color = selected ? palette().highlight().color() :
1377 palette().button().color();
1378
1379 int adjustment = 110;
1380 gradient.setColorAt(0, color.lighter(adjustment));
1381 gradient.setColorAt(1, color.darker(adjustment));
1382 painter->fillRect(cellRect, gradient);
1383 if (selected)
1384 painter->setPen(palette().highlightedText().color());
1385 else
1386 painter->setPen(palette().text().color());
1387 }
1388
1389 int flags = Qt::TextDontClip;
1390 if (textCentered)
1391 flags |= Qt::AlignCenter;
1392
1393 // TODO this shouldn't be here... an item should be able to tell
1394 // whether or not it should be bolded.
1395 QFont normalFont = painter->font();
1396
1397 if (item->getPointerType() == AbstractTreeItem::Measure) {
1398 ControlMeasure *cm = (ControlMeasure *) item->getPointer();
1399 if (cm && cm->Parent() && cm->Parent()->GetRefMeasure() == cm) {
1400 QFont boldFont(normalFont);
1401 boldFont.setBold(true);
1402 painter->setFont(boldFont);
1403 }
1404 }
1405
1406 painter->drawText(textRect, flags,
1407 metrics.elidedText(text, Qt::ElideRight,
1408 textRect.width() - ITEM_INDENTATION));
1409 painter->setFont(normalFont);
1410
1411 textPoint.setX(cellRect.right() + ITEM_INDENTATION);
1412 painter->setPen(originalPen);
1413
1414 painter->setPen(gridPen);
1415 painter->drawLine(QPoint(cellRect.right(), point.y()),
1416 QPoint(cellRect.right(), point.y() + m_rowHeight));
1417 painter->setPen(originalPen);
1418 }
1419
1420 int left = -horizontalScrollBar()->value() - 1;
1421 int right = m_columns->getVisibleWidth();
1422
1423 gridPen.setWidth(2);
1424 painter->setPen(gridPen);
1425 painter->drawLine(QPoint(left, point.y() + m_rowHeight),
1426 QPoint(right, point.y() + m_rowHeight));
1427 painter->setPen(originalPen);
1428 }
1429 }
1430
1431
1437 void TableViewContent::updateActiveCell(QPoint screenPos) {
1438 if (m_editWidget && m_activeCell->first && m_activeCell->second >= 0) {
1439 try {
1440 const TableColumn *col =
1441 m_columns->getVisibleColumns()[m_activeCell->second];
1442 m_model->getDelegate()->saveData(m_editWidget, m_activeCell->first,
1443 col);
1444
1445 cellDataChanged(col);
1446 }
1447 catch (IException &e) {
1448 QMessageBox::critical(this, "Failed to Set Data", e.what());
1449 }
1450 }
1451
1452 int rowNum = getRowFromScreenY(screenPos.y());
1453 int oldActiveColumn = m_activeCell->second;
1454
1456
1457 if (rowNum >= 0) {
1458 AbstractTreeItem *item = (*m_items)[rowNum];
1459
1460 TableColumnList visibleCols = m_columns->getVisibleColumns();
1461 for (int i = 0; i < visibleCols.size(); i++) {
1462 QPair<int, int> cellXRange(m_columns->getVisibleXRange(i));
1463 QRect cellRect(cellXRange.first, m_rowHeight * rowNum,
1464 cellXRange.second - cellXRange.first, m_rowHeight);
1465
1466 cellRect.moveLeft(cellRect.left() - horizontalScrollBar()->value());
1467
1468 if (cellRect.contains(screenPos) &&
1469 (oldActiveColumn != -1 || !visibleCols[i]->getTitle().isEmpty())) {
1470 m_activeCell->first = item;
1471 m_activeCell->second = i;
1472 }
1473 }
1474 }
1475
1476 if (oldActiveColumn != m_activeCell->second) {
1479 }
1480
1482 }
1483
1484
1491 // delete current row selection
1492 foreach (AbstractTreeItem * row, *m_lastShiftSelection) {
1493 if (rowsWithActiveColumnSelected->indexOf(row) != -1)
1494 rowsWithActiveColumnSelected->removeOne(row);
1495 }
1496
1497
1499 *m_lastShiftSelection = m_model->getItems(
1501 }
1502 else {
1503 m_lastShiftSelection->clear();
1504 }
1505
1506 foreach (AbstractTreeItem * row, *m_lastShiftSelection) {
1507 if (rowsWithActiveColumnSelected->indexOf(row) == -1)
1508 rowsWithActiveColumnSelected->append(row);
1509 }
1510 }
1511
1512
1521 foreach (AbstractTreeItem * row, *m_lastShiftSelection) {
1522 if (row->getPointerType() == AbstractTreeItem::Point) {
1523 foreach (AbstractTreeItem * child, row->getChildren())
1524 child->setSelected(false);
1525 }
1526
1527 if (row->getPointerType() == AbstractTreeItem::Measure)
1528 row->parent()->setSelected(false);
1529
1530 row->setSelected(false);
1531 }
1532
1534 *m_lastShiftSelection = m_model->getItems(
1535 m_lastDirectlySelectedRow, m_items->at(lastRow));
1536 }
1537 else {
1538 m_lastShiftSelection->clear();
1539 }
1540
1541 QList< AbstractTreeItem * > newlySelectedItems;
1542 foreach (AbstractTreeItem * row, *m_lastShiftSelection) {
1543 row->setSelected(true);
1544
1545 if (row->getPointerType() == AbstractTreeItem::Measure)
1546 row->parent()->setSelected(true);
1547
1548 newlySelectedItems.append(row);
1549 }
1550
1551 return newlySelectedItems;
1552 }
1553
1554
1563
1564
1573
1574
1579 // Prompt the user for confirmation before deletion.
1580 QMessageBox::StandardButton status = QMessageBox::warning(
1581 this, "Delete row(s)?", "Delete selected row(s)?",
1582 QMessageBox::Yes | QMessageBox::No);
1583
1584 if (status == QMessageBox::Yes) {
1585 // TODO should we store off the selected rows for efficiency?
1586 QList<AbstractTreeItem *> selectedRows = m_model->getSelectedItems();
1587
1588 emit rebuildModels(selectedRows);
1589 emit modelDataChanged();
1590
1591 m_lastShiftSelection->clear();
1592 }
1593 }
1594
1595
1600
1601 ControlPoint *cp;
1602 QString serialNumber;
1603 AbstractTreeItem *item;
1604
1605 // A single cell is chosen
1606 if (m_model->getSelectedItems().count() == 0) {
1607 item = m_activeCell->first;
1608 }
1609 // A row is chosen
1610 else {
1612 }
1613
1614 // Item chosen from the Point table view
1615 if (item->getPointerType() == AbstractTreeItem::Point) {
1616 cp = (ControlPoint *) (item->getPointer());
1617 }
1618 // Item chosen from the Measure table view
1619 else {
1620 cp = (ControlPoint *) (item->parent()->getPointer());
1621 serialNumber = item->getData("Image ID").toString();
1622 }
1623
1624// qDebug()<<"activeCell cpid = "<<cp->GetId()<<" sn = "<<serialNumber;
1625
1626 emit editControlPoint(cp, serialNumber);
1627 }
1628
1629
1634
1635 if (m_model) {
1636 int startRow = verticalScrollBar()->value();
1637 int rowCount = (int) ceil(viewport()->height() / (double) m_rowHeight);
1638 m_items->clear();
1639 foreach (AbstractTreeItem * item,
1640 m_model->getItems(startRow, startRow + rowCount)) {
1641 m_items->append(item);
1642 }
1643
1644 viewport()->update();
1645 }
1646 }
1647
1648
1654 void TableViewContent::showContextMenu(QPoint mouseLocation) {
1655 QMenu contextMenu(this);
1656
1657 // Only add this action if a single row is selected or a cell is selected
1658 // TODO: 2017-05-17 TLS
1659 // Always allow editing of point. Should we check for editLock??
1660 QList<AbstractTreeItem *> selectedRows = m_model->getSelectedItems();
1661
1662
1663 // If there is a row selection, show a context menu if the user clicked
1664 // anywhere on any of the selected row(s).
1665
1666 if (QApplication::applicationName() != "cneteditor") {
1667 if (m_activeControlNet) {
1668 m_editControlPointAct->setEnabled(true);
1669 m_applyToSelectionAct->setEnabled(true);
1670 m_applyToAllAct->setEnabled(true);
1671 }
1672 else {
1673 m_editControlPointAct->setEnabled(false);
1674 m_applyToSelectionAct->setEnabled(false);
1675 m_applyToAllAct->setEnabled(false);
1676 }
1677
1678 // We want to be able to delete rows in a nonactive control.
1679 m_deleteSelectedRowsAct->setEnabled(true);
1680
1681 if (hasActiveCell() && selectedRows.count() <= 1) {
1682 contextMenu.addAction(m_editControlPointAct);
1683 }
1684 if (hasRowSelection() && mouseInRowSelection(mouseLocation)) {
1685 contextMenu.addAction(m_deleteSelectedRowsAct);
1686 }
1687
1688 // Only show the context menu for cells if the user right-clicked on the
1689 // active cell.
1690 if (hasActiveCell() && mouseInCellSelection(mouseLocation)) {
1691 if (rowsWithActiveColumnSelected->size() > 1) {
1692 contextMenu.addAction(m_applyToSelectionAct);
1693 }
1694
1695 contextMenu.addAction(m_applyToAllAct);
1696 }
1697 }
1698 else {
1699 if (hasRowSelection() && mouseInRowSelection(mouseLocation)) {
1700 contextMenu.addAction(m_deleteSelectedRowsAct);
1701 }
1702
1703 // Only show the context menu for cells if the user right-clicked on the
1704 // active cell.
1705 if (hasActiveCell() && mouseInCellSelection(mouseLocation)) {
1706 if (rowsWithActiveColumnSelected->size() > 1) {
1707 contextMenu.addAction(m_applyToSelectionAct);
1708 }
1709
1710 contextMenu.addAction(m_applyToAllAct);
1711 }
1712 }
1713 contextMenu.exec(mapToGlobal(mouseLocation));
1714 }
1715}
Base class for delegates which create, read, and save data in the tables.
Translates the tree model into a table model.
Base class for an item in the tree.
a control measurement
A single control point.
const ControlMeasure * GetRefMeasure() const
Get the reference control measure.
QPair< int, int > getVisibleXRange(int visibleColumn)
bool hasActiveCell() const
Checks if there is an active cell.
void mouseDoubleClickEvent(QMouseEvent *event)
Overrides QWidget::mouseDoubleClickEvent.
QList< AbstractTreeItem * > updateRowGroupSelection(int lastRow)
Updates which row is selected.
void moveActiveCellDown()
Changes the viewport when the active cell is moved.
int getRowFromScreenY(int screenY) const
Calculates the visible range of a row and returns the index of the column.
void paintEvent(QPaintEvent *event)
Paints the table when there is a paint event.
AbstractTableModel * getModel()
Returns the model.
void clearActiveCell()
Clears the active cell.
void refresh()
Refreshes the table and viewport.
void leaveEvent(QEvent *event)
Overrides QWidget::leaveEvent.
void resizeEvent(QResizeEvent *event)
Updates the table when it is resized.
void scrollTo(QList< AbstractTreeItem * >)
Scrolls to the selected items.
void mousePressEvent(QMouseEvent *event)
Overrides QWidget::mousePressEvent.
void copyCellSelection(bool)
Copies the selected cells.
void updateItemList()
Updates the item list.
void createActions()
Builds the menus.
void updateColumnGroupSelection(AbstractTreeItem *)
Updates which column is selected.
void editControlPoint()
Retrieves the control point from the selected cells for editing.
void finishEditing()
Saves the data from the cell the user was modifying.
QSize sizeHint() const
Returns the minimum size hint.
void copyAll()
Copies all of the cells.
QAction * m_applyToSelectionAct
This action applies (copies) the contents of the active cell to the current selection.
QAction * m_editControlPointAct
This action edits selected control point or if measure selected, edit parent control pt.
void clearColumnSelection()
Clears the selected column.
void cellDataChanged(TableColumn const *col)
Rebuilds the models when the data is changed.
void moveActiveCellRight()
Changes the viewport when the active cell is moved.
QAction * m_deleteSelectedRowsAct
This action deletes the selected rows.
void updateHorizontalScrollBar(bool scrollRight=false)
Updates the horizontal scroll bar.
bool eventFilter(QObject *target, QEvent *event)
Overrides QObject::eventFilter.
bool rowIsValid(int rowNum) const
Checks if the row number is valid.
AbstractTreeItem * m_lastDirectlySelectedRow
This is the last row that was selected by either a control-click or normal click.
bool cellIsEditable(int, int) const
Checks if the cell is editable.
void moveActiveCellLeft()
Changes the viewport when the active cell is moved.
void deleteSelectedRows()
Deletes the selected rows.
void updateActiveCell(QPoint)
Updates which cell is active.
QSize minimumSizeHint() const
Returns the minimum size hint.
QAction * m_applyToAllAct
This action applies (copies) the contents of the active cell to all of the cells in the active cell's...
TableViewContent(AbstractTableModel *someModel)
Constructor.
bool hasRowSelection() const
Checks if there is a row selected.
void paintRow(QPainter *, int, QPoint, QPoint)
Repaints the row.
bool columnIsValid(int colNum) const
Checks if the column number is valid.
QList< AbstractTreeItem * > * rowsWithActiveColumnSelected
Stores a list of the rows that have their active column cells selected.
void keyPressEvent(QKeyEvent *event)
Overrides QWidget::keyPressEvent.
void copySelection()
Copies selected cells.
void nullify()
Clears all member variables.
bool isDataColumn(int) const
Checks if the column has a non empty title.
void moveActiveCellUp()
Shifts the active cell up.
void mouseReleaseEvent(QMouseEvent *event)
Overrides QWidget::mouseReleaseEvent.
void mouseMoveEvent(QMouseEvent *event)
Overrides QWidget::mouseMoveEvent.
void showContextMenu(QPoint)
Populates the context menus based on where the user clicked.
bool mouseInRowSelection(QPoint) const
Checks if the mouse is in the selected row.
void scrollContentsBy(int dx, int dy)
Updates the item list when the user scrolls.
virtual ~TableViewContent()
Destructor.
void setActiveControlNet(bool activeNet)
Sets if there is an active control net.
int getColumnFromScreenX(int screenX) const
Calculates the visible range of a column and returns the index of the column.
bool mouseInCellSelection(QPoint) const
Checks if the mouse is in the selected cells.
This is free and unencumbered software released into the public domain.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16