54 #include "ui_groups_widget.h"
55 #include "../core/vapplication.h"
56 #include "../vtools/tools/vabstracttool.h"
57 #include "../vtools/dialogs/tools/dialogtool.h"
58 #include "../vtools/dialogs/tools/editgroup_dialog.h"
59 #include "../vtools/undocommands/delgroup.h"
60 #include "../vtools/undocommands/addgroup.h"
61 #include "../vtools/undocommands/add_groupitem.h"
62 #include "../vtools/undocommands/remove_groupitem.h"
63 #include "../vtools/undocommands/move_groupitem.h"
64 #include "../vtools/tools/vabstracttool.h"
65 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutspline.h"
66 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutsplinepath.h"
67 #include "../vtools/tools/drawTools/toolpoint/toolsinglepoint/toolcut/vtoolcutarc.h"
68 #include "../vgeometry/vabstractarc.h"
69 #include "../vgeometry/varc.h"
70 #include "../vgeometry/vellipticalarc.h"
71 #include "../vgeometry/vcubicbezier.h"
72 #include "../vgeometry/vsplinepath.h"
73 #include "../vgeometry/vcubicbezierpath.h"
74 #include "../vgeometry/vpointf.h"
75 #include "../vpatterndb/vcontainer.h"
76 #include "../vwidgets/group_tablewidgetitem.h"
77 #include "../vwidgets/vabstractmainwindow.h"
78 #include "../vmisc/vabstractapplication.h"
79 #include "../vmisc/vsettings.h"
80 #include "../vmisc/vcommonsettings.h"
81 #include "../vmisc/logging.h"
82 #include "../ifc/ifcdef.h"
83 #include "../ifc/xml/vabstractpattern.h"
86 #include <QApplication>
89 #include <QListWidget>
90 #include <QListWidgetItem>
92 #include <QMessageBox>
93 #include <QMetaObject>
96 #include <QScopedPointer>
98 #include <QTableWidget>
101 Q_LOGGING_CATEGORY(WidgetGroups,
"vwidgetgroups")
109 , m_patternHasGroups(false)
110 , m_currentGroupId(0)
115 ui->groups_Splitter->restoreState(settings.value(
"splitterSizes").toByteArray());
117 fillTable(m_doc->getGroups());
118 ui->groups_TableWidget->sortItems(settings.value(
"groupSort", 4).toInt(), Qt::AscendingOrder);
136 ui->groups_TableWidget->setContextMenuPolicy(Qt::CustomContextMenu);
139 ui->groupItems_ListWidget->setContextMenuPolicy(Qt::CustomContextMenu);
156 if (column != 0)
return;
158 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, column);
159 const quint32 groupId = item->data(Qt::UserRole).toUInt();
176 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, column);
178 const quint32 groupId = item->data(Qt::UserRole).toUInt();
183 item->setIcon(QIcon(
"://icon/32x32/lock_on.png"));
187 item->setIcon(QIcon(
"://icon/32x32/lock_off.png"));
199 const quint32 groupId =
ui->groups_TableWidget->item(row, 0)->data(Qt::UserRole).toUInt();
211 for (i = groups.constBegin(); i != groups.constEnd(); ++i)
213 for (
int j = 0; j <
ui->groups_TableWidget->rowCount(); ++j)
215 QTableWidgetItem *item =
ui->groups_TableWidget->item(j, 0);
218 quint32 groupId = item->data(Qt::UserRole).toUInt();
219 if (groupId == i.key())
231 qCDebug(WidgetGroups,
"Show All Groups");
234 for (
int i = 0; i <
ui->groups_TableWidget->rowCount(); ++i)
236 QTableWidgetItem *item =
ui->groups_TableWidget->item(i, 0);
241 groupId = item->data(Qt::UserRole).toUInt();
243 if (item && locked ==
false)
252 qCDebug(WidgetGroups,
"Hide All Groups");
255 for (
int row = 0; row <
ui->groups_TableWidget->rowCount(); ++row)
257 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, 0);
262 groupId = item->data(Qt::UserRole).toUInt();
264 if (item && locked ==
false)
273 qCDebug(WidgetGroups,
"Lock All Groups");
274 for (
int row = 0; row <
ui->groups_TableWidget->rowCount(); ++row)
276 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, 1);
281 const quint32 groupId = item->data(Qt::UserRole).toUInt();
283 item->setIcon(QIcon(
"://icon/32x32/lock_on.png"));
289 qCDebug(WidgetGroups,
"Unlock All Groups");
290 for (
int row = 0; row <
ui->groups_TableWidget->rowCount(); ++row)
292 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, 1);
297 const quint32 groupId = item->data(Qt::UserRole).toUInt();
299 item->setIcon(QIcon(
"://icon/32x32/lock_off.png"));
312 const bool result = dialog->exec();
313 groupName = dialog->getName();
314 if (result ==
false || groupName.isEmpty())
324 QMessageBox messageBox;
325 messageBox.setWindowTitle(tr(
"Name Exists"));
326 messageBox.setIcon(QMessageBox::Warning);
327 messageBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel);
328 messageBox.setDefaultButton(QMessageBox::Retry);
329 messageBox.setText(tr(
"The action can't be completed because the group name already exists."));
330 int boxResult = messageBox.exec();
334 case QMessageBox::Retry:
336 case QMessageBox::Cancel:
344 qCDebug(WidgetGroups,
"Group Name = %s", qUtf8Printable(groupName));
345 qCDebug(WidgetGroups,
"Next Id = %d", nextId);
347 const QDomElement group =
m_doc->
createGroup(nextId, groupName, dialog->getColor(), dialog->getLineType(),
348 dialog->getLineWeight(), dialog->getGroupData());
352 qCDebug(WidgetGroups,
"Add a Group to List");
355 qApp->getUndoStack()->push(command);
362 qCDebug(WidgetGroups,
"Remove Group %d from List", groupId);
364 QTableWidgetItem *item =
ui->groups_TableWidget->currentItem();
370 if (item && (locked ==
false))
374 qApp->getUndoStack()->push(command);
380 ui->groups_TableWidget->blockSignals(
true);
381 qCDebug(WidgetGroups,
"Edit Group List");
382 const int row =
ui->groups_TableWidget->currentRow();
383 if (
ui->groups_TableWidget->rowCount() == 0 || row == -1 || row >=
ui->groups_TableWidget->rowCount())
385 ui->groups_TableWidget->blockSignals(
false);
389 const quint32 groupId =
ui->groups_TableWidget->item(row, 0)->data(Qt::UserRole).toUInt();
394 qCDebug(WidgetGroups,
"Row = %d", row);
398 dialog->setName(oldGroupName);
402 dialog->setWindowTitle(tr(
"Edit Group"));
407 const bool result = dialog->exec();
408 groupName = dialog->getName();
409 if (result ==
false || groupName.isEmpty())
411 ui->groups_TableWidget->blockSignals(
false);
415 if (exists ==
false || groupName == oldGroupName)
420 QMessageBox messageBox;
421 messageBox.setWindowTitle(tr(
"Name Exists"));
422 messageBox.setIcon(QMessageBox::Warning);
423 messageBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel);
424 messageBox.setDefaultButton(QMessageBox::Retry);
425 messageBox.setText(tr(
"The action can't be completed because the group name already exists."));
426 int boxResult = messageBox.exec();
430 case QMessageBox::Retry:
432 case QMessageBox::Cancel:
439 const QString groupColor = dialog->getColor();
440 const QString groupLineType = dialog->getLineType();
441 const QString groupLineWeight = dialog->getLineWeight();
443 QTableWidgetItem *item =
ui->groups_TableWidget->item(row, 3);
444 item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
445 item->setSizeHint(QSize(20, 20));
446 QPixmap pixmap(20, 20);
447 pixmap.fill(QColor(groupColor));
448 item->setIcon(QIcon(pixmap));
449 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
450 item->setToolTip(tr(
"Group color"));
451 ui->groups_TableWidget->setItem(row, 3, item);
453 item =
ui->groups_TableWidget->item(row, 4);
454 item->setText(groupName);
463 ui->groups_TableWidget->blockSignals(
false);
469 ui->groups_TableWidget->setSortingEnabled(
false);
470 ui->groups_TableWidget->blockSignals(
true);
472 QTableWidgetItem *item =
ui->groups_TableWidget->itemAt(pos);
478 const int row = item->row();
479 item =
ui->groups_TableWidget->item(row, 0);
480 const quint32 groupId = item->data(Qt::UserRole).toUInt();
488 QScopedPointer<QMenu> menu(
new QMenu());
489 QAction *actionRename = menu->addAction(QIcon(
"://icon/32x32/rename_32"), tr(
"Rename"));
490 QAction *actionDelete = menu->addAction(QIcon::fromTheme(
"edit-delete"), tr(
"Delete"));
491 QAction *selectedAction = menu->exec(
ui->groups_TableWidget->viewport()->mapToGlobal(pos));
492 if(selectedAction ==
nullptr)
496 else if (selectedAction == actionRename)
505 dialog->setWindowTitle(tr(
"Edit Group"));
510 const bool result = dialog->exec();
511 groupName = dialog->getName();
512 if (result ==
false || groupName.isEmpty())
517 if (exists ==
false || groupName == oldGroupName)
522 QMessageBox messageBox;
523 messageBox.setWindowTitle(tr(
"Name Exists"));
524 messageBox.setIcon(QMessageBox::Warning);
525 messageBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Cancel);
526 messageBox.setDefaultButton(QMessageBox::Retry);
527 messageBox.setText(tr(
"The action can't be completed because the group name already exists."));
528 int boxResult = messageBox.exec();
532 case QMessageBox::Retry:
534 case QMessageBox::Cancel:
541 const QString groupColor = dialog->getColor();
542 const QString groupLineType = dialog->getLineType();
543 const QString groupLineWeight = dialog->getLineWeight();
545 item =
ui->groups_TableWidget->item(row, 3);
546 item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
547 item->setSizeHint(QSize(20, 20));
548 QPixmap pixmap(20, 20);
549 pixmap.fill(QColor(groupColor));
550 item->setIcon(QIcon(pixmap));
551 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
552 item->setToolTip(tr(
"Group color"));
553 ui->groups_TableWidget->setItem(row, 3, item);
555 item =
ui->groups_TableWidget->item(row, 4);
556 item->setText(groupName);
562 else if (selectedAction == actionDelete)
566 qApp->getUndoStack()->push(command);
569 ui->groups_TableWidget->setSortingEnabled(
true);
570 ui->groups_TableWidget->blockSignals(
false);
577 int row =
ui->groups_TableWidget->currentRow();
579 if (
ui->groups_TableWidget->rowCount() != 0 || row != -1 || row <= ui->groups_TableWidget->rowCount())
581 ui->groups_TableWidget->selectRow(row);
589 ui->groups_TableWidget->blockSignals(
true);
590 ui->groups_TableWidget->clear();
591 ui->groups_TableWidget->setColumnCount(5);
592 ui->groups_TableWidget->setRowCount(groups.size());
593 ui->groups_TableWidget->setSortingEnabled(
false);
595 qint32 currentRow = -1;
596 auto i = groups.constBegin();
597 while (i != groups.constEnd())
604 item->setTextAlignment(Qt::AlignHCenter);
605 item->setSizeHint(QSize(20, 20));
609 item->setData(Qt::UserRole, i.key());
610 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
611 item->setToolTip(tr(
"Show which groups in the list are visible"));
612 ui->groups_TableWidget->setItem(currentRow, 0, item);
616 item->setTextAlignment(Qt::AlignHCenter);
617 item->setSizeHint(QSize(20, 20));
618 item->setIcon(data.
locked ? QIcon(
"://icon/32x32/lock_on.png") : QIcon(
"://icon/32x32/lock_off.png"));
619 item->setData(Qt::UserRole, i.key());
620 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
621 item->setToolTip(tr(
"Show which groups in the list are locked"));
622 ui->groups_TableWidget->setItem(currentRow, 1, item);
626 item->setTextAlignment(Qt::AlignHCenter);
627 item->setIcon(!
m_doc->
isGroupEmpty(i.key()) ? QIcon(
"://icon/32x32/history.png") : QIcon());
628 item->setData(Qt::UserRole, i.key());
629 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
630 item->setToolTip(tr(
"Show which groups contain objects"));
631 ui->groups_TableWidget->setItem(currentRow, 2, item);
635 item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
636 item->setSizeHint(QSize(20, 20));
637 QPixmap pixmap(20, 20);
638 pixmap.fill(QColor(data.
color));
639 item->setIcon(QIcon(pixmap));
640 item->setData(Qt::UserRole, data.
color);
641 item->setFlags(item->flags() &= ~(Qt::ItemIsEditable));
642 item->setToolTip(tr(
"Group color"));
643 ui->groups_TableWidget->setItem(currentRow, 3, item);
646 QTableWidgetItem *nameItem =
new QTableWidgetItem(data.
name);
647 nameItem->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
648 nameItem->setToolTip(tr(
"Group name"));
649 ui->groups_TableWidget->setItem(currentRow, 4, nameItem);
654 ui->groups_TableWidget->setHorizontalHeaderItem(0,
new QTableWidgetItem(
makeHeaderName(QString(
"Visible"))));
655 ui->groups_TableWidget->setHorizontalHeaderItem(1,
new QTableWidgetItem(
makeHeaderName(QString(
"Locked"))));
656 ui->groups_TableWidget->setHorizontalHeaderItem(2,
new QTableWidgetItem(
makeHeaderName(QString(
"Objects"))));
657 ui->groups_TableWidget->setHorizontalHeaderItem(3,
new QTableWidgetItem(
makeHeaderName(QString(
"Color"))));
658 ui->groups_TableWidget->setHorizontalHeaderItem(4,
new QTableWidgetItem(tr(
"Name")));
659 ui->groups_TableWidget->horizontalHeaderItem(4)->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter);
660 ui->groups_TableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed);
661 ui->groups_TableWidget->resizeColumnsToContents();
662 ui->groups_TableWidget->resizeRowsToContents();
663 ui->groups_TableWidget->setSortingEnabled(
true);
664 ui->groups_TableWidget->blockSignals(
false);
671 ui->showAllGroups_ToolButton->setEnabled(value);
672 ui->hideAllGroups_ToolButton->setEnabled(value);
673 ui->lockAllGroups_ToolButton->setEnabled(value);
674 ui->unlockAllGroups_ToolButton->setEnabled(value);
675 ui->deleteGroup_ToolButton->setEnabled(value);
676 ui->editGroup_ToolButton->setEnabled(value);
677 qCDebug(WidgetGroups,
"Draft Block Has Groups = %d", value);
682 ui->addGroup_ToolButton->setEnabled(value);
687 ui->groups_TableWidget->setRowCount(0);
688 ui->groups_TableWidget->clearContents();
689 ui->groupItems_ListWidget->clear();
694 QTableWidgetItem *item =
ui->groups_TableWidget->currentItem();
699 int row =
ui->groups_TableWidget->row(item);
700 qCDebug(WidgetGroups,
"Row = %d\n", row);
701 const quint32 groupId =
ui->groups_TableWidget->item(row, 0)->data(Qt::UserRole).toUInt();
707 QTableWidgetItem *item =
ui->groups_TableWidget->currentItem();
712 int row =
ui->groups_TableWidget->row(item);
713 qCDebug(WidgetGroups,
"Row = %d\n", row);
714 const QString groupName =
ui->groups_TableWidget->item(row, 4)->text();
720 ui->groupItems_ListWidget->blockSignals(
true);
721 ui->groupItems_ListWidget->clear();
724 if (groupDomElement.isNull())
731 if (!groupData.isEmpty())
733 auto i = groupData.begin();
734 while (i != groupData.end())
736 quint32 toolId = i.value();
737 quint32 objId = i.key();
738 Tool tooltype = history.value(toolId);
743 ui->groupItems_ListWidget->sortItems(Qt::AscendingOrder);
744 ui->groupItems_ListWidget->blockSignals(
false);
749 QT_WARNING_DISABLE_GCC(
"-Wswitch-default")
756 void
GroupsWidget::addGroupItem(const quint32 &toolId, const quint32 &objId, const
Tool &tooltype)
761 QString iconFileName =
"";
762 QString objName = tr(
"Unknown Object");
763 const QDomElement domElement = m_doc->elementById(toolId);
764 if (domElement.isElement() ==
false)
766 qDebug()<<
"Can't find element by id"<<Q_FUNC_INFO;
786 iconFileName =
":/toolicon/32x32/point_basepoint_icon.png";
787 objName = tr(
"%1 - Base point").arg(getPointName(toolId));
791 iconFileName =
":/toolicon/32x32/segment.png";
792 objName = tr(
"%1 - Point Length and Angle").arg(getPointName(toolId));
796 iconFileName =
":/toolicon/32x32/line.png";
797 objName = tr(
"Line %1_%2")
803 iconFileName =
":/toolicon/32x32/along_line.png";
804 objName = tr(
"%1 - Point On Line").arg(getPointName(toolId));
808 iconFileName =
":/toolicon/32x32/shoulder.png";
809 objName = tr(
"%1 - Point Length to Line").arg(getPointName(toolId));
813 iconFileName =
":/toolicon/32x32/normal.png";
814 objName = tr(
"%1 - Point On Perpendicular").arg(getPointName(toolId));
818 iconFileName =
":/toolicon/32x32/bisector.png";
819 objName = tr(
"%1 - Point On Bisector").arg(getPointName(toolId));
823 iconFileName =
":/toolicon/32x32/intersect.png";
824 objName = tr(
"%1 - Point Intersect Lines").arg(getPointName(toolId));
831 iconFileName =
":/toolicon/32x32/spline.png";
832 objName = tr(
"%1 - Curve Interactive").arg(spl->NameForHistory(tr(
"Spl_")));
840 iconFileName =
":/toolicon/32x32/cubic_bezier.png";
841 objName = tr(
"%1 - Curve Fixed").arg(spl->NameForHistory(tr(
"Spl_")));
849 iconFileName =
":/toolicon/32x32/arc.png";
850 objName = tr(
"%1 - Arc Radius & Angles").arg(arc->NameForHistory(tr(
"Arc_")));
858 iconFileName =
":/toolicon/32x32/arc_with_length.png";
859 objName = tr(
"%1 - Arc Radius & Length").arg(arc->NameForHistory(tr(
"Arc_")));
867 iconFileName =
":/toolicon/32x32/splinePath.png";
868 objName = tr(
"%1 - Spline Interactive").arg(
splPath->NameForHistory(tr(
"SplPath_")));
876 iconFileName =
":/toolicon/32x32/cubic_bezier_path.png";
877 objName = tr(
"%1 - Spline Fixed").arg(
splPath->NameForHistory(tr(
"SplPath_")));
882 iconFileName =
":/toolicon/32x32/point_of_contact.png";
883 objName = tr(
"%1 - Point Intersect Arc & Line").arg(getPointName(toolId));
887 iconFileName =
":/toolicon/32x32/height.png";
888 objName = tr(
"%1 - Point Intersect Line & Perpendicular").arg(getPointName(toolId));
892 iconFileName =
":/toolicon/32x32/triangle.png";
893 objName = tr(
"%1 - Point Intersect Axis & Triangle").arg(getPointName(toolId));
897 iconFileName =
":/toolicon/32x32/point_intersectxy_icon.png";
898 objName = tr(
"%1 - Point Intersect XY").arg(getPointName(toolId));
905 iconFileName =
":/toolicon/32x32/arc_cut.png";
906 objName = tr(
"%1 - Point On Arc").arg(getPointName(toolId));
916 iconFileName =
":/toolicon/32x32/spline_cut_point.png";
917 objName = tr(
"%1 - Point On Curve").arg(getPointName(toolId));
927 iconFileName =
":/toolicon/32x32/splinePath_cut_point.png";
928 objName = tr(
"%1 - Point On Spline").arg(getPointName(toolId));
933 iconFileName =
":/toolicon/32x32/line_intersect_axis.png";
934 objName = tr(
"%1 - Point Intersect Line & Axis").arg(getPointName(toolId));
938 iconFileName =
":/toolicon/32x32/arc_intersect_axis.png";
939 objName = tr(
"%1 - Point Intersect Curve & Axis").arg(getPointName(toolId));
943 iconFileName =
":/toolicon/32x32/point_of_intersection_arcs.png";
944 objName = tr(
"%1 - Point Intersect Arcs").arg(getPointName(toolId));
948 iconFileName =
":/toolicon/32x32/point_of_intersection_circles.png";
949 objName = tr(
"%1 - Point Intersect Circles").arg(getPointName(toolId));
953 iconFileName =
":/toolicon/32x32/intersection_curves.png";
954 objName = tr(
"%1 - Point Intersect Curves").arg(getPointName(toolId));
958 iconFileName =
":/toolicon/32x32/point_from_circle_and_tangent.png";
959 objName = tr(
"%1 - Point Intersect Circle & Tangent").arg(getPointName(toolId));
963 iconFileName =
":/toolicon/32x32/point_from_arc_and_tangent.png";
964 objName = tr(
"%1 - Point Intersect Arc & Tangent").arg(getPointName(toolId));
968 iconFileName =
":/toolicon/32x32/true_darts.png";
969 objName = tr(
"%1 - True Dart %2_%3_%4")
970 .arg(getObjName(objId))
971 .arg(getPointName(attrUInt(domElement,
AttrDartP1)))
972 .arg(getPointName(attrUInt(domElement,
AttrDartP2)))
973 .arg(getPointName(attrUInt(domElement,
AttrDartP3)));
980 iconFileName =
":/toolicon/32x32/el_arc.png";
981 objName = tr(
"%1 - Arc Elliptical").arg(elArc->NameForHistory(tr(
"ElArc_")));
987 iconFileName =
":/toolicon/32x32/rotation.png";
988 objName = tr(
"%1 - Rotation")
989 .arg(getObjName(objId ==
NULL_ID ? toolId : objId));
996 iconFileName =
":/toolicon/32x32/move.png";
997 objName = tr(
"%1 - Move")
998 .arg(getObjName(objId ==
NULL_ID ? toolId : objId));
1005 iconFileName =
":/toolicon/32x32/mirror_by_line.png";
1006 objName = tr(
"%1 - Mirror by Line")
1007 .arg(getObjName(objId ==
NULL_ID ? toolId : objId));
1014 iconFileName =
":/toolicon/32x32/mirror_by_axis.png";
1015 objName = tr(
"%1 - Mirror by Axis")
1016 .arg(getObjName(objId ==
NULL_ID ? toolId : objId));
1034 itemData.append(objId);
1035 itemData.append(toolId);
1037 QListWidgetItem *item =
new QListWidgetItem(objName);
1038 item->setIcon(QIcon(iconFileName));
1039 item->setData(Qt::UserRole, QVariant::fromValue(itemData));
1040 ui->groupItems_ListWidget->addItem(item);
1047 itemData.append(objId);
1048 itemData.append(toolId);
1051 QListWidgetItem *item =
new QListWidgetItem(objName);
1052 item->setIcon(QIcon(
":/icons/win.icon.theme/16x16/status/dialog-warning.png"));
1053 item->setData(Qt::UserRole, QVariant::fromValue(itemData));
1054 ui->groupItems_ListWidget->addItem(item);
1099 qCDebug(WidgetGroups,
"Error! Couldn't get object name by id = %s. %s %s", qUtf8Printable(QString().setNum(toolId)),
1102 return QString(
"Unknown Object");
1114 const int row =
ui->groupItems_ListWidget->currentRow();
1115 if (
ui->groupItems_ListWidget->count() == 0 || row == -1 || row >=
ui->groupItems_ListWidget->count())
1120 QListWidgetItem *rowItem =
ui->groupItems_ListWidget->item(row);
1123 const quint32 toolId = itemData.last();
1124 const quint32 objId = itemData.first();
1129 QActionGroup *actionMoveGroupMenu=
new QActionGroup(
this);
1131 if(!groupsNotContainingItem.empty())
1133 QMenu *menuMoveGroupItem = menu.addMenu(QIcon(
"://icon/32x32/list-move_32.png"), tr(
"Move Group Object"));
1134 QStringList list = QStringList(groupsNotContainingItem.values());
1135 list.sort(Qt::CaseInsensitive);
1137 for(
int i=0; i<list.count(); ++i)
1139 QAction *actionMoveGroupItem = menuMoveGroupItem->addAction(list[i]);
1140 actionMoveGroupMenu->addAction(actionMoveGroupItem);
1141 const quint32 groupId = groupsNotContainingItem.key(list[i]);
1142 actionMoveGroupItem->setData(groupId);
1146 QAction *actionRemove = menu.addAction(QIcon::fromTheme(
"edit-delete"), tr(
"Remove Group Object"));
1148 QAction *selectedAction = menu.exec(
ui->groupItems_ListWidget->viewport()->mapToGlobal(pos));
1149 if(selectedAction ==
nullptr)
1153 else if (selectedAction == actionRemove)
1156 if (locked ==
false)
1158 qCDebug(WidgetGroups,
"Remove Tool %s from Group %s.",
1159 qUtf8Printable(QString().setNum(toolId)),
1160 qUtf8Printable(QString().setNum(groupId)));
1162 QListWidgetItem *rowItem =
ui->groupItems_ListWidget->item(row);
1165 delete ui->groupItems_ListWidget->item(row);
1171 scene->clearSelection();
1178 qApp->getUndoStack()->push(command);
1182 else if (selectedAction->actionGroup() == actionMoveGroupMenu)
1184 const quint32 destinationGroupId = selectedAction->data().toUInt();
1187 if ((sourceLock ==
false) && (destinationLock ==
false))
1190 qCDebug(WidgetGroups,
"Move Tool %s from Group %s to Group %s.",
1191 qUtf8Printable(QString().setNum(toolId)),
1192 qUtf8Printable(QString().setNum(groupId)),
1193 qUtf8Printable(QString().setNum(destinationGroupId)));
1195 QListWidgetItem *rowItem =
ui->groupItems_ListWidget->item(row);
1198 delete ui->groupItems_ListWidget->item(row);
1201 QDomElement destItem =
m_doc->
addGroupItem(itemData.last(), itemData.first(), destinationGroupId);
1207 scene->clearSelection();
1214 qApp->getUndoStack()->push(command);
1230 quint32 toolId = itemData.last();
1231 quint32 objId = itemData.first();
1237 if (objects->contains(toolId))
1308 scene->clearSelection();
1310 VMainGraphicsView *view = qobject_cast<VMainGraphicsView *>(scene->views().first());
1312 view->centerOn(point->toQPointF());
1314 int row =
ui->groups_TableWidget->currentRow();
1318 quint32 toolId = point->getIdTool();
1319 const quint32 objectId = point->getIdObject();
1328 tool->setPointNameVisiblity(toolId,
true);
1343 item->setIcon(QIcon(
"://icon/32x32/visible_on.png"));
1347 item->setIcon(QIcon(
"://icon/32x32/visible_off.png"));
1363 settings.setValue(
"splitterSizes",
ui->groups_Splitter->saveState());
1374 settings.setValue(
"groupSort", index);
virtual void updateGroups()=0
void setGroupLock(quint32 id, bool locked)
bool getGroupLock(quint32 id)
void setGroupColor(quint32 id, QString color)
QMap< quint32, GroupAttributes > getGroups()
void setGroupLineWeight(quint32 id, QString weight)
QDomElement removeGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Removes the item of given toolId and objectId from the group of given groupId.
QDomElement getGroupByName(const QString &name)
QPair< bool, QMap< quint32, quint32 > > parseItemElement(const QDomElement &domElement)
bool isGroupEmpty(quint32 id)
Returns true if the given group is empty.
QDomElement addGroupItem(quint32 toolId, quint32 objectId, quint32 groupId)
Adds an item to the given group with the given toolId and objectId.
QString getGroupName(quint32 id)
QDomElement createGroup(quint32 id, const QString &name, const QString &color, const QString &type, const QString &weight, const QMap< quint32, quint32 > &groupData)
bool getGroupVisibility(quint32 id)
QString getGroupLineWeight(quint32 id)
static const QString TagLine
void setGroupName(quint32 id, const QString &name)
static VDataTool * getTool(quint32 id)
getTool return tool from tool list.
void setGroupLineType(quint32 id, QString type)
QString getGroupLineType(quint32 id)
QMap< quint32, Tool > getGroupObjHistory() const
QMap< quint32, QString > getGroupsContainingItem(quint32 toolId, quint32 objectId, bool containsItem)
Returns the groups that contain or do not contain the item identified by the toolid and the objectid.
bool groupNameExists(const QString &groupName)
QString getGroupColor(quint32 id)
void setGroupVisibility(quint32 id, bool visible)
void patternHasGroups(bool value)
VArc class for anticlockwise arc.
The VContainer class container of all variables.
static quint32 getNextId()
getNextId generate next unique id
const QSharedPointer< VGObject > GetGObject(quint32 id) const
GetGObject returns a point by id.
const QSharedPointer< T > GeometricObject(const quint32 &id) const
const QHash< quint32, QSharedPointer< VGObject > > * DataGObjects() const
data container with datagObjects return container of gObjects
QDomElement elementById(quint32 id, const QString &tagName=QString())
static quint32 GetParametrUInt(const QDomElement &domElement, const QString &name, const QString &defValue)
Returns the long long value of the given attribute. RENAME: GetParameterLongLong?
The VExceptionBadId class for exception bad id.
virtual QString ErrorMessage() const Q_DECL_OVERRIDE
ErrorMessage return main error message.
virtual QString DetailedInformation() const
DetailedInformation return detailed information about error.
The VMainGraphicsScene class main scene.
The VMainGraphicsView class main scene view.
void zoomByScale(qreal scale)
The VPointF class keep data of point.
The VSplinePath class keep information about splinePath.
VSpline class that implements the spline.
QString makeHeaderName(const QString &name)
makeHeaderName make a 1 char tablewidgetitem header name based on a translated string.
@ PointOfIntersectionCurves
@ PointOfIntersectionCircles
@ PointFromCircleAndTangent
@ PointOfIntersectionArcs
const QString AttrSecondPoint
const QString AttrFirstPoint