9#include "TableViewContent.h"
15#include <QApplication>
27#include <QStyleOptionViewItemV4>
31#include "ControlMeasure.h"
32#include "IException.h"
35#include "AbstractTableDelegate.h"
36#include "AbstractTableModel.h"
37#include "AbstractTreeItem.h"
38#include "TableColumn.h"
39#include "TableColumnList.h"
40#include <ControlPoint.h>
53 connect(m_model, SIGNAL(modelModified()),
this, SLOT(
refresh()));
54 connect(m_model, SIGNAL(filterProgressChanged(
int)),
56 connect(
this, SIGNAL(modelDataChanged()),
57 m_model, SLOT(applyFilter()));
59 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)),
61 SIGNAL(tableSelectionChanged(QList< AbstractTreeItem * >)));
62 connect(m_model, SIGNAL(treeSelectionChanged(QList< AbstractTreeItem * >)),
63 this, SLOT(
scrollTo(QList< AbstractTreeItem * >)));
65 m_columns =
getModel()->getColumns();
66 for (
int i = 0; i < m_columns->size(); i++) {
69 connect(column, SIGNAL(visibilityChanged()),
this, SLOT(
refresh()));
70 connect(column, SIGNAL(visibilityChanged()),
72 connect(column, SIGNAL(widthChanged()),
this, SLOT(
refresh()));
75 m_items =
new QList< QPointer<AbstractTreeItem> >;
76 m_activeCell =
new QPair<AbstractTreeItem *, int>(NULL, -1);
78 m_lastShiftSelection =
new QList<AbstractTreeItem *>;
79 m_lastShiftArrowSelectedCell =
new QPair< AbstractTreeItem *, int >;
80 m_lastShiftArrowSelectedCell->first = NULL;
82 verticalScrollBar()->setSingleStep(1);
84 m_rowHeight = QFontMetrics(font()).height() + ITEM_PADDING;
86 connect(horizontalScrollBar(), SIGNAL(valueChanged(
int)),
87 this, SIGNAL(horizontalScrollBarValueChanged(
int)));
89 setMouseTracking(
true);
94 setContextMenuPolicy(Qt::CustomContextMenu);
95 connect(
this, SIGNAL(customContextMenuRequested(QPoint)),
98 m_activeControlNet =
false;
115 delete m_lastShiftSelection;
116 m_lastShiftSelection = NULL;
130 delete m_lastShiftArrowSelectedCell;
131 m_lastShiftArrowSelectedCell = NULL;
143 return QWidget::minimumSizeHint();
213 m_activeControlNet = activeNet;
222 if (!m_model->isFiltering()) {
223 int rowCount = m_model->getVisibleRowCount();
224 verticalScrollBar()->setRange(0, qMax(rowCount - 1, 0));
229 m_lastShiftSelection->clear();
231 if (m_model->getSelectedItems().size() &&
237 viewport()->update();
251 for (
int i = 0; i < visibleCols.size(); i++)
252 range += visibleCols[i]->getWidth() - 1;
256 horizontalScrollBar()->setRange(0, range - viewport()->width());
257 horizontalScrollBar()->setPageStep(viewport()->width());
260 horizontalScrollBar()->setValue(horizontalScrollBar()->maximum());
271 QList< AbstractTreeItem * > newlySelectedItems) {
272 if (newlySelectedItems.size())
273 scrollTo(newlySelectedItems.last());
283 int row =
getModel()->indexOfVisibleItem(newlySelectedItem);
286 int topRow = verticalScrollBar()->value();
289 verticalScrollBar()->setValue(row);
292 int wholeVisibleRowCount = viewport()->height() / m_rowHeight;
293 int bottomRow = topRow + wholeVisibleRowCount;
295 verticalScrollBar()->setValue(row - wholeVisibleRowCount + 1);
299 viewport()->update();
312 return QObject::eventFilter(target, event);
322 if (event->buttons() & Qt::LeftButton) {
323 int rowNum =
event->pos().y() / m_rowHeight;
325 if (m_activeCell->first &&
cellIsEditable(rowNum, m_activeCell->second)) {
328 m_columns->getVisibleColumns()[m_activeCell->second];
332 m_editWidget = delegate->getWidget(col);
333 delegate->readData(m_editWidget, m_activeCell->first, col);
334 m_editWidget->setParent(
this);
335 m_editWidget->setFocus(Qt::OtherFocusReason);
338 viewport()->update();
350 if (event->buttons() & Qt::LeftButton) {
352 if (!(event->modifiers() & Qt::ShiftModifier))
355 int rowNum =
event->pos().y() / m_rowHeight;
365 if (rowNum >= 0 && rowNum < m_items->size() && m_activeCell->first) {
370 m_model->setGlobalSelection(
false);
373 if (event->modifiers() & Qt::ControlModifier) {
380 m_lastShiftSelection->clear();
383 if (event->modifiers() & Qt::ShiftModifier) {
391 m_lastShiftSelection->clear();
398 if (rowNum >= 0 && rowNum < m_items->size()) {
401 if (columnNum != -1) {
402 TableColumn *column = m_columns->getVisibleColumns()[columnNum];
403 if (column->getTitle().isEmpty()) {
407 QList< AbstractTreeItem * > newlySelectedItems;
409 if (event->modifiers() & Qt::ControlModifier) {
410 if (item->getPointerType() == AbstractTreeItem::Measure)
411 item->parent()->setSelected(!item->isSelected());
413 item->setSelected(!item->isSelected());
415 newlySelectedItems.append(item);
418 if (event->modifiers() & Qt::ShiftModifier) {
422 QList<AbstractTreeItem *> selectedItems =
423 m_model->getSelectedItems();
426 if (selectedItem->getPointerType() ==
427 AbstractTreeItem::Measure)
428 selectedItem->parent()->setSelected(
false);
431 m_model->setGlobalSelection(
false);
433 if (item->getPointerType() == AbstractTreeItem::Measure)
434 item->parent()->setSelected(
true);
436 item->setSelected(
true);
438 newlySelectedItems.append(item);
442 QList< AbstractTreeItem * > tmp = newlySelectedItems;
443 newlySelectedItems.clear();
445 newlySelectedItems.append(i);
446 if (i->getPointerType() == AbstractTreeItem::Point) {
448 child->setSelected(
true);
449 newlySelectedItems.append(child);
454 emit tableSelectionChanged(newlySelectedItems);
463 viewport()->update();
464 emit tableSelectionChanged();
485 if (event->buttons() & Qt::LeftButton) {
486 int rowNum =
event->pos().y() / m_rowHeight;
489 int yPos =
event->pos().y();
490 if (yPos >= 0 && rowNum < m_items->size() && m_activeCell->first) {
499 if (yPos >= 0 && rowNum < m_items->size()) {
504 if (columnNum != -1) {
507 QList< AbstractTreeItem * > tmp =
509 QList< AbstractTreeItem * > newlySelectedItems;
511 newlySelectedItems.append(i);
512 if (i->getPointerType() == AbstractTreeItem::Point) {
514 child->setSelected(
true);
515 newlySelectedItems.append(child);
520 emit tableSelectionChanged(newlySelectedItems);
525 QScrollBar *vertScroll = verticalScrollBar();
527 if (yPos > viewport()->height() &&
528 vertScroll->value() < vertScroll->maximum()) {
530 vertScroll->setValue(vertScroll->value() + 1);
533 if (yPos < 0 && vertScroll->value() > vertScroll->minimum())
534 vertScroll->setValue(vertScroll->value() - 1);
537 viewport()->update();
538 emit tableSelectionChanged();
560 Qt::Key key = (Qt::Key) event->key();
563 if (key == Qt::Key_A && event->modifiers() == Qt::ControlModifier) {
566 m_model->setGlobalSelection(
true);
567 viewport()->update();
569 emit tableSelectionChanged();
573 else if (key == Qt::Key_Escape) {
577 setFocus(Qt::ActiveWindowFocusReason);
578 viewport()->update();
583 else if (key == Qt::Key_Delete) {
589 else if (key == Qt::Key_Return || key == Qt::Key_Enter) {
595 else if (key == Qt::Key_Tab) {
601 else if (key == Qt::Key_Up || key == Qt::Key_Down ||
602 key == Qt::Key_Left || key == Qt::Key_Right) {
604 if (m_items && m_items->size()) {
605 m_activeCell->first = (*m_items)[0];
606 m_activeCell->second = 1;
613 if (key == Qt::Key_Up && event->modifiers() == Qt::ShiftModifier) {
616 m_lastShiftArrowSelectedCell->first : m_activeCell->first;
618 int prevCellIndex =
getModel()->indexOfVisibleItem(prevCell);
620 if (prevCellIndex > 0) {
621 QList< AbstractTreeItem * > itemList =
622 getModel()->getItems(prevCellIndex - 1, prevCellIndex);
624 if (itemList.size()) {
628 curItem == m_activeCell->first)
633 if (curItem == m_activeCell->first)
634 m_lastShiftArrowSelectedCell->first = NULL;
636 m_lastShiftArrowSelectedCell->first = curItem;
637 m_lastShiftArrowSelectedCell->second = m_activeCell->second;
640 int m_itemsPrevIndex = m_items->indexOf(prevCell);
641 int m_itemsCurIndex = m_items->indexOf(curItem);
642 if (m_itemsCurIndex == -1) {
643 if (m_itemsPrevIndex == 0) {
644 verticalScrollBar()->setValue(qMax(0, prevCellIndex - 1));
652 viewport()->update();
658 else if (key == Qt::Key_Down && event->modifiers() == Qt::ShiftModifier) {
660 m_lastShiftArrowSelectedCell->first : m_activeCell->first;
662 int prevCellIndex =
getModel()->indexOfVisibleItem(prevCell);
664 if (prevCellIndex >= 0 &&
665 prevCellIndex <
getModel()->getVisibleRowCount() - 1) {
666 QList< AbstractTreeItem * > itemList =
667 getModel()->getItems(prevCellIndex + 1, prevCellIndex + 2);
669 if (itemList.size()) {
673 curItem == m_activeCell->first)
678 if (curItem == m_activeCell->first)
679 m_lastShiftArrowSelectedCell->first = NULL;
681 m_lastShiftArrowSelectedCell->first = curItem;
682 m_lastShiftArrowSelectedCell->second = m_activeCell->second;
683 viewport()->update();
686 int m_itemsPrevIndex = m_items->indexOf(prevCell);
687 int m_itemsCurIndex = m_items->indexOf(curItem);
688 if (m_itemsCurIndex == -1) {
689 if (m_itemsPrevIndex == m_items->size() - 1) {
690 int visibleItemCount =
getModel()->getVisibleRowCount();
691 verticalScrollBar()->setValue(qMin(visibleItemCount,
692 getModel()->indexOfVisibleItem(m_items->at(1))));
704 else if (key == Qt::Key_Up) {
709 else if (key == Qt::Key_Down) {
714 else if (key == Qt::Key_Left) {
719 else if (key == Qt::Key_Right) {
729 if (!m_items->contains(m_activeCell->first))
732 if (m_items->contains(m_activeCell->first) &&
734 m_activeCell->second)) {
737 m_columns->getVisibleColumns()[m_activeCell->second];
741 m_editWidget = delegate->getWidget(col);
742 delegate->readData(m_editWidget, m_activeCell->first, col, event->text());
743 m_editWidget->setParent(
this);
744 m_editWidget->setFocus(Qt::OtherFocusReason);
747 viewport()->update();
759 m_columns->getVisibleColumns()[m_activeCell->second];
760 getModel()->getDelegate()->saveData(
761 m_editWidget, m_activeCell->first, col);
766 setFocus(Qt::ActiveWindowFocusReason);
775 int activeIndex = m_items->indexOf(m_activeCell->first);
776 if (activeIndex != -1) {
777 if (activeIndex == 0) {
778 int row = qMax(0,
getModel()->indexOfVisibleItem(
779 m_activeCell->first) - 1);
781 verticalScrollBar()->setValue(row);
784 m_activeCell->first = (*m_items)[qMax(0, activeIndex - 1)];
786 viewport()->update();
795 int activeIndex = m_items->indexOf(m_activeCell->first);
796 if (activeIndex != -1) {
797 if (activeIndex == m_items->size() - 1) {
798 int row = qMin(
getModel()->getVisibleRowCount() - 1,
799 getModel()->indexOfVisibleItem(m_items->at(0)));
801 verticalScrollBar()->setValue(row + 1);
802 activeIndex = m_items->indexOf(m_activeCell->first);
805 m_activeCell->first = (*m_items)[qMin(activeIndex + 1, m_items->size() - 1)];
807 viewport()->update();
816 m_activeCell->second = qMax(1, m_activeCell->second - 1);
818 if (leftMostVisibleCol == m_activeCell->second) {
819 horizontalScrollBar()->setValue(horizontalScrollBar()->value() -
820 m_columns->getVisibleColumns()[m_activeCell->second]->getWidth());
824 viewport()->update();
832 m_activeCell->second = qMin(m_columns->getVisibleColumns().size() - 1,
833 m_activeCell->second + 1);
835 if (rightMostVisibleCol == m_activeCell->second) {
836 horizontalScrollBar()->setValue(horizontalScrollBar()->value() +
837 m_columns->getVisibleColumns()[m_activeCell->second]->getWidth());
841 viewport()->update();
851 if (m_model && m_columns) {
853 int rowCount = (int) ceil(viewport()->height() / (double) m_rowHeight);
855 QPainter painter(viewport());
856 painter.setRenderHint(QPainter::Antialiasing,
false);
859 bool editWidgetVisible =
false;
860 for (
int i = 0; i < rowCount; i++) {
862 QPoint relativeTopLeft(0, i * m_rowHeight);
863 QPoint scrollBarPos(horizontalScrollBar()->value(),
864 verticalScrollBar()->value());
865 QPoint absoluteTopLeft(relativeTopLeft + scrollBarPos);
866 QSize rowSize(viewport()->width(), (
int) m_rowHeight);
869 painter.fillRect(QRect(relativeTopLeft, rowSize), palette().base());
871 if (i < m_items->size()) {
911 if (m_items->at(i)->isSelected()) {
912 QPoint selectionTopLeft(-absoluteTopLeft.x(), relativeTopLeft.y());
913 QSize selectionSize(m_columns->getVisibleWidth(), (
int) m_rowHeight);
915 QRect selectionRect(selectionTopLeft, selectionSize);
916 painter.fillRect(selectionRect, palette().highlight().color());
919 paintRow(&painter, i, absoluteTopLeft, relativeTopLeft);
923 for (
int i = 0; i < rowCount; i++) {
924 if (i < m_items->size()) {
925 QPoint relativeTopLeft(0, i * m_rowHeight);
926 if (m_editWidget && m_activeCell->first == m_items->at(i)) {
927 QPair<int, int> xRange(
931 QPoint(xRange.first - horizontalScrollBar()->value() - 1,
932 relativeTopLeft.y() + 1));
933 m_editWidget->resize(xRange.second - xRange.first, m_rowHeight + 1);
934 m_editWidget->setVisible(
true);
935 editWidgetVisible =
true;
938 if (m_activeCell->first == m_items->at(i)) {
939 QPair<int, int> activeXArea =
942 QRect activeArea(activeXArea.first, relativeTopLeft.y(),
943 activeXArea.second - activeXArea.first, m_rowHeight);
946 activeArea.left() - horizontalScrollBar()->value());
947 activeArea.adjust(-1, -1, -2, -1);
951 painter.drawRect(activeArea);
957 if (m_editWidget && !editWidgetVisible)
958 m_editWidget->setVisible(
false);
961 QWidget::paintEvent(event);
972 QAbstractScrollArea::resizeEvent(event);
985 QAbstractScrollArea::scrollContentsBy(dx, dy);
998 m_lastShiftArrowSelectedCell = NULL;
1001 m_lastShiftSelection = NULL;
1017 if (col->hasNetworkStructureEffect())
1018 emit rebuildModels(QList< AbstractTreeItem * >());
1020 emit modelDataChanged();
1028 m_activeCell->first = NULL;
1029 m_activeCell->second = -1;
1037 m_lastShiftArrowSelectedCell->first = NULL;
1049 TableColumn *col = m_columns->getVisibleColumns()[m_activeCell->second];
1051 QString colTitle = col->getTitle();
1055 QString cellData = m_activeCell->first->getFormattedData(colTitle);
1057 QList< AbstractTreeItem * > selection = allCells ? m_model->getItems(
1060 bool needsDialog =
true;
1062 for (
int i = 0; !done && i < selection.size(); i++) {
1064 bool changeData =
true;
1066 QString warningText =
1067 m_model->getWarningMessage(row, col, cellData);
1068 if (needsDialog && warningText.size()) {
1069 QMessageBox::StandardButton status = QMessageBox::warning(
1070 this,
"Change cells?", warningText, QMessageBox::Yes |
1071 QMessageBox::No | QMessageBox::YesToAll | QMessageBox::NoToAll);
1074 case QMessageBox::YesToAll:
1075 needsDialog =
false;
1077 case QMessageBox::NoToAll:
1079 case QMessageBox::No:
1087 row->setData(colTitle, cellData);
1090 viewport()->update();
1107 m_applyToAllAct->setStatusTip(tr(
"Copy the contents of this cell to all"
1108 "cells in the current column"));
1114 tr(
"Delete the currently selected rows"));
1120 tr(
"Edit the selected control point or the parent control point of control measure"));
1135 for (
int i = 0; i < m_columns->getVisibleColumns().size(); i++) {
1137 int deltaX = -horizontalScrollBar()->value();
1139 if (cellXRange.first + deltaX < screenX &&
1140 cellXRange.second + deltaX > screenX) {
1157 int calculatedRowNum = screenY / m_rowHeight;
1159 if (calculatedRowNum >= 0 && calculatedRowNum < m_items->size() &&
1160 screenY >= 0 && screenY <= viewport()->height())
1161 return calculatedRowNum;
1173 return (m_activeCell->first && m_activeCell->second >= 0);
1183 return (m_model->getSelectedItems().size());
1199 m_activeCell->second == colNum);
1213 return (m_model->getSelectedItems().contains(row));
1227 if (rowNum >= 0 && rowNum < m_items->size())
1244 if (colNum >= 0 && colNum < m_columns->getVisibleColumns().size())
1261 bool editable =
false;
1263 QString colName = m_columns->getVisibleColumns()[colNum]->getTitle();
1264 if (m_items->at(rowNum)->isSelectable() &&
1265 m_items->at(rowNum)->isDataEditable(colName) &&
1266 !m_columns->getVisibleColumns()[colNum]->isReadOnly())
1282 return m_columns->getVisibleColumns()[colNum]->getTitle().size();
1295 QPoint absolutePosition, QPoint relativePosition) {
1297 QPoint point(-absolutePosition.x(), relativePosition.y());
1303 QPen originalPen = painter->pen();
1305 QPoint textPoint(point.x() + ITEM_INDENTATION,
1306 point.y() + ITEM_PADDING / 2);
1309 int textHeight = m_rowHeight - ITEM_PADDING;
1311 QFontMetrics metrics(font());
1313 QPen gridPen(Qt::gray);
1316 for (
int i = 0; i < visibleCols.size(); i++) {
1318 QPair<int, int> cellXRange(visibleCols.getVisibleXRange(i));
1319 QRect cellRect(cellXRange.first, point.y(),
1320 cellXRange.second - cellXRange.first, m_rowHeight);
1321 cellRect.moveLeft(cellRect.left() - horizontalScrollBar()->value() - 1);
1323 QString columnTitle = visibleCols[i]->getTitle();
1324 QRect textRect(textPoint, QSize(cellRect.right() - textPoint.x(),
1327 bool textCentered =
false;
1328 if (!columnTitle.isEmpty()) {
1329 text = item->getFormattedData(columnTitle);
1332 m_activeCell->second == i) {
1334 if (m_activeCell->first != item) {
1335 painter->fillRect(cellRect,
1336 QBrush(palette().highlight().color()));
1337 painter->setPen(palette().highlightedText().color());
1340 painter->setPen(palette().text().color());
1344 if (item->isSelected()) {
1345 painter->setPen(palette().highlightedText().color());
1358 painter->setPen(palette().color(QPalette::Disabled,
1362 painter->setPen(palette().text().color());
1369 text = QString::number(rowNum + verticalScrollBar()->value() + 1);
1370 textCentered =
true;
1373 int x = cellRect.center().x();
1374 QLinearGradient gradient(x, cellRect.top(), x, cellRect.bottom());
1376 bool selected = item->isSelected();
1377 QColor color = selected ? palette().highlight().color() :
1378 palette().button().color();
1380 int adjustment = 110;
1381 gradient.setColorAt(0, color.lighter(adjustment));
1382 gradient.setColorAt(1, color.darker(adjustment));
1383 painter->fillRect(cellRect, gradient);
1385 painter->setPen(palette().highlightedText().color());
1387 painter->setPen(palette().text().color());
1390 int flags = Qt::TextDontClip;
1392 flags |= Qt::AlignCenter;
1396 QFont normalFont = painter->font();
1398 if (item->getPointerType() == AbstractTreeItem::Measure) {
1400 if (cm && cm->Parent() && cm->Parent()->GetRefMeasure() == cm) {
1401 QFont boldFont(normalFont);
1402 boldFont.setBold(
true);
1403 painter->setFont(boldFont);
1407 painter->drawText(textRect, flags,
1408 metrics.elidedText(text, Qt::ElideRight,
1409 textRect.width() - ITEM_INDENTATION));
1410 painter->setFont(normalFont);
1412 textPoint.setX(cellRect.right() + ITEM_INDENTATION);
1413 painter->setPen(originalPen);
1415 painter->setPen(gridPen);
1416 painter->drawLine(QPoint(cellRect.right(), point.y()),
1417 QPoint(cellRect.right(), point.y() + m_rowHeight));
1418 painter->setPen(originalPen);
1421 int left = -horizontalScrollBar()->value() - 1;
1422 int right = m_columns->getVisibleWidth();
1424 gridPen.setWidth(2);
1425 painter->setPen(gridPen);
1426 painter->drawLine(QPoint(left, point.y() + m_rowHeight),
1427 QPoint(right, point.y() + m_rowHeight));
1428 painter->setPen(originalPen);
1439 if (m_editWidget && m_activeCell->first && m_activeCell->second >= 0) {
1442 m_columns->getVisibleColumns()[m_activeCell->second];
1443 m_model->getDelegate()->saveData(m_editWidget, m_activeCell->first,
1449 QMessageBox::critical(
this,
"Failed to Set Data", e.what());
1454 int oldActiveColumn = m_activeCell->second;
1462 for (
int i = 0; i < visibleCols.size(); i++) {
1464 QRect cellRect(cellXRange.first, m_rowHeight * rowNum,
1465 cellXRange.second - cellXRange.first, m_rowHeight);
1467 cellRect.moveLeft(cellRect.left() - horizontalScrollBar()->value());
1469 if (cellRect.contains(screenPos) &&
1470 (oldActiveColumn != -1 || !visibleCols[i]->getTitle().isEmpty())) {
1471 m_activeCell->first = item;
1472 m_activeCell->second = i;
1477 if (oldActiveColumn != m_activeCell->second) {
1500 *m_lastShiftSelection = m_model->getItems(
1504 m_lastShiftSelection->clear();
1523 if (row->getPointerType() == AbstractTreeItem::Point)
1525 child->setSelected(
false);
1527 if (row->getPointerType() == AbstractTreeItem::Measure)
1528 row->parent()->setSelected(
false);
1530 row->setSelected(
false);
1534 *m_lastShiftSelection = m_model->getItems(
1538 m_lastShiftSelection->clear();
1541 QList< AbstractTreeItem * > newlySelectedItems;
1543 row->setSelected(
true);
1545 if (row->getPointerType() == AbstractTreeItem::Measure)
1546 row->parent()->setSelected(
true);
1548 newlySelectedItems.append(row);
1551 return newlySelectedItems;
1580 QMessageBox::StandardButton status = QMessageBox::warning(
1581 this,
"Delete row(s)?",
"Delete selected row(s)?",
1582 QMessageBox::Yes | QMessageBox::No);
1584 if (status == QMessageBox::Yes) {
1586 QList<AbstractTreeItem *> selectedRows = m_model->getSelectedItems();
1588 emit rebuildModels(selectedRows);
1589 emit modelDataChanged();
1591 m_lastShiftSelection->clear();
1602 QString serialNumber;
1606 if (m_model->getSelectedItems().count() == 0) {
1607 item = m_activeCell->first;
1615 if (item->getPointerType() == AbstractTreeItem::Point) {
1621 serialNumber = item->getData(
"Image ID").toString();
1636 int startRow = verticalScrollBar()->value();
1637 int rowCount = (int) ceil(viewport()->height() / (double) m_rowHeight);
1640 m_model->getItems(startRow, startRow + rowCount)) {
1641 m_items->append(item);
1644 viewport()->update();
1655 QMenu contextMenu(
this);
1660 QList<AbstractTreeItem *> selectedRows = m_model->getSelectedItems();
1666 if (QApplication::applicationName() !=
"cneteditor") {
1667 if (m_activeControlNet) {
1713 contextMenu.exec(mapToGlobal(mouseLocation));
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.
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.