From 844d3764c2533417a0487a641ea2bc4ec8c1d475 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Mon, 4 Apr 2016 18:03:40 +0300 Subject: [PATCH 01/12] Group button. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 5 +- src/app/valentina/mainwindow.ui | 54 +++++++++++++++--- .../valentina/share/resources/toolicon.qrc | 2 + .../resources/toolicon/32x32/group_plus.png | Bin 0 -> 1138 bytes .../toolicon/32x32/group_plus@2x.png | Bin 0 -> 2235 bytes .../resources/toolicon/svg/group_plus.svg | 6 ++ src/libs/vmisc/share/resources/icon.qrc | 2 + .../share/resources/icon/16x16/operations.png | Bin 0 -> 448 bytes .../resources/icon/16x16/operations@2x.png | Bin 0 -> 2180 bytes 9 files changed, 60 insertions(+), 9 deletions(-) create mode 100644 src/app/valentina/share/resources/toolicon/32x32/group_plus.png create mode 100644 src/app/valentina/share/resources/toolicon/32x32/group_plus@2x.png create mode 100644 src/app/valentina/share/resources/toolicon/svg/group_plus.svg create mode 100644 src/libs/vmisc/share/resources/icon/16x16/operations.png create mode 100644 src/libs/vmisc/share/resources/icon/16x16/operations@2x.png diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 227ed6aab..08c842102 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -2086,7 +2086,7 @@ void MainWindow::ActionDetails(bool checked) mode = Draw::Modeling; SetEnableTool(true); SetEnableWidgets(true); - ui->toolBox->setCurrentIndex(4); + ui->toolBox->setCurrentIndex(5); if (qApp->patternType() == MeasurementsType::Standard) { @@ -2161,7 +2161,7 @@ void MainWindow::ActionLayout(bool checked) mode = Draw::Layout; SetEnableTool(true); SetEnableWidgets(true); - ui->toolBox->setCurrentIndex(5); + ui->toolBox->setCurrentIndex(6); mouseCoordinate->setText(""); @@ -3042,6 +3042,7 @@ void MainWindow::SetEnableTool(bool enable) ui->toolButtonPointFromArcAndTangent->setEnabled(drawTools); ui->toolButtonArcWithLength->setEnabled(drawTools); ui->toolButtonTrueDarts->setEnabled(drawTools); + ui->toolButtonGroup->setEnabled(drawTools); ui->actionLast_tool->setEnabled(drawTools); diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index 90c9bb8a7..fdb501f67 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -48,14 +48,14 @@ Tools - 2 + 4 0 0 - 100 + 130 318 @@ -375,7 +375,7 @@ 0 0 - 100 + 130 58 @@ -700,7 +700,7 @@ 0 0 - 100 + 130 196 @@ -937,12 +937,52 @@ + + + + :/icon/16x16/operations.png:/icon/16x16/operations.png + + + Operations + + + Operations + + + + + + false + + + Create new group + + + ... + + + + :/toolicon/32x32/group_plus.png:/toolicon/32x32/group_plus.png + + + + 32 + 32 + + + + true + + + + + 0 0 - 100 + 130 58 @@ -1028,8 +1068,8 @@ 0 0 - 87 - 58 + 130 + 356 diff --git a/src/app/valentina/share/resources/toolicon.qrc b/src/app/valentina/share/resources/toolicon.qrc index 772aa06a7..8b5d0bec5 100644 --- a/src/app/valentina/share/resources/toolicon.qrc +++ b/src/app/valentina/share/resources/toolicon.qrc @@ -62,5 +62,7 @@ toolicon/32x32/cubic_bezier@2x.png toolicon/32x32/cubic_bezier_path.png toolicon/32x32/cubic_bezier_path@2x.png + toolicon/32x32/group_plus.png + toolicon/32x32/group_plus@2x.png diff --git a/src/app/valentina/share/resources/toolicon/32x32/group_plus.png b/src/app/valentina/share/resources/toolicon/32x32/group_plus.png new file mode 100644 index 0000000000000000000000000000000000000000..4b00755f062d4523700904b53550720ad9898ef5 GIT binary patch literal 1138 zcmV-&1daQNP)qO-oH@dMhT}LoZM&{3X)MI{?1qH1B(Q7b#-N?rl$IUcY#bTUJE&-PN1{1bJN`1+#t}F zihEjX5s?DW@4D`(RP2;(+ae+Z6^Dp?) z+jju{skNsoYLYmPUs;MgDPpJA`dF3wE#PBd2XL&ty?v*llsW^LNy61I z4Ew4U1;B3LnBzE@rujKQxm4q#cG~ z3;@q0=3Ep-J((Z~{U~i4&XI$4k4tG0ib93_m zaH0~_T7T(zUN5A&T~kxjxApb)PXO7(wQq8AGG|$q9|XZn5Cp@PWlbg`9$bd_25`i6 z-46i@g~GP^`T4IzL^Nz_Tg$Jn)H#oGq0~*Yo-O zM$gwvchK7bJ@7&^vXoa6q1YFiy zdrGOFq9_`hnVGo>uzB<5txBnfwbqX-rJO`u_1a=Cmm8?=j?0c@wr%efkq>~}ayhj? zYkeh?$-F&0JpAKQ@l|I++qMsg$RX}tOWkVu3GQgEzfnq^FO^EeD<#%El;-pKEv9L9 zCX>-qz*b;O621l81V%;VO1WJA&iDOWweG!+b^O2a5BmRldF3s8O8@`>07*qoM6N<$ Eg7pg@rvLx| literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon/32x32/group_plus@2x.png b/src/app/valentina/share/resources/toolicon/32x32/group_plus@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..7b9c63a74f37de0d0e3615927895bc7005b06e28 GIT binary patch literal 2235 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 JPDHLkV1h4TLP-Ds literal 0 HcmV?d00001 diff --git a/src/app/valentina/share/resources/toolicon/svg/group_plus.svg b/src/app/valentina/share/resources/toolicon/svg/group_plus.svg new file mode 100644 index 000000000..92243882d --- /dev/null +++ b/src/app/valentina/share/resources/toolicon/svg/group_plus.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index ed0dec1b4..3d273e73d 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -55,5 +55,7 @@ icon/16x16/toolsectioncurve@2x.png icon/16x16/toolsectionline@2x.png icon/16x16/toolsectionpoint@2x.png + icon/16x16/operations.png + icon/16x16/operations@2x.png diff --git a/src/libs/vmisc/share/resources/icon/16x16/operations.png b/src/libs/vmisc/share/resources/icon/16x16/operations.png new file mode 100644 index 0000000000000000000000000000000000000000..76e5e17fe34f0e7e703d49c6e23c0aec1d18c7ee GIT binary patch literal 448 zcmV;x0YCnUP)rQ{Av5#Ye+FS*3>Wk;9Ltnr z`0NQ{KVsnBE;Cbi)01>5Oc(t9`3tL!62IPhhJ=JLfG~(1z|Xf# z^((_Kpd2!ei;Dw^XLfdWPJ2MeP`}3QD_28*Z|3Y{-gJ>8VC&YTZ-WdV1_uNL{0GJW7=zd_aTa28 q9WYHy4+;v(MD{;HFAxI&0t^8DANvn?@D3yZ0000*TXw)<$jn;@ZBCSRtD!oAI4A2=Y19Lqy=YICO{CqfPh8CF8dRfWN zIr*($_WJJcZ+*YNA6rkB760e8^<-IXJz2izo&wnVYB>jNLFiMUfl}5p1<=rp0sWo) z<R~(df&hx-`JNc)b;vgHu)$RBmpowq> zI1GGn9{|z^JR$IqR|-+|S2TkPRN^Tr7--|9SPduw+$%01S)pGELrMhI{-BpXt2`lq zc+u^5LNnl%YM|b1D2jm)<`ky_;VghtEY%ew0QZVJh0O}D7Oc!CUY^lyHuZf0AX4hk z-e1w`&3dS=;HBR~u&S9taj{dXj1uyKVpZ!8QMv_M5F$hhD8gFEhsGH{j4f(mMM3Gl z0181ga|xL6Hq?=D9kr{ul>Y(6&zJfCX6~E zYqcb~`pr)ppWLki@0WqoqIA(KwS@B-kh|rh6euKcX{b%JCsYOcdV9$g3IGfZD@I0! zb7eD!ua+4|%etV_hyV22PbSqj#G-w8-qo^^8FLlZ-4Lg*M6D1vjwa( zP`WyegaOS>MSN031<^g|U#kK*=fzkn##*ek9TGiCX>$2In;(3D()>-b((I|!8{b;3 zRPAb|S~`04=s)-G-(Nd$;D7)eK76?2QUkqXs<-QfxMg3+R2yRwM>WyfZcqZecNk-^ z#^Bs-0LB=sb7bO}9gpo~{Hu@Uf-oAdR4RLnF+U7~V9$vYC-R?sV_OACKf-s#`vGO` zS)%YF)&=-GRnRGcYaeEe!8wQb9_Jj+Ik1*64C(3ZmDCtDGBOfbYsYG}nk|>hl*{F% zBS(&0@ZL8L9XjMYDzF`=6~z1Ymu}R&b(?{-1Hf9lez+6fo zpFjWT>gsBk&1NN=%?<@Y@D{MR<^#*1P74%$7%X922Dyg{P-}MplcuC5#aee4fVJN! ziWnIgkuVI^($Z2C1i`jSr9!P%vm)}|I)K=?DGBw#MsHWq^%O=_vz4b~#dk5F+6Sa* zib>mdz&W?hgzB&-A_PGIpausA*}HcylarI-nKNg`7Zw(loO37ERj@k!F+>qQj>QiT zTB6WlY@2~VTeSA=|Dh*9S?_gf45>*m#vmd@QH0hSV@yX8idwBksZ>I1O*WfdXK4-W zIsiR9IELbRRjv0+x%#Smq~{8^n*GYUK(dJ;)+uYQ#&={jknv$mNtwN!I_nzhD zWvsQtam>QP0_V@4m$|t)6-5!wIlHp5G6|g5T32p6p`s7igR?_=c79%*L;8BID{Djj zubX4a*Z}|==jYk7`Te-LGH;u8Yh5pKoFF1xzkVI(9Qk~nT(0dol}d#xSFWh5SFidc zNgA0<=1LSrXQC*2TWh^?yBCP}KojFprPXJ`a%IT(bw7uobgBGP#P0>rI{dw_4!pf> z`giZRx^0RYrC2Ott>uk3-oQD>lTSX$(9n=nt5ubzDXmtEG)*f}6kPz`^4|YClgV6) zvj`xC+yY810VwecT(t|kF8)08kB6SRQExQAHa#8)00MB52wZqOixb_UcP*p<>lqSHyVwP zXJ%&lXJ==#g+hVB!9j+Hhso#j@!Z_p=;Gp{F~RNX+iP9@5&U)`JSZljQB+X{Cv$a}nxA*=BnM{U(fdLAIf&g@P zcOxRSS}lw*pPq=)qkBL1!B0Q^G=Mt!%JCFf=sfG|@y8#(md$3br)m0?nVA`qBvAm@ zu3e+iXyBZ?>Ag?y9!S0*0UK@Pa=B&@1nKbO zW4fGkna-?`W-^(IQmWj^`QNUIi3uhqCe# Date: Tue, 5 Apr 2016 20:14:12 +0300 Subject: [PATCH 02/12] Dialog Group. --HG-- branch : feature --- .../core/vtooloptionspropertybrowser.cpp | 6 +- src/app/valentina/dialogs/dialoghistory.cpp | 3 +- src/app/valentina/mainwindow.cpp | 80 ++++++++++++- src/app/valentina/mainwindow.h | 6 +- src/app/valentina/share/resources/cursor.qrc | 2 + .../resources/cursor/group_plus_cursor.png | Bin 0 -> 830 bytes .../resources/cursor/group_plus_cursor@2x.png | Bin 0 -> 1843 bytes src/app/valentina/xml/vpattern.cpp | 3 +- src/libs/ifc/xml/vabstractpattern.cpp | 6 + src/libs/ifc/xml/vabstractpattern.h | 2 + src/libs/vmisc/def.h | 1 + src/libs/vtools/dialogs/dialogs.pri | 9 +- src/libs/vtools/dialogs/tooldialogs.h | 1 + src/libs/vtools/dialogs/tools/dialoggroup.cpp | 106 ++++++++++++++++++ src/libs/vtools/dialogs/tools/dialoggroup.h | 66 +++++++++++ src/libs/vtools/dialogs/tools/dialoggroup.ui | 91 +++++++++++++++ src/libs/vtools/dialogs/tools/dialogtool.cpp | 8 ++ src/libs/vtools/dialogs/tools/dialogtool.h | 1 + .../drawTools/toolcurve/vabstractspline.cpp | 10 +- .../tooldoublepoint/vtooldoublepoint.cpp | 14 +++ .../tooldoublepoint/vtooldoublepoint.h | 2 + .../toolsinglepoint/vtoolsinglepoint.cpp | 13 +-- src/libs/vtools/tools/drawTools/vdrawtool.h | 4 + src/libs/vtools/tools/drawTools/vtoolline.cpp | 15 +-- src/libs/vwidgets/vgraphicssimpletextitem.cpp | 4 + src/libs/vwidgets/vgraphicssimpletextitem.h | 1 + src/libs/vwidgets/vmaingraphicsscene.cpp | 12 ++ src/libs/vwidgets/vmaingraphicsscene.h | 4 + src/libs/vwidgets/vsimplepoint.cpp | 21 ++++ src/libs/vwidgets/vsimplepoint.h | 11 +- 30 files changed, 453 insertions(+), 49 deletions(-) create mode 100644 src/app/valentina/share/resources/cursor/group_plus_cursor.png create mode 100644 src/app/valentina/share/resources/cursor/group_plus_cursor@2x.png create mode 100644 src/libs/vtools/dialogs/tools/dialoggroup.cpp create mode 100644 src/libs/vtools/dialogs/tools/dialoggroup.h create mode 100644 src/libs/vtools/dialogs/tools/dialoggroup.ui diff --git a/src/app/valentina/core/vtooloptionspropertybrowser.cpp b/src/app/valentina/core/vtooloptionspropertybrowser.cpp index b508af5f5..117787659 100644 --- a/src/app/valentina/core/vtooloptionspropertybrowser.cpp +++ b/src/app/valentina/core/vtooloptionspropertybrowser.cpp @@ -74,7 +74,7 @@ void VToolOptionsPropertyBrowser::ClearPropertyBrowser() void VToolOptionsPropertyBrowser::ShowItemOptions(QGraphicsItem *item) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch."); switch (item->type()) { @@ -191,7 +191,7 @@ void VToolOptionsPropertyBrowser::UpdateOptions() } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch."); switch (currentItem->type()) { @@ -323,7 +323,7 @@ void VToolOptionsPropertyBrowser::userChangedData(VProperty *property) } // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was used in switch."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in switch."); switch (currentItem->type()) { diff --git a/src/app/valentina/dialogs/dialoghistory.cpp b/src/app/valentina/dialogs/dialoghistory.cpp index 5c5c462de..bddd259f3 100644 --- a/src/app/valentina/dialogs/dialoghistory.cpp +++ b/src/app/valentina/dialogs/dialoghistory.cpp @@ -208,7 +208,7 @@ void DialogHistory::FillTable() QString DialogHistory::Record(const VToolRecord &tool) { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was used in history."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used in history."); const QDomElement domElem = doc->elementById(tool.getId()); if (domElem.isElement() == false) @@ -383,6 +383,7 @@ QString DialogHistory::Record(const VToolRecord &tool) case Tool::NodePoint: case Tool::NodeSpline: case Tool::NodeSplinePath: + case Tool::Group: return QString(); } } diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 08c842102..b37aab18c 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -305,6 +305,7 @@ void MainWindow::InitScenes() connect(this, &MainWindow::EnableLabelSelection, sceneDraw, &VMainGraphicsScene::ToggleLabelSelection); connect(this, &MainWindow::EnablePointSelection, sceneDraw, &VMainGraphicsScene::TogglePointSelection); + connect(this, &MainWindow::EnableLineSelection, sceneDraw, &VMainGraphicsScene::ToggleLineSelection); connect(this, &MainWindow::EnableArcSelection, sceneDraw, &VMainGraphicsScene::ToggleArcSelection); connect(this, &MainWindow::EnableSplineSelection, sceneDraw, &VMainGraphicsScene::ToggleSplineSelection); connect(this, &MainWindow::EnableSplinePathSelection, sceneDraw, &VMainGraphicsScene::ToggleSplinePathSelection); @@ -551,6 +552,7 @@ void MainWindow::SetToolButton(bool checked, Tool t, const QString &cursor, cons SCASSERT(scene != nullptr); connect(scene, &VMainGraphicsScene::ChoosedObject, dialogTool, &DialogTool::ChosenObject); + connect(scene, &VMainGraphicsScene::SelectedObject, dialogTool, &DialogTool::SelectedObject); connect(dialogTool, &DialogTool::DialogClosed, this, closeDialogSlot); connect(dialogTool, &DialogTool::ToolTip, this, &MainWindow::ShowToolTip); ui->view->itemClicked(nullptr); @@ -906,7 +908,7 @@ void MainWindow::ToolPointOfContact(bool checked) */ void MainWindow::ToolDetail(bool checked) { - ToolSelectAllObjects(); + ToolSelectAllDrawObjects(); SetToolButton(checked, Tool::Detail, "://cursor/new_detail_cursor.png", tr("Select points, arcs, curves clockwise."), &MainWindow::ClosedDialogDetail); } @@ -991,6 +993,33 @@ void MainWindow::ClosedDialogUnionDetails(int result) doc->LiteParseTree(Document::LiteParse); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolGroup(bool checked) +{ + ToolSelectGroupObjects(); + SetToolButton(checked, Tool::Group, ":/cursor/group_plus_cursor.png", + tr("Select objects, Enter - finish creation"), &MainWindow::ClosedDialogGroup); +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ClosedDialogGroup(int result) +{ + SCASSERT(dialogTool != nullptr); + if (result == QDialog::Accepted) + { + VMainGraphicsScene *scene = qobject_cast(currentScene); + SCASSERT(scene != nullptr); + + DialogGroup *dialog = qobject_cast(dialogTool); + SCASSERT(dialog != nullptr); + const QString name = dialog->GetName(); + const QMap group = dialog->GetGroup(); + const quint32 id = pattern->getNextId(); + doc->AddGroup(id, name, group); + } + ArrowTool(); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief ToolCutArc handler tool cutArc. @@ -1018,7 +1047,7 @@ void MainWindow::ToolLineIntersectAxis(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolCurveIntersectAxis(bool checked) { - ToolSelectAllObjects(); + ToolSelectAllDrawObjects(); SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, ":/cursor/curve_intersect_axis_cursor.png", tr("Select curve"), @@ -1029,7 +1058,7 @@ void MainWindow::ToolCurveIntersectAxis(bool checked) //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolArcIntersectAxis(bool checked) { - ToolSelectAllObjects(); + ToolSelectAllDrawObjects(); // Reuse ToolCurveIntersectAxis but with different cursor and tool tip SetToolButtonWithApply(checked, Tool::CurveIntersectAxis, ":/cursor/arc_intersect_axis_cursor.png", @@ -1739,7 +1768,7 @@ void MainWindow::mouseMove(const QPointF &scenePos) void MainWindow::CancelTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled."); qCDebug(vMainWindow, "Canceling tool."); delete dialogTool; @@ -1863,6 +1892,9 @@ void MainWindow::CancelTool() case Tool::TrueDarts: ui->toolButtonTrueDarts->setChecked(false); break; + case Tool::Group: + ui->toolButtonGroup->setChecked(false); + break; } currentScene->setFocus(Qt::OtherFocusReason); currentScene->clearSelection(); @@ -1895,6 +1927,7 @@ void MainWindow::ArrowTool() // Only true for rubber band selection emit EnableLabelSelection(true); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -3317,7 +3350,7 @@ void MainWindow::CreateMenus() void MainWindow::LastUsedTool() { // This check helps to find missed tools in the switch - Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was handled."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was handled."); if (currentTool == lastUsedTool) { @@ -3464,6 +3497,10 @@ void MainWindow::LastUsedTool() ui->toolButtonTrueDarts->setChecked(true); ToolTrueDarts(true); break; + case Tool::Group: + ui->toolButtonGroup->setChecked(true); + ToolGroup(true); + break; } } @@ -4460,6 +4497,7 @@ void MainWindow::ToolSelectPoint() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4495,6 +4533,7 @@ void MainWindow::ToolSelectSpline() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4518,6 +4557,7 @@ void MainWindow::ToolSelectSplinePath() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4541,6 +4581,7 @@ void MainWindow::ToolSelectArc() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4564,6 +4605,7 @@ void MainWindow::ToolSelectPointArc() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4587,6 +4629,7 @@ void MainWindow::ToolSelectCurve() const // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4605,11 +4648,12 @@ void MainWindow::ToolSelectCurve() const } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::ToolSelectAllObjects() const +void MainWindow::ToolSelectAllDrawObjects() const { // Only true for rubber band selection emit EnableLabelSelection(false); emit EnablePointSelection(false); + emit EnableLineSelection(false); emit EnableArcSelection(false); emit EnableSplineSelection(false); emit EnableSplinePathSelection(false); @@ -4627,6 +4671,30 @@ void MainWindow::ToolSelectAllObjects() const ui->view->AllowRubberBand(false); } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::ToolSelectGroupObjects() const +{ + // Only true for rubber band selection + emit EnableLabelSelection(true); + emit EnablePointSelection(true); + emit EnableLineSelection(true); + emit EnableArcSelection(true); + emit EnableSplineSelection(true); + emit EnableSplinePathSelection(true); + + // Hovering + emit EnableLabelHover(true); + emit EnablePointHover(true); + emit EnableLineHover(true); + emit EnableArcHover(true); + emit EnableSplineHover(true); + emit EnableSplinePathHover(true); + + emit ItemsSelection(SelectionType::ByMouseRelease); + + ui->view->AllowRubberBand(false); +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::ToolSelectDetail() const { diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index f241b3526..52602520e 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -120,6 +120,7 @@ public slots: void ToolTriangle(bool checked); void ToolPointOfIntersection(bool checked); void ToolUnionDetails(bool checked); + void ToolGroup(bool checked); void ToolCutArc(bool checked); void ToolLineIntersectAxis(bool checked); void ToolCurveIntersectAxis(bool checked); @@ -134,6 +135,7 @@ public slots: void ClosedDialogDetail(int result); void ClosedDialogUnionDetails(int result); + void ClosedDialogGroup(int result); //tmp void LastUsedTool(); @@ -161,6 +163,7 @@ signals: void EnableLabelSelection(bool enable) const; void EnablePointSelection(bool enable) const; + void EnableLineSelection(bool enable) const; void EnableArcSelection(bool enable) const; void EnableSplineSelection(bool enable) const; void EnableSplinePathSelection(bool enable) const; @@ -360,7 +363,8 @@ private: void ToolSelectArc() const; void ToolSelectPointArc() const; void ToolSelectCurve() const; - void ToolSelectAllObjects() const; + void ToolSelectAllDrawObjects() const; + void ToolSelectGroupObjects() const; void ToolSelectDetail() const; }; diff --git a/src/app/valentina/share/resources/cursor.qrc b/src/app/valentina/share/resources/cursor.qrc index a52e2b468..1063918f4 100644 --- a/src/app/valentina/share/resources/cursor.qrc +++ b/src/app/valentina/share/resources/cursor.qrc @@ -64,5 +64,7 @@ cursor/cubic_bezier_cursor@2x.png cursor/cubic_bezier_path_cursor.png cursor/cubic_bezier_path_cursor@2x.png + cursor/group_plus_cursor.png + cursor/group_plus_cursor@2x.png diff --git a/src/app/valentina/share/resources/cursor/group_plus_cursor.png b/src/app/valentina/share/resources/cursor/group_plus_cursor.png new file mode 100644 index 0000000000000000000000000000000000000000..e1b00a75359d064f7ab90591c0d32f780a27554c GIT binary patch literal 830 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::LAST_ONE_DO_NOT_USE) == 41, "Not all tools was used."); + Q_STATIC_ASSERT_X(static_cast(Tool::LAST_ONE_DO_NOT_USE) == 42, "Not all tools was used."); QRectF rec; @@ -3237,6 +3237,7 @@ QRectF VPattern::ActiveDrawBoundingRect() const case Tool::NodePoint: case Tool::NodeSpline: case Tool::NodeSplinePath: + case Tool::Group: break; } } diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 32220e939..2709dbe32 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1355,3 +1355,9 @@ QDomElement VAbstractPattern::GetDraw(const QString &name) const } return QDomElement(); } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap &group) +{ + +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 46c99eb85..e7ba57630 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -114,6 +114,8 @@ public: QDomElement GetDraw(const QString &name) const; + void AddGroup(quint32 id, const QString &name, const QMap &group); + static const QString TagPattern; static const QString TagCalculation; static const QString TagModeling; diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 6987cc452..5083bbb38 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -101,6 +101,7 @@ enum class Tool : ToolVisHolderType PointFromArcAndTangent, TrueDarts, UnionDetails, + Group, LAST_ONE_DO_NOT_USE //add new stuffs above this, this constant must be last and never used }; diff --git a/src/libs/vtools/dialogs/dialogs.pri b/src/libs/vtools/dialogs/dialogs.pri index fd77d2ce3..26bcfaad6 100644 --- a/src/libs/vtools/dialogs/dialogs.pri +++ b/src/libs/vtools/dialogs/dialogs.pri @@ -36,7 +36,8 @@ HEADERS += \ $$PWD/tools/dialogtruedarts.h \ $$PWD/tools/dialogpointofintersectioncurves.h \ $$PWD/tools/dialogcubicbezier.h \ - $$PWD/tools/dialogcubicbezierpath.h + $$PWD/tools/dialogcubicbezierpath.h \ + $$PWD/tools/dialoggroup.h SOURCES += \ $$PWD/tools/dialogalongline.cpp \ @@ -72,7 +73,8 @@ SOURCES += \ $$PWD/tools/dialogtruedarts.cpp \ $$PWD/tools/dialogpointofintersectioncurves.cpp \ $$PWD/tools/dialogcubicbezier.cpp \ - $$PWD/tools/dialogcubicbezierpath.cpp + $$PWD/tools/dialogcubicbezierpath.cpp \ + $$PWD/tools/dialoggroup.cpp FORMS += \ $$PWD/tools/dialogalongline.ui \ @@ -107,4 +109,5 @@ FORMS += \ $$PWD/tools/dialogtruedarts.ui \ $$PWD/tools/dialogpointofintersectioncurves.ui \ $$PWD/tools/dialogcubicbezier.ui \ - $$PWD/tools/dialogcubicbezierpath.ui + $$PWD/tools/dialogcubicbezierpath.ui \ + $$PWD/tools/dialoggroup.ui diff --git a/src/libs/vtools/dialogs/tooldialogs.h b/src/libs/vtools/dialogs/tooldialogs.h index 08326cce0..b9ac6d496 100644 --- a/src/libs/vtools/dialogs/tooldialogs.h +++ b/src/libs/vtools/dialogs/tooldialogs.h @@ -60,6 +60,7 @@ #include "dialogs/tools/dialogpointfromcircleandtangent.h" #include "dialogs/tools/dialogpointfromarcandtangent.h" #include "dialogs/tools/dialogtruedarts.h" +#include "dialogs/tools/dialoggroup.h" #include "dialogs/support/dialogeditwrongformula.h" #include "dialogs/support/dialogundo.h" diff --git a/src/libs/vtools/dialogs/tools/dialoggroup.cpp b/src/libs/vtools/dialogs/tools/dialoggroup.cpp new file mode 100644 index 000000000..d9e64ef23 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoggroup.cpp @@ -0,0 +1,106 @@ +/************************************************************************ + ** + ** @file dialoggroup.cpp + ** @author Roman Telezhynskyi + ** @date 4 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "dialoggroup.h" +#include "ui_dialoggroup.h" +#include "../vtools/tools/drawTools/drawtools.h" + +//--------------------------------------------------------------------------------------------------------------------- +DialogGroup::DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent) + : DialogTool(data, toolId, parent), + ui(new Ui::DialogGroup), + group() +{ + ui->setupUi(this); + InitOkCancel(ui); + CheckState(); + + connect(ui->lineEditName, &QLineEdit::textChanged, this, &DialogGroup::NameChanged); +} + +//--------------------------------------------------------------------------------------------------------------------- +DialogGroup::~DialogGroup() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogGroup::SetName(const QString &name) +{ + ui->lineEditName->setText(name); +} + +//--------------------------------------------------------------------------------------------------------------------- +QString DialogGroup::GetName() const +{ + return ui->lineEditName->text(); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogGroup::ShowDialog(bool click) +{ + if (not click) + { + if (group.isEmpty()) + { + return; + } + + SetName(tr("New group")); + + setModal(true); + emit ToolTip(""); + show(); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogGroup::SelectedObject(bool selected, quint32 object, quint32 tool) +{ + if (selected) + { + group.insert(object, tool); + } + else + { + group.remove(object); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void DialogGroup::NameChanged() +{ + ui->lineEditName->text().isEmpty() ? flagName = false : flagName = true; + CheckState(); +} + +//--------------------------------------------------------------------------------------------------------------------- +QMap DialogGroup::GetGroup() const +{ + return group; +} diff --git a/src/libs/vtools/dialogs/tools/dialoggroup.h b/src/libs/vtools/dialogs/tools/dialoggroup.h new file mode 100644 index 000000000..249e0e5f7 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoggroup.h @@ -0,0 +1,66 @@ +/************************************************************************ + ** + ** @file dialoggroup.h + ** @author Roman Telezhynskyi + ** @date 4 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DIALOGGROUP_H +#define DIALOGGROUP_H + +#include "dialogtool.h" + +namespace Ui +{ + class DialogGroup; +} + +class DialogGroup : public DialogTool +{ + Q_OBJECT + +public: + explicit DialogGroup(const VContainer *data, const quint32 &toolId, QWidget *parent = nullptr); + ~DialogGroup(); + + void SetName(const QString &name); + QString GetName() const; + + QMap GetGroup() const; + + virtual void ShowDialog(bool click) Q_DECL_OVERRIDE; + +public slots: + virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE; + +private slots: + void NameChanged(); + +private: + Q_DISABLE_COPY(DialogGroup) + Ui::DialogGroup *ui; + QMap group; +}; + +#endif // DIALOGGROUP_H diff --git a/src/libs/vtools/dialogs/tools/dialoggroup.ui b/src/libs/vtools/dialogs/tools/dialoggroup.ui new file mode 100644 index 000000000..3983b99f8 --- /dev/null +++ b/src/libs/vtools/dialogs/tools/dialoggroup.ui @@ -0,0 +1,91 @@ + + + DialogGroup + + + + 0 + 0 + 397 + 80 + + + + Group + + + + :/icon/64x64/icon64x64.png:/icon/64x64/icon64x64.png + + + + + + + + Group name: + + + + + + + Unique pattern piece name + + + Choose group name + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + DialogGroup + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + DialogGroup + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/libs/vtools/dialogs/tools/dialogtool.cpp b/src/libs/vtools/dialogs/tools/dialogtool.cpp index 8e1d66333..c288f9fb8 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.cpp +++ b/src/libs/vtools/dialogs/tools/dialogtool.cpp @@ -694,6 +694,14 @@ void DialogTool::ChosenObject(quint32 id, const SceneObject &type) Q_UNUSED(type); } +//--------------------------------------------------------------------------------------------------------------------- +void DialogTool::SelectedObject(bool selected, quint32 object, quint32 tool) +{ + Q_UNUSED(selected); + Q_UNUSED(object); + Q_UNUSED(tool); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NamePointChanged check name of point diff --git a/src/libs/vtools/dialogs/tools/dialogtool.h b/src/libs/vtools/dialogs/tools/dialogtool.h index fb70cb1ad..86e752be2 100644 --- a/src/libs/vtools/dialogs/tools/dialogtool.h +++ b/src/libs/vtools/dialogs/tools/dialogtool.h @@ -92,6 +92,7 @@ signals: public slots: void ShowVisToolTip(const QString &toolTip); virtual void ChosenObject(quint32 id, const SceneObject &type); + virtual void SelectedObject(bool selected, quint32 object, quint32 tool); void NamePointChanged(); virtual void DialogAccepted(); /** diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index fdc8d6c4b..042a3f640 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -166,15 +166,7 @@ QVariant VAbstractSpline::itemChange(QGraphicsItem::GraphicsItemChange change, c { if (change == QGraphicsItem::ItemSelectedChange) { - if (value == true) - { - // do stuff if selected - this->setFocus(); - } - else - { - // do stuff if not selected - } + emit ChangedToolSelection(value.toBool(), id, id); } return QGraphicsItem::itemChange(change, value); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index 000991f4e..b8eaf3359 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -42,6 +42,7 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin firstPoint = new VSimplePoint(p1id, QColor(baseColor), *data->GetPatternUnit(), &factor); firstPoint->setParentItem(this); connect(firstPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point1Choosed); + connect(firstPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point1Selected); connect(firstPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent); connect(firstPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel); connect(firstPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label1ChangePosition); @@ -50,6 +51,7 @@ VToolDoublePoint::VToolDoublePoint(VAbstractPattern *doc, VContainer *data, quin secondPoint = new VSimplePoint(p2id, QColor(baseColor), *data->GetPatternUnit(), &factor); secondPoint->setParentItem(this); connect(secondPoint, &VSimplePoint::Choosed, this, &VToolDoublePoint::Point2Choosed); + connect(secondPoint, &VSimplePoint::Selected, this, &VToolDoublePoint::Point2Selected); connect(secondPoint, &VSimplePoint::ShowContextMenu, this, &VToolDoublePoint::contextMenuEvent); connect(secondPoint, &VSimplePoint::Delete, this, &VToolDoublePoint::DeleteFromLabel); connect(secondPoint, &VSimplePoint::NameChangedPosition, this, &VToolDoublePoint::Label2ChangePosition); @@ -138,6 +140,18 @@ void VToolDoublePoint::Point2Choosed() emit ChoosedTool(p2id, SceneObject::Point); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::Point1Selected(bool selected) +{ + emit ChangedToolSelection(selected, p1id, id); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::Point2Selected(bool selected) +{ + emit ChangedToolSelection(selected, p2id, id); +} + //--------------------------------------------------------------------------------------------------------------------- void VToolDoublePoint::FullUpdateFromFile() { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h index 0062b954c..c1cae4c8f 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h @@ -64,6 +64,8 @@ public slots: virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE; void Point1Choosed(); void Point2Choosed(); + void Point1Selected(bool selected); + void Point2Selected(bool selected); virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE; virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 2794bd0dc..3e4f79b2c 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -270,15 +270,10 @@ QVariant VToolSinglePoint::itemChange(QGraphicsItem::GraphicsItemChange change, { if (change == QGraphicsItem::ItemSelectedChange) { - if (value == true) - { - // do stuff if selected - this->setFocus(); - } - else - { - // do stuff if not selected - } + namePoint->blockSignals(true); + namePoint->setSelected(value.toBool()); + namePoint->blockSignals(false); + emit ChangedToolSelection(value.toBool(), id, id); } return QGraphicsEllipseItem::itemChange(change, value); diff --git a/src/libs/vtools/tools/drawTools/vdrawtool.h b/src/libs/vtools/tools/drawTools/vdrawtool.h index ddf9eb0ca..dcabb0288 100644 --- a/src/libs/vtools/tools/drawTools/vdrawtool.h +++ b/src/libs/vtools/tools/drawTools/vdrawtool.h @@ -61,6 +61,9 @@ public: QString GetLineColor() const; virtual void SetLineColor(const QString &value); +signals: + void ChangedToolSelection(bool selected, quint32 object, quint32 tool); + public slots: virtual void ShowTool(quint32 id, bool enable); virtual void ChangedActivDraw(const QString &newName); @@ -238,6 +241,7 @@ void VDrawTool::InitDrawToolConnections(VMainGraphicsScene *scene, T *tool) SCASSERT(tool != nullptr); QObject::connect(tool, &T::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); + QObject::connect(tool, &T::ChangedToolSelection, scene, &VMainGraphicsScene::SelectedItem); QObject::connect(scene, &VMainGraphicsScene::NewFactor, tool, &T::SetFactor); QObject::connect(scene, &VMainGraphicsScene::DisableItem, tool, &T::Disable); QObject::connect(scene, &VMainGraphicsScene::EnableToolMove, tool, &T::EnableToolMove); diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 5cd75cea1..9e66ec18b 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -149,9 +149,8 @@ VToolLine * VToolLine::Create(const quint32 &_id, const quint32 &firstPoint, con { VToolLine *line = new VToolLine(doc, data, id, firstPoint, secondPoint, typeLine, lineColor, typeCreation); scene->addItem(line); - connect(line, &VToolLine::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem); - connect(scene, &VMainGraphicsScene::NewFactor, line, &VToolLine::SetFactor); - connect(scene, &VMainGraphicsScene::DisableItem, line, &VToolLine::Disable); + InitDrawToolConnections(scene, line); + connect(scene, &VMainGraphicsScene::EnablePointItemSelection, line, &VToolLine::AllowSelecting); connect(scene, &VMainGraphicsScene::EnableLineItemHover, line, &VToolLine::AllowHover); doc->AddTool(id, line); @@ -327,15 +326,7 @@ QVariant VToolLine::itemChange(QGraphicsItem::GraphicsItemChange change, const Q { if (change == QGraphicsItem::ItemSelectedChange) { - if (value == true) - { - // do stuff if selected - this->setFocus(); - } - else - { - // do stuff if not selected - } + emit ChangedToolSelection(value.toBool(), id, id); } return QGraphicsItem::itemChange(change, value); diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.cpp b/src/libs/vwidgets/vgraphicssimpletextitem.cpp index 60abcc02a..093a14051 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.cpp +++ b/src/libs/vwidgets/vgraphicssimpletextitem.cpp @@ -152,6 +152,10 @@ QVariant VGraphicsSimpleTextItem::itemChange(GraphicsItemChange change, const QV changeFinished = true; } } + if (change == QGraphicsItem::ItemSelectedChange) + { + emit PointSelected(value.toBool()); + } return QGraphicsItem::itemChange(change, value); } diff --git a/src/libs/vwidgets/vgraphicssimpletextitem.h b/src/libs/vwidgets/vgraphicssimpletextitem.h index dd5db5118..031879075 100644 --- a/src/libs/vwidgets/vgraphicssimpletextitem.h +++ b/src/libs/vwidgets/vgraphicssimpletextitem.h @@ -63,6 +63,7 @@ signals: void ShowContextMenu(QGraphicsSceneContextMenuEvent *event); void DeleteTool(); void PointChoosed(); + void PointSelected(bool selected); protected: QVariant itemChange ( GraphicsItemChange change, const QVariant &value ); virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent *event ) Q_DECL_OVERRIDE; diff --git a/src/libs/vwidgets/vmaingraphicsscene.cpp b/src/libs/vwidgets/vmaingraphicsscene.cpp index 6ad0b7ce7..d1940cdac 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.cpp +++ b/src/libs/vwidgets/vmaingraphicsscene.cpp @@ -258,6 +258,12 @@ void VMainGraphicsScene::ChoosedItem(quint32 id, const SceneObject &type) emit ChoosedObject(id, type); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::SelectedItem(bool selected, quint32 object, quint32 tool) +{ + emit SelectedObject(selected, object, tool); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief SetFactor set current scale factor of scene. @@ -299,6 +305,12 @@ void VMainGraphicsScene::TogglePointSelection(bool enabled) emit EnablePointItemSelection(enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void VMainGraphicsScene::ToggleLineSelection(bool enabled) +{ + emit EnableLineItemSelection(enabled); +} + //--------------------------------------------------------------------------------------------------------------------- void VMainGraphicsScene::ToggleArcSelection(bool enabled) { diff --git a/src/libs/vwidgets/vmaingraphicsscene.h b/src/libs/vwidgets/vmaingraphicsscene.h index fc9b99c6e..e65896965 100644 --- a/src/libs/vwidgets/vmaingraphicsscene.h +++ b/src/libs/vwidgets/vmaingraphicsscene.h @@ -55,6 +55,7 @@ public: void SetOriginsVisible(bool visible); public slots: void ChoosedItem(quint32 id, const SceneObject &type); + void SelectedItem(bool selected, quint32 object, quint32 tool); void SetFactor(qreal factor); void EnableItemMove(bool move); void EnableDetailsMode(bool mode); @@ -62,6 +63,7 @@ public slots: void ToggleLabelSelection(bool enabled); void TogglePointSelection(bool enabled); + void ToggleLineSelection(bool enabled); void ToggleArcSelection(bool enabled); void ToggleSplineSelection(bool enabled); void ToggleSplinePathSelection(bool enabled); @@ -98,6 +100,7 @@ signals: * @param type object scene type. */ void ChoosedObject(quint32 id, SceneObject type); + void SelectedObject(bool selected, quint32 object, quint32 tool); /** * @brief NewFactor send new scale factor. * @param factor scene scale factor. @@ -110,6 +113,7 @@ signals: void EnableLabelItemSelection(bool enable); void EnablePointItemSelection(bool enable); + void EnableLineItemSelection(bool enable); void EnableArcItemSelection(bool enable); void EnableSplineItemSelection(bool enable); void EnableSplinePathItemSelection(bool enable); diff --git a/src/libs/vwidgets/vsimplepoint.cpp b/src/libs/vwidgets/vsimplepoint.cpp index 87624351f..0fafd4051 100644 --- a/src/libs/vwidgets/vsimplepoint.cpp +++ b/src/libs/vwidgets/vsimplepoint.cpp @@ -46,6 +46,7 @@ VSimplePoint::VSimplePoint(quint32 id, const QColor ¤tColor, Unit patternU connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VSimplePoint::ContextMenu); connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VSimplePoint::DeleteFromLabel); connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VSimplePoint::PointChoosed); + connect(namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VSimplePoint::PointSelected); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VSimplePoint::ChangedPosition); lineName = new QGraphicsLineItem(this); this->setBrush(QBrush(Qt::NoBrush)); @@ -165,6 +166,12 @@ void VSimplePoint::PointChoosed() emit Choosed(id); } +//--------------------------------------------------------------------------------------------------------------------- +void VSimplePoint::PointSelected(bool selected) +{ + emit Selected(selected, id); +} + //--------------------------------------------------------------------------------------------------------------------- void VSimplePoint::ChangedPosition(const QPointF &pos) { @@ -222,6 +229,20 @@ void VSimplePoint::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) QGraphicsEllipseItem::hoverLeaveEvent(event); } +//--------------------------------------------------------------------------------------------------------------------- +QVariant VSimplePoint::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value) +{ + if (change == QGraphicsItem::ItemSelectedChange) + { + namePoint->blockSignals(true); + namePoint->setSelected(value.toBool()); + namePoint->blockSignals(false); + emit Selected(value.toBool(), id); + } + + return QGraphicsEllipseItem::itemChange(change, value); +} + //--------------------------------------------------------------------------------------------------------------------- // cppcheck-suppress unusedFunction QColor VSimplePoint::GetCurrentColor() const diff --git a/src/libs/vwidgets/vsimplepoint.h b/src/libs/vwidgets/vsimplepoint.h index cba340a0b..c412ee594 100644 --- a/src/libs/vwidgets/vsimplepoint.h +++ b/src/libs/vwidgets/vsimplepoint.h @@ -65,6 +65,7 @@ signals: * @param id point id. */ void Choosed(quint32 id); + void Selected(bool selected, quint32 id); void ShowContextMenu(QGraphicsSceneContextMenuEvent * event); void Delete(); void NameChangedPosition(const QPointF &pos); @@ -72,14 +73,16 @@ signals: public slots: void DeleteFromLabel(); void PointChoosed(); + void PointSelected(bool selected); void ChangedPosition(const QPointF &pos); void ContextMenu(QGraphicsSceneContextMenuEvent * event); protected: - virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; - virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; - virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; - virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void mousePressEvent( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void mouseReleaseEvent ( QGraphicsSceneMouseEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverEnterEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual void hoverLeaveEvent ( QGraphicsSceneHoverEvent * event ) Q_DECL_OVERRIDE; + virtual QVariant itemChange ( GraphicsItemChange change, const QVariant &value ) Q_DECL_OVERRIDE; private: Q_DISABLE_COPY(VSimplePoint) From d73256f1196f6487693d5aac814f1aa829f4e8d3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Tue, 5 Apr 2016 20:53:49 +0300 Subject: [PATCH 03/12] The method CreateGroup. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 5 +-- src/app/valentina/xml/vpattern.cpp | 4 +-- src/libs/ifc/xml/vabstractpattern.cpp | 52 +++++++++++++++++++++++++-- src/libs/ifc/xml/vabstractpattern.h | 6 ++++ src/libs/ifc/xml/vdomdocument.cpp | 6 ++-- src/libs/vmisc/def.cpp | 2 ++ src/libs/vmisc/def.h | 2 ++ 7 files changed, 66 insertions(+), 11 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index b37aab18c..fad3d9e82 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1012,10 +1012,7 @@ void MainWindow::ClosedDialogGroup(int result) DialogGroup *dialog = qobject_cast(dialogTool); SCASSERT(dialog != nullptr); - const QString name = dialog->GetName(); - const QMap group = dialog->GetGroup(); - const quint32 id = pattern->getNextId(); - doc->AddGroup(id, name, group); + doc->AddGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup()); } ArrowTool(); } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 33d8c6182..6816d7e4e 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -2882,7 +2882,7 @@ bool VPattern::IsDefCustom() const const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - return GetParametrBool(domElement, AttrCustom, QStringLiteral("false")); + return GetParametrBool(domElement, AttrCustom, falseStr); } else { @@ -3051,7 +3051,7 @@ bool VPattern::IsReadOnly() const return false; } - return GetParametrBool(pattern, AttrReadOnly, QStringLiteral("false")); + return GetParametrBool(pattern, AttrReadOnly, falseStr); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index 2709dbe32..f7f50a77e 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -43,6 +43,8 @@ const QString VAbstractPattern::TagMeasurements = QStringLiteral("measurements") const QString VAbstractPattern::TagIncrements = QStringLiteral("increments"); const QString VAbstractPattern::TagIncrement = QStringLiteral("increment"); const QString VAbstractPattern::TagDraw = QStringLiteral("draw"); +const QString VAbstractPattern::TagGroups = QStringLiteral("groups"); +const QString VAbstractPattern::TagItem = QStringLiteral("item"); const QString VAbstractPattern::TagPoint = QStringLiteral("point"); const QString VAbstractPattern::TagLine = QStringLiteral("line"); const QString VAbstractPattern::TagSpline = QStringLiteral("spline"); @@ -54,6 +56,9 @@ const QString VAbstractPattern::TagSizes = QStringLiteral("sizes"); const QString VAbstractPattern::TagUnit = QStringLiteral("unit"); const QString VAbstractPattern::AttrName = QStringLiteral("name"); +const QString VAbstractPattern::AttrVisible = QStringLiteral("visible"); +const QString VAbstractPattern::AttrObject = QStringLiteral("object"); +const QString VAbstractPattern::AttrTool = QStringLiteral("tool"); const QString VAbstractPattern::AttrType = QStringLiteral("type"); const QString VAbstractPattern::AttrAll = QStringLiteral("all"); @@ -593,7 +598,7 @@ QMap VAbstractPattern::GetGradationHeights() const const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - const QString defValue = QStringLiteral("true"); + const QString defValue = trueStr; switch (gTags.indexOf(domElement.tagName())) { case 0: // TagHeights @@ -759,7 +764,7 @@ QMap VAbstractPattern::GetGradationSizes() const const QDomElement domElement = domNode.toElement(); if (domElement.isNull() == false) { - const QString defValue = QStringLiteral("true"); + const QString defValue = trueStr; switch (gTags.indexOf(domElement.tagName())) { case 0: // TagHeights @@ -1356,8 +1361,51 @@ QDomElement VAbstractPattern::GetDraw(const QString &name) const return QDomElement(); } +//--------------------------------------------------------------------------------------------------------------------- +QDomElement VAbstractPattern::CreateGroups() +{ + QDomElement draw; + if (GetActivDrawElement(draw)) + { + QDomElement groups = draw.firstChildElement(TagGroups); + + if (groups.isNull()) + { + groups = createElement(TagGroups); + draw.appendChild(groups); + } + + return groups; + } + return QDomElement(); +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap &group) { + if (id == NULL_ID || group.isEmpty()) + { + return; + } + QDomElement groups = CreateGroups(); + + if (groups.isNull()) + { + return; + } + + groups.setAttribute(AttrId, id); + groups.setAttribute(AttrName, name); + groups.setAttribute(AttrVisible, trueStr); + + auto i = group.constBegin(); + while (i != group.constEnd()) + { + QDomElement item = createElement(TagItem); + item.setAttribute(AttrObject, i.key()); + item.setAttribute(AttrTool, i.value()); + groups.appendChild(item); + ++i; + } } diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index e7ba57630..15321da9e 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -114,6 +114,7 @@ public: QDomElement GetDraw(const QString &name) const; + QDomElement CreateGroups(); void AddGroup(quint32 id, const QString &name, const QMap &group); static const QString TagPattern; @@ -127,6 +128,8 @@ public: static const QString TagIncrements; static const QString TagIncrement; static const QString TagDraw; + static const QString TagGroups; + static const QString TagItem; static const QString TagPoint; static const QString TagLine; static const QString TagSpline; @@ -138,6 +141,9 @@ public: static const QString TagUnit; static const QString AttrName; + static const QString AttrVisible; + static const QString AttrObject; + static const QString AttrTool; static const QString AttrType; static const QString AttrAll; diff --git a/src/libs/ifc/xml/vdomdocument.cpp b/src/libs/ifc/xml/vdomdocument.cpp index 59215996b..f0d6bae55 100644 --- a/src/libs/ifc/xml/vdomdocument.cpp +++ b/src/libs/ifc/xml/vdomdocument.cpp @@ -255,7 +255,7 @@ bool VDomDocument::GetParametrBool(const QDomElement &domElement, const QString //--------------------------------------------------------------------------------------------------------------------- NodeUsage VDomDocument::GetParametrUsage(const QDomElement &domElement, const QString &name) const { - const bool value = GetParametrBool(domElement, name, QStringLiteral("true")); + const bool value = GetParametrBool(domElement, name, trueStr); if (value) { return NodeUsage::InUse; @@ -271,11 +271,11 @@ void VDomDocument::SetParametrUsage(QDomElement &domElement, const QString &name { if (value == NodeUsage::InUse) { - domElement.setAttribute(name, QStringLiteral("true")); + domElement.setAttribute(name, trueStr); } else { - domElement.setAttribute(name, QStringLiteral("false")); + domElement.setAttribute(name, falseStr); } } diff --git a/src/libs/vmisc/def.cpp b/src/libs/vmisc/def.cpp index 3995185dd..e94baca4f 100644 --- a/src/libs/vmisc/def.cpp +++ b/src/libs/vmisc/def.cpp @@ -408,6 +408,8 @@ const QString cursorArrowCloseHand = QStringLiteral("://cursor/cursor-arrow-clos // From documantation: If you use QStringLiteral you should avoid declaring the same literal in multiple places: This // furthermore blows up the binary sizes. const QString degreeSymbol = QStringLiteral("°"); +const QString trueStr = QStringLiteral("true"); +const QString falseStr = QStringLiteral("false"); //--------------------------------------------------------------------------------------------------------------------- void SetOverrideCursor(const QString &pixmapPath, int hotX, int hotY) diff --git a/src/libs/vmisc/def.h b/src/libs/vmisc/def.h index 5083bbb38..521492ba6 100644 --- a/src/libs/vmisc/def.h +++ b/src/libs/vmisc/def.h @@ -584,6 +584,8 @@ extern const QString cursorArrowOpenHand; extern const QString cursorArrowCloseHand; extern const QString degreeSymbol; +extern const QString trueStr; +extern const QString falseStr; void SetOverrideCursor(const QString & pixmapPath, int hotX = -1, int hotY = -1); void RestoreOverrideCursor(const QString & pixmapPath); From cb67249b54af15f7e9dc2bf06e31470cebb4cdc5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 6 Apr 2016 12:03:34 +0300 Subject: [PATCH 04/12] New undo command Add Group. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 8 +- src/app/valentina/xml/vpattern.cpp | 6 +- src/app/valentina/xml/vpattern.h | 4 +- src/libs/ifc/xml/vabstractpattern.cpp | 121 +++++++++++++++--- src/libs/ifc/xml/vabstractpattern.h | 9 +- .../drawTools/toolcurve/vabstractspline.cpp | 7 + .../drawTools/toolcurve/vabstractspline.h | 1 + .../tooldoublepoint/vtooldoublepoint.cpp | 13 ++ .../tooldoublepoint/vtooldoublepoint.h | 1 + .../toolsinglepoint/vtoolsinglepoint.cpp | 7 + .../toolsinglepoint/vtoolsinglepoint.h | 1 + src/libs/vtools/tools/drawTools/vtoolline.cpp | 7 + src/libs/vtools/tools/drawTools/vtoolline.h | 1 + .../tools/nodeDetails/vabstractnode.cpp | 7 + .../vtools/tools/nodeDetails/vabstractnode.h | 2 + src/libs/vtools/tools/vdatatool.h | 11 +- src/libs/vtools/tools/vtooldetail.cpp | 7 + src/libs/vtools/tools/vtooldetail.h | 1 + src/libs/vtools/tools/vtooluniondetails.cpp | 7 + src/libs/vtools/tools/vtooluniondetails.h | 1 + src/libs/vtools/undocommands/addgroup.cpp | 104 +++++++++++++++ src/libs/vtools/undocommands/addgroup.h | 47 +++++++ src/libs/vtools/undocommands/undocommands.pri | 6 +- 23 files changed, 348 insertions(+), 31 deletions(-) create mode 100644 src/libs/vtools/undocommands/addgroup.cpp create mode 100644 src/libs/vtools/undocommands/addgroup.h diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index fad3d9e82..6e13b293c 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -54,6 +54,7 @@ #include "tools/vtooldetail.h" #include "tools/vtooluniondetails.h" #include "dialogs/dialogs.h" +#include "../vtools/undocommands/addgroup.h" #include #include @@ -1012,7 +1013,12 @@ void MainWindow::ClosedDialogGroup(int result) DialogGroup *dialog = qobject_cast(dialogTool); SCASSERT(dialog != nullptr); - doc->AddGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup()); + const QDomElement group = doc->CreateGroup(pattern->getNextId(), dialog->GetName(), dialog->GetGroup()); + if (not group.isNull()) + { + AddGroup *addGroup = new AddGroup(group, doc); + qApp->getUndoStack()->push(addGroup); + } } ArrowTool(); } diff --git a/src/app/valentina/xml/vpattern.cpp b/src/app/valentina/xml/vpattern.cpp index 6816d7e4e..f0485fd95 100644 --- a/src/app/valentina/xml/vpattern.cpp +++ b/src/app/valentina/xml/vpattern.cpp @@ -466,7 +466,7 @@ void VPattern::customEvent(QEvent *event) */ void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse) { - QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails; + QStringList tags = QStringList() << TagCalculation << TagModeling << TagDetails << TagGroups; QDomNode domNode = node.firstChild(); while (domNode.isNull() == false) { @@ -490,6 +490,10 @@ void VPattern::ParseDrawElement(const QDomNode &node, const Document &parse) qCDebug(vXML, "Tag details."); ParseDetails(domElement, parse); break; + case 3: // TagGroups + qCDebug(vXML, "Tag groups."); + ParseGroups(domElement); + break; default: VException e(tr("Wrong tag name '%1'.").arg(domElement.tagName())); throw e; diff --git a/src/app/valentina/xml/vpattern.h b/src/app/valentina/xml/vpattern.h index c65ccb6d1..92c57cd13 100644 --- a/src/app/valentina/xml/vpattern.h +++ b/src/app/valentina/xml/vpattern.h @@ -112,9 +112,9 @@ private: void ParseDrawElement(const QDomNode& node, const Document &parse); void ParseDrawMode(const QDomNode& node, const Document &parse, const Draw &mode); - void ParseDetailElement(const QDomElement &domElement, - const Document &parse); + void ParseDetailElement(const QDomElement &domElement, const Document &parse); void ParseDetails(const QDomElement &domElement, const Document &parse); + void ParsePointElement(VMainGraphicsScene *scene, QDomElement &domElement, const Document &parse, const QString &type); void ParseLineElement(VMainGraphicsScene *scene, const QDomElement& domElement, diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index f7f50a77e..c532ce063 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -31,6 +31,8 @@ #include "exception/vexceptionemptyparameter.h" #include "vpatternconverter.h" #include "../qmuparser/qmutokenparser.h" +#include "../exception/vexceptionobjecterror.h" +#include "../vtools/tools/vdatatool.h" const QString VAbstractPattern::TagPattern = QStringLiteral("pattern"); const QString VAbstractPattern::TagCalculation = QStringLiteral("calculation"); @@ -44,7 +46,8 @@ const QString VAbstractPattern::TagIncrements = QStringLiteral("increments"); const QString VAbstractPattern::TagIncrement = QStringLiteral("increment"); const QString VAbstractPattern::TagDraw = QStringLiteral("draw"); const QString VAbstractPattern::TagGroups = QStringLiteral("groups"); -const QString VAbstractPattern::TagItem = QStringLiteral("item"); +const QString VAbstractPattern::TagGroup = QStringLiteral("group"); +const QString VAbstractPattern::TagGroupItem = QStringLiteral("item"); const QString VAbstractPattern::TagPoint = QStringLiteral("point"); const QString VAbstractPattern::TagLine = QStringLiteral("line"); const QString VAbstractPattern::TagSpline = QStringLiteral("spline"); @@ -292,6 +295,54 @@ bool VAbstractPattern::GetActivNodeElement(const QString &name, QDomElement &ele return false; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::ParseGroups(const QDomElement &domElement) +{ + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + + QMap itemTool; + QMap itemVisibility; + + QDomNode domNode = domElement.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement domElement = domNode.toElement(); + if (domElement.isNull() == false) + { + if (domElement.tagName() == TagGroup) + { + const QPair > groupData = ParseItemElement(domElement); + const QMap group = groupData.second; + auto i = group.constBegin(); + while (i != group.constEnd()) + { + if (not itemTool.contains(i.key())) + { + itemTool.insert(i.key(), i.value()); + } + + const bool previous = itemVisibility.value(i.key(), true); + itemVisibility.insert(i.key(), previous || groupData.first); + } + } + } + } + domNode = domNode.nextSibling(); + } + + auto i = itemTool.constBegin(); + while (i != itemTool.constEnd()) + { + if (tools.contains(i.value())) + { + VDataTool* tool = tools.value(i.value()); + tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true)); + } + } +} + //--------------------------------------------------------------------------------------------------------------------- int VAbstractPattern::CountPP() const { @@ -1325,6 +1376,44 @@ bool VAbstractPattern::IsFunction(const QString &token) const return false; } +//--------------------------------------------------------------------------------------------------------------------- +QPair > VAbstractPattern::ParseItemElement(const QDomElement &domElement) +{ + Q_ASSERT_X(not domElement.isNull(), Q_FUNC_INFO, "domElement is null"); + + try + { + const bool visible = GetParametrBool(domElement, AttrVisible, trueStr); + + QMap items; + + const QDomNodeList nodeList = domElement.childNodes(); + const qint32 num = nodeList.size(); + for (qint32 i = 0; i < num; ++i) + { + const QDomElement element = nodeList.at(i).toElement(); + if (not element.isNull() && element.tagName() == TagGroupItem) + { + const quint32 object = GetParametrUInt(element, AttrObject, NULL_ID_STR); + const quint32 tool = GetParametrUInt(element, AttrTool, NULL_ID_STR); + items.insert(object, tool); + } + } + + QPair > group; + group.first = visible; + group.second = items; + + return group; + } + catch (const VExceptionBadId &e) + { + VExceptionObjectError excep(tr("Error creating or updating group"), domElement); + excep.AddMoreInformation(e.ErrorMessage()); + throw excep; + } +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief IsModified state of the document for cases that do not cover QUndoStack. @@ -1381,31 +1470,27 @@ QDomElement VAbstractPattern::CreateGroups() } //--------------------------------------------------------------------------------------------------------------------- -void VAbstractPattern::AddGroup(quint32 id, const QString &name, const QMap &group) +QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const QMap &groupData) { - if (id == NULL_ID || group.isEmpty()) + if (id == NULL_ID || groupData.isEmpty()) { - return; + return QDomElement(); } - QDomElement groups = CreateGroups(); + QDomElement group = createElement(TagGroup); + group.setAttribute(AttrId, id); + group.setAttribute(AttrName, name); + group.setAttribute(AttrVisible, trueStr); - if (groups.isNull()) + auto i = groupData.constBegin(); + while (i != groupData.constEnd()) { - return; - } - - groups.setAttribute(AttrId, id); - groups.setAttribute(AttrName, name); - groups.setAttribute(AttrVisible, trueStr); - - auto i = group.constBegin(); - while (i != group.constEnd()) - { - QDomElement item = createElement(TagItem); + QDomElement item = createElement(TagGroupItem); item.setAttribute(AttrObject, i.key()); item.setAttribute(AttrTool, i.value()); - groups.appendChild(item); + group.appendChild(item); ++i; } + + return group; } diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 15321da9e..77ada5d8a 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -67,6 +67,8 @@ public: bool GetActivDrawElement(QDomElement &element) const; bool GetActivNodeElement(const QString& name, QDomElement& element) const; + void ParseGroups(const QDomElement &domElement); + quint32 getCursor() const; void setCursor(const quint32 &value); @@ -115,7 +117,7 @@ public: QDomElement GetDraw(const QString &name) const; QDomElement CreateGroups(); - void AddGroup(quint32 id, const QString &name, const QMap &group); + QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData); static const QString TagPattern; static const QString TagCalculation; @@ -129,7 +131,8 @@ public: static const QString TagIncrement; static const QString TagDraw; static const QString TagGroups; - static const QString TagItem; + static const QString TagGroup; + static const QString TagGroupItem; static const QString TagPoint; static const QString TagLine; static const QString TagSpline; @@ -281,6 +284,8 @@ private: bool IsVariable(const QString& token) const; bool IsPostfixOperator(const QString& token) const; bool IsFunction(const QString& token) const; + + QPair > ParseItemElement(const QDomElement &domElement); }; //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp index 042a3f640..7d7b5f03c 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.cpp @@ -334,3 +334,10 @@ QString VAbstractSpline::name() const { return ObjectName(id); } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractSpline::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + setVisible(visible); +} diff --git a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h index 140276363..89f2548f2 100644 --- a/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h +++ b/src/libs/vtools/tools/drawTools/toolcurve/vabstractspline.h @@ -53,6 +53,7 @@ public: QString name() const; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp index b8eaf3359..8e7729788 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.cpp @@ -92,6 +92,19 @@ void VToolDoublePoint::SetEnabled(bool enabled) SetToolEnabled(this, enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDoublePoint::GroupVisibility(quint32 object, bool visible) +{ + if (object == p1id) + { + firstPoint->setVisible(visible); + } + else if (object == p2id) + { + secondPoint->setVisible(visible); + } +} + //--------------------------------------------------------------------------------------------------------------------- void VToolDoublePoint::Label1ChangePosition(const QPointF &pos) { diff --git a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h index c1cae4c8f..8612864e1 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/tooldoublepoint/vtooldoublepoint.h @@ -56,6 +56,7 @@ public: void SetEnabled(bool enabled); + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: void Label1ChangePosition(const QPointF &pos); void Label2ChangePosition(const QPointF &pos); diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index 3e4f79b2c..b41c53e4b 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -96,6 +96,13 @@ void VToolSinglePoint::SetEnabled(bool enabled) SetToolEnabled(lineName, enabled); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + setVisible(visible); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief NameChangePosition handle change posion point label. diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 785ed98f9..9c0cf5710 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -53,6 +53,7 @@ public: void SetEnabled(bool enabled); + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: void NameChangePosition(const QPointF &pos); virtual void SetFactor(qreal factor) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/drawTools/vtoolline.cpp b/src/libs/vtools/tools/drawTools/vtoolline.cpp index 9e66ec18b..acadc4f00 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.cpp +++ b/src/libs/vtools/tools/drawTools/vtoolline.cpp @@ -470,6 +470,13 @@ void VToolLine::SetLineColor(const QString &value) SaveOption(obj); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolLine::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + setVisible(visible); +} + //--------------------------------------------------------------------------------------------------------------------- quint32 VToolLine::GetFirstPoint() const { diff --git a/src/libs/vtools/tools/drawTools/vtoolline.h b/src/libs/vtools/tools/drawTools/vtoolline.h index 084c92d80..a554c4248 100644 --- a/src/libs/vtools/tools/drawTools/vtoolline.h +++ b/src/libs/vtools/tools/drawTools/vtoolline.h @@ -63,6 +63,7 @@ public: virtual void SetTypeLine(const QString &value) Q_DECL_OVERRIDE; virtual void SetLineColor(const QString &value) Q_DECL_OVERRIDE; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void ShowTool(quint32 id, bool enable) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp index 2435b77f9..fc7662e9b 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.cpp @@ -108,6 +108,13 @@ void VAbstractNode::SetParentType(const ParentType &value) parentType = value; } +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractNode::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + Q_UNUSED(visible); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief AddToModeling add tag to modeling tag current pattern peace. diff --git a/src/libs/vtools/tools/nodeDetails/vabstractnode.h b/src/libs/vtools/tools/nodeDetails/vabstractnode.h index 037eef068..9ebc987ce 100644 --- a/src/libs/vtools/tools/nodeDetails/vabstractnode.h +++ b/src/libs/vtools/tools/nodeDetails/vabstractnode.h @@ -54,6 +54,8 @@ public: ParentType GetParentType() const; void SetParentType(const ParentType &value); + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; + protected: ParentType parentType; protected: diff --git a/src/libs/vtools/tools/vdatatool.h b/src/libs/vtools/tools/vdatatool.h index 6ebd29b38..3b939b07e 100644 --- a/src/libs/vtools/tools/vdatatool.h +++ b/src/libs/vtools/tools/vdatatool.h @@ -46,11 +46,12 @@ class VDataTool : public QObject public: explicit VDataTool(VContainer *data, QObject *parent = nullptr); virtual ~VDataTool() Q_DECL_OVERRIDE; - VContainer getData() const; - void setData(const VContainer *value); - virtual quint32 referens() const; - virtual void incrementReferens(); - virtual void decrementReferens(); + VContainer getData() const; + void setData(const VContainer *value); + virtual quint32 referens() const; + virtual void incrementReferens(); + virtual void decrementReferens(); + virtual void GroupVisibility(quint32 object, bool visible)=0; protected: /** @brief data container with data */ VContainer data; diff --git a/src/libs/vtools/tools/vtooldetail.cpp b/src/libs/vtools/tools/vtooldetail.cpp index d876c9fef..62252cba3 100644 --- a/src/libs/vtools/tools/vtooldetail.cpp +++ b/src/libs/vtools/tools/vtooldetail.cpp @@ -628,6 +628,13 @@ void VToolDetail::ShowVisualization(bool show) Q_UNUSED(show) } +//--------------------------------------------------------------------------------------------------------------------- +void VToolDetail::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + Q_UNUSED(visible); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief RefreshGeometry refresh item on scene. diff --git a/src/libs/vtools/tools/vtooldetail.h b/src/libs/vtools/tools/vtooldetail.h index 322b5fee9..c93769c1e 100644 --- a/src/libs/vtools/tools/vtooldetail.h +++ b/src/libs/vtools/tools/vtooldetail.h @@ -86,6 +86,7 @@ public: enum { Type = UserType + static_cast(Tool::Detail)}; virtual QString getTagName() const Q_DECL_OVERRIDE; virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: virtual void FullUpdateFromFile () Q_DECL_OVERRIDE; virtual void FullUpdateFromGuiOk(int result); diff --git a/src/libs/vtools/tools/vtooluniondetails.cpp b/src/libs/vtools/tools/vtooluniondetails.cpp index d895ed931..f0706e462 100644 --- a/src/libs/vtools/tools/vtooluniondetails.cpp +++ b/src/libs/vtools/tools/vtooluniondetails.cpp @@ -488,6 +488,13 @@ void VToolUnionDetails::decrementReferens() } } +//--------------------------------------------------------------------------------------------------------------------- +void VToolUnionDetails::GroupVisibility(quint32 object, bool visible) +{ + Q_UNUSED(object); + Q_UNUSED(visible); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief Create help create tool from GUI. diff --git a/src/libs/vtools/tools/vtooluniondetails.h b/src/libs/vtools/tools/vtooluniondetails.h index 058d4ee79..af18419ac 100644 --- a/src/libs/vtools/tools/vtooluniondetails.h +++ b/src/libs/vtools/tools/vtooluniondetails.h @@ -84,6 +84,7 @@ public: virtual void ShowVisualization(bool show) Q_DECL_OVERRIDE; virtual void incrementReferens() Q_DECL_OVERRIDE; virtual void decrementReferens() Q_DECL_OVERRIDE; + virtual void GroupVisibility(quint32 object, bool visible) Q_DECL_OVERRIDE; public slots: /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/libs/vtools/undocommands/addgroup.cpp b/src/libs/vtools/undocommands/addgroup.cpp new file mode 100644 index 000000000..b4b86ef90 --- /dev/null +++ b/src/libs/vtools/undocommands/addgroup.cpp @@ -0,0 +1,104 @@ +/************************************************************************ + ** + ** @file addgroup.cpp + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "addgroup.h" +#include "../vwidgets/vmaingraphicsscene.h" +#include "../vwidgets/vmaingraphicsview.h" +#include "../vmisc/vabstractapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +AddGroup::AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent) + : VUndoCommand(xml, doc, parent), nameActivDraw(doc->GetNameActivPP()) +{ + setText(tr("add group")); + nodeId = doc->GetParametrId(xml); +} + +//--------------------------------------------------------------------------------------------------------------------- +AddGroup::~AddGroup() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddGroup::undo() +{ + qCDebug(vUndo, "Undo."); + + doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change + + QDomElement groups = doc->CreateGroups(); + if (not groups.isNull()) + { + QDomElement group = doc->elementById(nodeId); + if (group.isElement()) + { + group.setAttribute(VAbstractPattern::AttrVisible, trueStr); + doc->ParseGroups(groups); + if (groups.removeChild(group).isNull()) + { + qCDebug(vUndo, "Can't delete group."); + return; + } + } + else + { + qCDebug(vUndo, "Can't get group by id = %u.", nodeId); + return; + } + } + else + { + qCDebug(vUndo, "Can't get tag Groups."); + return; + } + + VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); + doc->SetCurrentPP(nameActivDraw);//Return current pattern piece after undo +} + +//--------------------------------------------------------------------------------------------------------------------- +void AddGroup::redo() +{ + qCDebug(vUndo, "Redo."); + + doc->ChangeActivPP(nameActivDraw);//Without this user will not see this change + + QDomElement groups = doc->CreateGroups(); + if (not groups.isNull()) + { + groups.appendChild(xml); + doc->ParseGroups(groups); + } + else + { + qCDebug(vUndo, "Can't get tag Groups."); + return; + } + + VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); +} diff --git a/src/libs/vtools/undocommands/addgroup.h b/src/libs/vtools/undocommands/addgroup.h new file mode 100644 index 000000000..ae3273253 --- /dev/null +++ b/src/libs/vtools/undocommands/addgroup.h @@ -0,0 +1,47 @@ +/************************************************************************ + ** + ** @file addgroup.h + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef ADDGROUP_H +#define ADDGROUP_H + +#include "vundocommand.h" + +class AddGroup : public VUndoCommand +{ + Q_OBJECT +public: + AddGroup(const QDomElement &xml, VAbstractPattern *doc, QUndoCommand *parent = nullptr); + virtual ~AddGroup(); + virtual void undo() Q_DECL_OVERRIDE; + virtual void redo() Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(AddGroup) + const QString nameActivDraw; +}; + +#endif // ADDGROUP_H diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri index 46d553b32..e4fed2b63 100644 --- a/src/libs/vtools/undocommands/undocommands.pri +++ b/src/libs/vtools/undocommands/undocommands.pri @@ -18,7 +18,8 @@ HEADERS += \ $$PWD/vundocommand.h \ $$PWD/renamepp.h \ $$PWD/movelabel.h \ - $$PWD/movedoublelabel.h + $$PWD/movedoublelabel.h \ + $$PWD/addgroup.h SOURCES += \ $$PWD/addtocalc.cpp \ @@ -37,4 +38,5 @@ SOURCES += \ $$PWD/vundocommand.cpp \ $$PWD/renamepp.cpp \ $$PWD/movelabel.cpp \ - $$PWD/movedoublelabel.cpp + $$PWD/movedoublelabel.cpp \ + $$PWD/addgroup.cpp From a8feb5d0c03b869bc1e2c18847b7b9d244d075dd Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 6 Apr 2016 12:23:39 +0300 Subject: [PATCH 05/12] New undo command DelGroup. --HG-- branch : feature --- src/libs/vtools/undocommands/delgroup.cpp | 110 ++++++++++++++++++ src/libs/vtools/undocommands/delgroup.h | 47 ++++++++ src/libs/vtools/undocommands/undocommands.pri | 6 +- 3 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 src/libs/vtools/undocommands/delgroup.cpp create mode 100644 src/libs/vtools/undocommands/delgroup.h diff --git a/src/libs/vtools/undocommands/delgroup.cpp b/src/libs/vtools/undocommands/delgroup.cpp new file mode 100644 index 000000000..17ce0c0ce --- /dev/null +++ b/src/libs/vtools/undocommands/delgroup.cpp @@ -0,0 +1,110 @@ +/************************************************************************ + ** + ** @file delgroup.cpp + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "delgroup.h" +#include "../vwidgets/vmaingraphicsscene.h" +#include "../vwidgets/vmaingraphicsview.h" +#include "../vmisc/vabstractapplication.h" + +//--------------------------------------------------------------------------------------------------------------------- +DelGroup::DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent) + : VUndoCommand(QDomElement(), doc, parent), nameActivDraw(doc->GetNameActivPP()) +{ + setText(tr("delete group")); + nodeId = id; + xml = doc->CloneNodeById(nodeId); +} + +//--------------------------------------------------------------------------------------------------------------------- +DelGroup::~DelGroup() +{ +} + +//--------------------------------------------------------------------------------------------------------------------- +void DelGroup::undo() +{ + qCDebug(vUndo, "Undo."); + + doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change + + QDomElement groups = doc->CreateGroups(); + if (not groups.isNull()) + { + groups.appendChild(xml); + doc->ParseGroups(groups); + } + else + { + qCDebug(vUndo, "Can't get tag Groups."); + return; + } + + VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void DelGroup::redo() +{ + qCDebug(vUndo, "Redo."); + + //Keep first! + doc->SetCurrentPP(nameActivDraw);//Without this user will not see this change + QDomElement groups = doc->CreateGroups(); + if (not groups.isNull()) + { + QDomElement group = doc->elementById(nodeId); + if (group.isElement()) + { + group.setAttribute(VAbstractPattern::AttrVisible, trueStr); + doc->ParseGroups(groups); + if (groups.removeChild(group).isNull()) + { + qCDebug(vUndo, "Can't delete group."); + return; + } + + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + } + else + { + qCDebug(vUndo, "Can't get group by id = %u.", nodeId); + return; + } + } + else + { + qCDebug(vUndo, "Can't get tag Groups."); + return; + } + + VMainGraphicsView::NewSceneRect(qApp->getCurrentScene(), qApp->getSceneView()); +} diff --git a/src/libs/vtools/undocommands/delgroup.h b/src/libs/vtools/undocommands/delgroup.h new file mode 100644 index 000000000..fc8638445 --- /dev/null +++ b/src/libs/vtools/undocommands/delgroup.h @@ -0,0 +1,47 @@ +/************************************************************************ + ** + ** @file delgroup.h + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef DELGROUP_H +#define DELGROUP_H + +#include "vundocommand.h" + +class DelGroup : public VUndoCommand +{ + Q_OBJECT +public: + DelGroup(VAbstractPattern *doc, quint32 id, QUndoCommand *parent = nullptr); + virtual ~DelGroup(); + virtual void undo() Q_DECL_OVERRIDE; + virtual void redo() Q_DECL_OVERRIDE; +private: + Q_DISABLE_COPY(DelGroup) + const QString nameActivDraw; +}; + +#endif // DELGROUP_H diff --git a/src/libs/vtools/undocommands/undocommands.pri b/src/libs/vtools/undocommands/undocommands.pri index e4fed2b63..0ce6cb9ec 100644 --- a/src/libs/vtools/undocommands/undocommands.pri +++ b/src/libs/vtools/undocommands/undocommands.pri @@ -19,7 +19,8 @@ HEADERS += \ $$PWD/renamepp.h \ $$PWD/movelabel.h \ $$PWD/movedoublelabel.h \ - $$PWD/addgroup.h + $$PWD/addgroup.h \ + $$PWD/delgroup.h SOURCES += \ $$PWD/addtocalc.cpp \ @@ -39,4 +40,5 @@ SOURCES += \ $$PWD/renamepp.cpp \ $$PWD/movelabel.cpp \ $$PWD/movedoublelabel.cpp \ - $$PWD/addgroup.cpp + $$PWD/addgroup.cpp \ + $$PWD/delgroup.cpp From 9c63c4f794416a249ea0136ae8bf247a59565944 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 6 Apr 2016 12:36:33 +0300 Subject: [PATCH 06/12] The method SetGroupName. --HG-- branch : feature --- src/libs/ifc/xml/vabstractpattern.cpp | 32 +++++++++++++++++++++++ src/libs/ifc/xml/vabstractpattern.h | 1 + src/libs/vtools/undocommands/addgroup.cpp | 6 +++++ 3 files changed, 39 insertions(+) diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index c532ce063..d723c0365 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -1494,3 +1494,35 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const return group; } + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetGroupName(quint32 id, const QString &name) +{ + QDomElement groups = CreateGroups(); + if (not groups.isNull()) + { + QDomElement group = elementById(id); + if (group.isElement()) + { + group.setAttribute(AttrName, name); + modified = true; + emit patternChanged(false); + } + else + { + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + + qDebug("Can't get group by id = %u.", id); + return; + } + } + else + { + qDebug("Can't get tag Groups."); + return; + } +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 77ada5d8a..90e8c1b3c 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -118,6 +118,7 @@ public: QDomElement CreateGroups(); QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData); + void SetGroupName(quint32 id, const QString &name); static const QString TagPattern; static const QString TagCalculation; diff --git a/src/libs/vtools/undocommands/addgroup.cpp b/src/libs/vtools/undocommands/addgroup.cpp index b4b86ef90..2a5bdf65b 100644 --- a/src/libs/vtools/undocommands/addgroup.cpp +++ b/src/libs/vtools/undocommands/addgroup.cpp @@ -67,6 +67,12 @@ void AddGroup::undo() } else { + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + qCDebug(vUndo, "Can't get group by id = %u.", nodeId); return; } From fe3bd88c1776d76002984117e19d11097319b4f5 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Wed, 6 Apr 2016 14:40:44 +0300 Subject: [PATCH 07/12] Remember docks settings. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 51 ++++++++++++++++++++------ src/app/valentina/mainwindow.h | 6 +++ src/app/valentina/mainwindow.ui | 20 ++++++++++ src/app/valentina/mainwindowsnogui.cpp | 3 +- src/app/valentina/mainwindowsnogui.h | 1 + 5 files changed, 69 insertions(+), 12 deletions(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index 6e13b293c..a1e99b1b3 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -112,7 +112,10 @@ MainWindow::MainWindow(QWidget *parent) dialogTable(nullptr), dialogTool(nullptr), dialogHistory(nullptr), comboBoxDraws(nullptr), patternPieceLabel(nullptr), mode(Draw::Calculation), - currentDrawIndex(0), currentToolBoxIndex(0), drawMode(true), recentFileActs(), + currentDrawIndex(0), currentToolBoxIndex(0), + isDockToolOptionsVisible(true), + isDockGroupsVisible(true), + drawMode(true), recentFileActs(), separatorAct(nullptr), leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr), @@ -2061,7 +2064,8 @@ void MainWindow::ActionDraw(bool checked) } ui->dockWidgetLayoutPages->setVisible(false); - ui->dockWidgetToolOptions->setVisible(true); + ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); + ui->dockWidgetGroups->setVisible(isDockGroupsVisible); } else { @@ -2130,7 +2134,8 @@ void MainWindow::ActionDetails(bool checked) } ui->dockWidgetLayoutPages->setVisible(false); - ui->dockWidgetToolOptions->setVisible(true); + ui->dockWidgetToolOptions->setVisible(isDockToolOptionsVisible); + ui->dockWidgetGroups->setVisible(isDockGroupsVisible); helpLabel->setText(""); } @@ -2207,7 +2212,14 @@ void MainWindow::ActionLayout(bool checked) } ui->dockWidgetLayoutPages->setVisible(true); + + ui->dockWidgetToolOptions->blockSignals(true); ui->dockWidgetToolOptions->setVisible(false); + ui->dockWidgetToolOptions->blockSignals(false); + + ui->dockWidgetGroups->blockSignals(true); + ui->dockWidgetGroups->setVisible(false); + ui->dockWidgetGroups->blockSignals(false); ShowPaper(ui->listWidget->currentRow()); @@ -2704,6 +2716,7 @@ void MainWindow::SetEnableWidgets(bool enable) ui->actionUnloadMeasurements->setEnabled(enable && designStage); actionDockWidgetToolOptions->setEnabled(enable && designStage); + actionDockWidgetGroups->setEnabled(enable && designStage); undoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canUndo()); redoAction->setEnabled(enable && designStage && qApp->getUndoStack()->canRedo()); @@ -2911,6 +2924,18 @@ void MainWindow::ChangedHeight(const QString &text) } } +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::DockToolOptionsVisibilityChanged(bool visible) +{ + isDockToolOptionsVisible = visible; +} + +//--------------------------------------------------------------------------------------------------------------------- +void MainWindow::DockGropsVisibilityChanged(bool visible) +{ + isDockGroupsVisible = visible; +} + //--------------------------------------------------------------------------------------------------------------------- void MainWindow::SetDefaultHeight() { @@ -3229,6 +3254,9 @@ void MainWindow::ReadSettings() // Text under tool buton icon ToolBarStyles(); + + isDockToolOptionsVisible = ui->dockWidgetToolOptions->isVisible(); + isDockGroupsVisible = ui->dockWidgetGroups->isVisible(); } //--------------------------------------------------------------------------------------------------------------------- @@ -3335,13 +3363,6 @@ void MainWindow::CreateMenus() separatorAct->setSeparator(true); ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); - //Add dock - actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction(); - ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions); - - separatorAct = new QAction(this); - separatorAct->setSeparator(true); - ui->menuPatternPiece->insertAction(ui->actionPattern_properties, separatorAct); AddDocks(); } @@ -3514,7 +3535,15 @@ void MainWindow::LastUsedTool() //--------------------------------------------------------------------------------------------------------------------- void MainWindow::AddDocks() { - ui->menuPatternPiece->insertAction(ui->actionPattern_properties, ui->dockWidgetToolOptions->toggleViewAction()); + //Add dock + actionDockWidgetToolOptions = ui->dockWidgetToolOptions->toggleViewAction(); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetToolOptions); + connect(ui->dockWidgetToolOptions, &QDockWidget::visibilityChanged, this, + &MainWindow::DockToolOptionsVisibilityChanged); + + actionDockWidgetGroups = ui->dockWidgetGroups->toggleViewAction(); + ui->menuPatternPiece->insertAction(ui->actionPattern_properties, actionDockWidgetGroups); + connect(ui->dockWidgetGroups, &QDockWidget::visibilityChanged, this, &MainWindow::DockGropsVisibilityChanged); separatorAct = new QAction(this); separatorAct->setSeparator(true); diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 52602520e..673dcdf63 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -204,6 +204,9 @@ private slots: void ChangedSize(const QString &text); void ChangedHeight(const QString & text); + void DockToolOptionsVisibilityChanged(bool visible); + void DockGropsVisibilityChanged(bool visible); + private: Q_DISABLE_COPY(MainWindow) /** @brief ui keeps information about user interface */ @@ -255,6 +258,9 @@ private: /** @brief currentToolBoxIndex save current set of tools. */ qint32 currentToolBoxIndex; + bool isDockToolOptionsVisible; + bool isDockGroupsVisible; + /** @brief drawMode true if we current draw scene. */ bool drawMode; diff --git a/src/app/valentina/mainwindow.ui b/src/app/valentina/mainwindow.ui index fdb501f67..51eb11f32 100644 --- a/src/app/valentina/mainwindow.ui +++ b/src/app/valentina/mainwindow.ui @@ -938,6 +938,14 @@ + + + 0 + 0 + 130 + 356 + + :/icon/16x16/operations.png:/icon/16x16/operations.png @@ -1455,6 +1463,18 @@ + + + true + + + Groups + + + 2 + + + diff --git a/src/app/valentina/mainwindowsnogui.cpp b/src/app/valentina/mainwindowsnogui.cpp index e5137b537..2cbf03c0f 100644 --- a/src/app/valentina/mainwindowsnogui.cpp +++ b/src/app/valentina/mainwindowsnogui.cpp @@ -60,7 +60,8 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent) : QMainWindow(parent), listDetails(QVector()), currentScene(nullptr), tempSceneLayout(nullptr), pattern(new VContainer(qApp->TrVars(), qApp->patternUnitP())), doc(nullptr), papers(QList()), shadows(QList()), scenes(QList()), details(QList >()), - undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), curFile(QString()), + undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr), + curFile(QString()), isLayoutStale(true), margins(), paperSize(), isTiled(false) { InitTempLayoutScene(); diff --git a/src/app/valentina/mainwindowsnogui.h b/src/app/valentina/mainwindowsnogui.h index 1cb1d1926..f4aea3bb0 100644 --- a/src/app/valentina/mainwindowsnogui.h +++ b/src/app/valentina/mainwindowsnogui.h @@ -83,6 +83,7 @@ protected: QAction *undoAction; QAction *redoAction; QAction *actionDockWidgetToolOptions; + QAction *actionDockWidgetGroups; /** @brief fileName name current pattern file. */ QString curFile; From 48e411a3ce97a57b27279153fd56c9e7f8356c94 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 Apr 2016 17:57:53 +0300 Subject: [PATCH 08/12] Working with group widget. --HG-- branch : feature --- src/app/valentina/dialogs/dialogs.pri | 9 +- src/app/valentina/dialogs/vwidgetgroups.cpp | 159 ++++++++++++++++++ src/app/valentina/dialogs/vwidgetgroups.h | 62 +++++++ src/app/valentina/dialogs/vwidgetgroups.ui | 58 +++++++ src/app/valentina/mainwindow.cpp | 20 ++- src/app/valentina/mainwindow.h | 4 +- src/libs/ifc/xml/vabstractpattern.cpp | 117 ++++++++++++- src/libs/ifc/xml/vabstractpattern.h | 7 +- src/libs/vmisc/share/resources/icon.qrc | 4 + .../share/resources/icon/16x16/closed_eye.png | Bin 0 -> 416 bytes .../resources/icon/16x16/closed_eye@2x.png | Bin 0 -> 668 bytes .../share/resources/icon/16x16/open_eye.png | Bin 0 -> 527 bytes .../resources/icon/16x16/open_eye@2x.png | Bin 0 -> 1107 bytes .../share/resources/icon/svg/closed_eye.svg | 99 +++++++++++ .../share/resources/icon/svg/open_eye.svg | 5 + .../toolsinglepoint/vtoolsinglepoint.cpp | 7 + .../toolsinglepoint/vtoolsinglepoint.h | 1 + src/libs/vtools/undocommands/addgroup.cpp | 2 + src/libs/vtools/undocommands/addgroup.h | 2 + src/libs/vtools/undocommands/delgroup.cpp | 2 + src/libs/vtools/undocommands/delgroup.h | 2 + 21 files changed, 545 insertions(+), 15 deletions(-) create mode 100644 src/app/valentina/dialogs/vwidgetgroups.cpp create mode 100644 src/app/valentina/dialogs/vwidgetgroups.h create mode 100644 src/app/valentina/dialogs/vwidgetgroups.ui create mode 100644 src/libs/vmisc/share/resources/icon/16x16/closed_eye.png create mode 100644 src/libs/vmisc/share/resources/icon/16x16/closed_eye@2x.png create mode 100644 src/libs/vmisc/share/resources/icon/16x16/open_eye.png create mode 100644 src/libs/vmisc/share/resources/icon/16x16/open_eye@2x.png create mode 100644 src/libs/vmisc/share/resources/icon/svg/closed_eye.svg create mode 100644 src/libs/vmisc/share/resources/icon/svg/open_eye.svg diff --git a/src/app/valentina/dialogs/dialogs.pri b/src/app/valentina/dialogs/dialogs.pri index f110de946..c5910f074 100644 --- a/src/app/valentina/dialogs/dialogs.pri +++ b/src/app/valentina/dialogs/dialogs.pri @@ -17,7 +17,8 @@ HEADERS += \ $$PWD/configpages/pathpage.h \ $$PWD/dialoglayoutsettings.h \ $$PWD/dialoglayoutprogress.h \ - $$PWD/dialogsavelayout.h + $$PWD/dialogsavelayout.h \ + $$PWD/vwidgetgroups.h SOURCES += \ $$PWD/dialogincrements.cpp \ @@ -33,7 +34,8 @@ SOURCES += \ $$PWD/configpages/pathpage.cpp \ $$PWD/dialoglayoutsettings.cpp \ $$PWD/dialoglayoutprogress.cpp \ - $$PWD/dialogsavelayout.cpp + $$PWD/dialogsavelayout.cpp \ + $$PWD/vwidgetgroups.cpp FORMS += \ $$PWD/dialogincrements.ui \ @@ -44,4 +46,5 @@ FORMS += \ $$PWD/dialogpatternxmledit.ui \ $$PWD/dialoglayoutsettings.ui \ $$PWD/dialoglayoutprogress.ui \ - $$PWD/dialogsavelayout.ui + $$PWD/dialogsavelayout.ui \ + $$PWD/vwidgetgroups.ui diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp new file mode 100644 index 000000000..3d5965a5f --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -0,0 +1,159 @@ +/************************************************************************ + ** + ** @file vwidgetgroups.cpp + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#include "vwidgetgroups.h" +#include "ui_vwidgetgroups.h" +#include "../vtools/dialogs/tools/dialoggroup.h" +#include "../vtools/undocommands/delgroup.h" + +#include + +//--------------------------------------------------------------------------------------------------------------------- +VWidgetGroups::VWidgetGroups(VAbstractPattern *doc, QWidget *parent) + : QWidget(parent), + ui(new Ui::VWidgetGroups), + doc(doc) +{ + ui->setupUi(this); + + FillTable(doc->GetGroups()); + + ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); + + connect(ui->tableWidget, &QTableWidget::cellClicked, this, &VWidgetGroups::GroupVisibilityChanged); + connect(ui->tableWidget, &QTableWidget::customContextMenuRequested, this, &VWidgetGroups::CtxMenu); +} + +//--------------------------------------------------------------------------------------------------------------------- +VWidgetGroups::~VWidgetGroups() +{ + delete ui; +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::GroupVisibilityChanged(int row, int column) +{ + if (column != 0) + { + return; + } + + QTableWidgetItem *item = ui->tableWidget->item(row, column); + const quint32 id = item->data(Qt::UserRole).toUInt(); + const bool visible = not doc->GetGroupVisivility(id); + doc->SetGroupVisivility(id, visible); + if (visible) + { + item->setIcon(QIcon("://icon/16x16/open_eye.png")); + } + else + { + item->setIcon(QIcon("://icon/16x16/closed_eye.png")); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::CtxMenu(const QPoint &pos) +{ + QTableWidgetItem *item = ui->tableWidget->itemAt(pos); + if(not item) + { + return; + } + + const int row = item->row(); + item = ui->tableWidget->item(row, 0); + const quint32 id = item->data(Qt::UserRole).toUInt(); + + QMenu *menu = new QMenu; + QAction *actionRename = menu->addAction(tr("Rename")); + QAction *actionDelete = menu->addAction(tr("Delete")); + QAction *selectedAction = menu->exec(ui->tableWidget->viewport()->mapToGlobal(pos)); + if (selectedAction == actionRename) + { + DialogGroup *dialog = new DialogGroup(new VContainer(qApp->TrVars(), qApp->patternUnitP()), NULL_ID, this); + dialog->SetName(doc->GetGroupName(id)); + const int result = dialog->exec(); + + if (result == QDialog::Accepted) + { + doc->SetGroupName(id, dialog->GetName()); + item = ui->tableWidget->item(row, 1); + item->setText(dialog->GetName()); + } + delete dialog; + } + else if (selectedAction == actionDelete) + { + DelGroup *delGroup = new DelGroup(doc, id); + connect(delGroup, &DelGroup::UpdateGroups, this, &VWidgetGroups::UpdateGroups); + qApp->getUndoStack()->push(delGroup); + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::UpdateGroups() +{ + FillTable(doc->GetGroups()); +} + +//--------------------------------------------------------------------------------------------------------------------- +void VWidgetGroups::FillTable(const QMap > &groups) +{ + ui->tableWidget->clear(); + + ui->tableWidget->setColumnCount(2); + ui->tableWidget->setRowCount(groups.size()); + qint32 currentRow = -1; + auto i = groups.constBegin(); + while (i != groups.constEnd()) + { + ++currentRow; + const QPair data = i.value(); + + QTableWidgetItem *item = new QTableWidgetItem(); + item->setTextAlignment(Qt::AlignHCenter); + if (data.second) + { + item->setIcon(QIcon("://icon/16x16/open_eye.png")); + } + else + { + item->setIcon(QIcon("://icon/16x16/closed_eye.png")); + } + item->setData(Qt::UserRole, i.key()); + ui->tableWidget->setItem(currentRow, 0, item); + + item = new QTableWidgetItem(data.first); + item->setTextAlignment(Qt::AlignLeft); + ui->tableWidget->setItem(currentRow, 1, item); + ++i; + } + ui->tableWidget->resizeColumnsToContents(); + ui->tableWidget->resizeRowsToContents(); +} diff --git a/src/app/valentina/dialogs/vwidgetgroups.h b/src/app/valentina/dialogs/vwidgetgroups.h new file mode 100644 index 000000000..5d46f7a57 --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetgroups.h @@ -0,0 +1,62 @@ +/************************************************************************ + ** + ** @file vwidgetgroups.h + ** @author Roman Telezhynskyi + ** @date 6 4, 2016 + ** + ** @brief + ** @copyright + ** This source code is part of the Valentine project, a pattern making + ** program, whose allow create and modeling patterns of clothing. + ** Copyright (C) 2016 Valentina project + ** All Rights Reserved. + ** + ** Valentina is free software: you can redistribute it and/or modify + ** it under the terms of the GNU General Public License as published by + ** the Free Software Foundation, either version 3 of the License, or + ** (at your option) any later version. + ** + ** Valentina is distributed in the hope that it will be useful, + ** but WITHOUT ANY WARRANTY; without even the implied warranty of + ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + ** GNU General Public License for more details. + ** + ** You should have received a copy of the GNU General Public License + ** along with Valentina. If not, see . + ** + *************************************************************************/ + +#ifndef VWIDGETGROUPS_H +#define VWIDGETGROUPS_H + +#include +#include "../ifc/xml/vabstractpattern.h" + +namespace Ui +{ + class VWidgetGroups; +} + +class VWidgetGroups : public QWidget +{ + Q_OBJECT + +public: + explicit VWidgetGroups(VAbstractPattern *doc, QWidget *parent = nullptr); + virtual ~VWidgetGroups(); + +public slots: + void UpdateGroups(); + +private slots: + void GroupVisibilityChanged(int row, int column); + void CtxMenu(const QPoint &pos); +private: + Q_DISABLE_COPY(VWidgetGroups) + Ui::VWidgetGroups *ui; + VAbstractPattern *doc; + + void FillTable(const QMap > &groups); +}; + +#endif // VWIDGETGROUPS_H diff --git a/src/app/valentina/dialogs/vwidgetgroups.ui b/src/app/valentina/dialogs/vwidgetgroups.ui new file mode 100644 index 000000000..3bd6c417e --- /dev/null +++ b/src/app/valentina/dialogs/vwidgetgroups.ui @@ -0,0 +1,58 @@ + + + VWidgetGroups + + + + 0 + 0 + 371 + 279 + + + + Form + + + + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + false + + + false + + + 16 + + + false + + + true + + + false + + + false + + + 10 + + + + + + + + diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a1e99b1b3..a54c5aed8 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -54,6 +54,7 @@ #include "tools/vtooldetail.h" #include "tools/vtooluniondetails.h" #include "dialogs/dialogs.h" +#include "dialogs/vwidgetgroups.h" #include "../vtools/undocommands/addgroup.h" #include @@ -119,7 +120,9 @@ MainWindow::MainWindow(QWidget *parent) separatorAct(nullptr), leftGoToStage(nullptr), rightGoToStage(nullptr), autoSaveTimer(nullptr), guiEnabled(true), gradationHeights(nullptr), gradationSizes(nullptr), gradationHeightsLabel(nullptr), gradationSizesLabel(nullptr), - toolOptions(nullptr), lock(nullptr) + toolOptions(nullptr), + groupsWidget(nullptr), + lock(nullptr) { for (int i = 0; i < MaxRecentFiles; ++i) { @@ -154,7 +157,7 @@ MainWindow::MainWindow(QWidget *parent) ui->toolBox->setCurrentIndex(0); ReadSettings(); - PropertyBrowser(); + InitDocksContain(); setCurrentFile(""); WindowsLocale(); @@ -1001,6 +1004,7 @@ void MainWindow::ClosedDialogUnionDetails(int result) void MainWindow::ToolGroup(bool checked) { ToolSelectGroupObjects(); + currentScene->clearSelection(); SetToolButton(checked, Tool::Group, ":/cursor/group_plus_cursor.png", tr("Select objects, Enter - finish creation"), &MainWindow::ClosedDialogGroup); } @@ -1020,6 +1024,7 @@ void MainWindow::ClosedDialogGroup(int result) if (not group.isNull()) { AddGroup *addGroup = new AddGroup(group, doc); + connect(addGroup, &AddGroup::UpdateGroups, groupsWidget, &VWidgetGroups::UpdateGroups); qApp->getUndoStack()->push(addGroup); } } @@ -1733,7 +1738,7 @@ void MainWindow::InitToolButtons() connect(ui->toolButtonPointFromArcAndTangent, &QToolButton::clicked, this, &MainWindow::ToolPointFromArcAndTangent); connect(ui->toolButtonArcWithLength, &QToolButton::clicked, this, &MainWindow::ToolArcWithLength); connect(ui->toolButtonTrueDarts, &QToolButton::clicked, this, &MainWindow::ToolTrueDarts); - + connect(ui->toolButtonGroup, &QToolButton::clicked, this, &MainWindow::ToolGroup); } //--------------------------------------------------------------------------------------------------------------------- @@ -3551,13 +3556,17 @@ void MainWindow::AddDocks() } //--------------------------------------------------------------------------------------------------------------------- -void MainWindow::PropertyBrowser() +void MainWindow::InitDocksContain() { qCDebug(vMainWindow, "Initialization property browser."); toolOptions = new VToolOptionsPropertyBrowser(ui->dockWidgetToolOptions); connect(ui->view, &VMainGraphicsView::itemClicked, toolOptions, &VToolOptionsPropertyBrowser::itemClicked); connect(doc, &VPattern::FullUpdateFromFile, toolOptions, &VToolOptionsPropertyBrowser::UpdateOptions); + + qCDebug(vMainWindow, "Initialization groups dock."); + groupsWidget = new VWidgetGroups(doc, this); + ui->dockWidgetGroups->setWidget(groupsWidget); } //--------------------------------------------------------------------------------------------------------------------- @@ -4140,6 +4149,7 @@ void MainWindow::ChangePP(int index, bool zoomBestFit) } } toolOptions->itemClicked(nullptr);//hide options for tool in previous pattern piece + groupsWidget->UpdateGroups(); } } @@ -4724,7 +4734,7 @@ void MainWindow::ToolSelectGroupObjects() const emit ItemsSelection(SelectionType::ByMouseRelease); - ui->view->AllowRubberBand(false); + ui->view->AllowRubberBand(true); } //--------------------------------------------------------------------------------------------------------------------- diff --git a/src/app/valentina/mainwindow.h b/src/app/valentina/mainwindow.h index 673dcdf63..98b383942 100644 --- a/src/app/valentina/mainwindow.h +++ b/src/app/valentina/mainwindow.h @@ -48,6 +48,7 @@ class QLabel; class DialogIncrements; class DialogTool; class DialogHistory; +class VWidgetGroups; /** * @brief The MainWindow class main windows. @@ -276,6 +277,7 @@ private: QPointer gradationHeightsLabel; QPointer gradationSizesLabel; VToolOptionsPropertyBrowser *toolOptions; + VWidgetGroups *groupsWidget; std::shared_ptr> lock; void SetDefaultHeight(); @@ -333,7 +335,7 @@ private: void UpdateSizesList(const QStringList &list); void AddDocks(); - void PropertyBrowser(); + void InitDocksContain(); bool OpenNewValentina(const QString &fileName = QString())const; void FileClosedCorrect(); QStringList GetUnlokedRestoreFileList()const; diff --git a/src/libs/ifc/xml/vabstractpattern.cpp b/src/libs/ifc/xml/vabstractpattern.cpp index d723c0365..9b4758bf7 100644 --- a/src/libs/ifc/xml/vabstractpattern.cpp +++ b/src/libs/ifc/xml/vabstractpattern.cpp @@ -323,8 +323,9 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement) itemTool.insert(i.key(), i.value()); } - const bool previous = itemVisibility.value(i.key(), true); + const bool previous = itemVisibility.value(i.key(), false); itemVisibility.insert(i.key(), previous || groupData.first); + ++i; } } } @@ -340,6 +341,7 @@ void VAbstractPattern::ParseGroups(const QDomElement &domElement) VDataTool* tool = tools.value(i.value()); tool->GroupVisibility(i.key(), itemVisibility.value(i.key(), true)); } + ++i; } } @@ -1478,9 +1480,9 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const } QDomElement group = createElement(TagGroup); - group.setAttribute(AttrId, id); - group.setAttribute(AttrName, name); - group.setAttribute(AttrVisible, trueStr); + SetAttribute(group, AttrId, id); + SetAttribute(group, AttrName, name); + SetAttribute(group, AttrVisible, true); auto i = groupData.constBegin(); while (i != groupData.constEnd()) @@ -1495,6 +1497,38 @@ QDomElement VAbstractPattern::CreateGroup(quint32 id, const QString &name, const return group; } +//--------------------------------------------------------------------------------------------------------------------- +QString VAbstractPattern::GetGroupName(quint32 id) +{ + QString name = tr("New group"); + QDomElement groups = CreateGroups(); + if (not groups.isNull()) + { + QDomElement group = elementById(id); + if (group.isElement()) + { + name = GetParametrString(group, AttrName, name); + return name; + } + else + { + if (groups.childNodes().isEmpty()) + { + QDomNode parent = groups.parentNode(); + parent.removeChild(groups); + } + + qDebug("Can't get group by id = %u.", id); + return name; + } + } + else + { + qDebug("Can't get tag Groups."); + return name; + } +} + //--------------------------------------------------------------------------------------------------------------------- void VAbstractPattern::SetGroupName(quint32 id, const QString &name) { @@ -1526,3 +1560,78 @@ void VAbstractPattern::SetGroupName(quint32 id, const QString &name) return; } } + +//--------------------------------------------------------------------------------------------------------------------- +QMap > VAbstractPattern::GetGroups() +{ + QMap > data; + + QDomElement groups = CreateGroups(); + if (not groups.isNull()) + { + QDomNode domNode = groups.firstChild(); + while (domNode.isNull() == false) + { + if (domNode.isElement()) + { + const QDomElement group = domNode.toElement(); + if (group.isNull() == false) + { + if (group.tagName() == TagGroup) + { + const quint32 id = GetParametrUInt(group, AttrId, "0"); + const bool visible = GetParametrBool(group, AttrVisible, trueStr); + const QString name = GetParametrString(group, AttrName, tr("New group")); + + data.insert(id, qMakePair(name, visible)); + } + } + } + domNode = domNode.nextSibling(); + } + } + else + { + qDebug("Can't get tag Groups."); + } + + return data; +} + +//--------------------------------------------------------------------------------------------------------------------- +bool VAbstractPattern::GetGroupVisivility(quint32 id) +{ + QDomElement group = elementById(id); + if (group.isElement()) + { + return GetParametrBool(group, AttrVisible, trueStr); + } + else + { + qDebug("Can't get group by id = %u.", id); + return true; + } +} + +//--------------------------------------------------------------------------------------------------------------------- +void VAbstractPattern::SetGroupVisivility(quint32 id, bool visible) +{ + QDomElement group = elementById(id); + if (group.isElement()) + { + SetAttribute(group, AttrVisible, visible); + modified = true; + emit patternChanged(false); + + QDomElement groups = CreateGroups(); + if (not groups.isNull()) + { + ParseGroups(groups); + } + } + else + { + qDebug("Can't get group by id = %u.", id); + return; + } +} diff --git a/src/libs/ifc/xml/vabstractpattern.h b/src/libs/ifc/xml/vabstractpattern.h index 90e8c1b3c..0f5c77396 100644 --- a/src/libs/ifc/xml/vabstractpattern.h +++ b/src/libs/ifc/xml/vabstractpattern.h @@ -67,8 +67,6 @@ public: bool GetActivDrawElement(QDomElement &element) const; bool GetActivNodeElement(const QString& name, QDomElement& element) const; - void ParseGroups(const QDomElement &domElement); - quint32 getCursor() const; void setCursor(const quint32 &value); @@ -116,9 +114,14 @@ public: QDomElement GetDraw(const QString &name) const; + void ParseGroups(const QDomElement &domElement); QDomElement CreateGroups(); QDomElement CreateGroup(quint32 id, const QString &name, const QMap &groupData); + QString GetGroupName(quint32 id); void SetGroupName(quint32 id, const QString &name); + QMap > GetGroups(); + bool GetGroupVisivility(quint32 id); + void SetGroupVisivility(quint32 id, bool visible); static const QString TagPattern; static const QString TagCalculation; diff --git a/src/libs/vmisc/share/resources/icon.qrc b/src/libs/vmisc/share/resources/icon.qrc index 3d273e73d..8abf44308 100644 --- a/src/libs/vmisc/share/resources/icon.qrc +++ b/src/libs/vmisc/share/resources/icon.qrc @@ -57,5 +57,9 @@ icon/16x16/toolsectionpoint@2x.png icon/16x16/operations.png icon/16x16/operations@2x.png + icon/16x16/closed_eye.png + icon/16x16/closed_eye@2x.png + icon/16x16/open_eye.png + icon/16x16/open_eye@2x.png diff --git a/src/libs/vmisc/share/resources/icon/16x16/closed_eye.png b/src/libs/vmisc/share/resources/icon/16x16/closed_eye.png new file mode 100644 index 0000000000000000000000000000000000000000..dc1142f4a29195ecebcea04c689eecebcb91a475 GIT binary patch literal 416 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`EX7WqAsj$Z!;#Vf4nJ zu)P6cM!8Z8Q=p(^iEBhjaDG}zd16s2LwR|*US?i)adKios$PCk`s{Z$Qb0ulAVndW zB{``K&N=zTsVNGsm8olX{GG_az{u$7;uvDld-U>t?bbvQ_7DB9m73RSbT3LtPWt#* zDneJS*-_HxA8Yd;?tjc|%&CTws?8@C=mZIEy5lM#aM(8g-o1OjpWQpUGJkIIyyw4d zpIa_(|G#b9oEZLT8(Suxxch*Ey+T(g=D6`b=?8+@l}GYq!~{0qa1VEScidI@3Cr>o z2Ryl-upC!?^JsO30q+~(YR?TF+tsx8Cn&DH)){%{Z(~jO%Lf_@do~Bi9-j6~YxB1j z-=4)?Z=WQvK38O${Oa=BBvXUtIG-bP6|Wd5SV{PV?m86WRb%(ZGG^I3-sdGN`S~;Y zE7+wUmLD^ld1b7){gD6w0sTotK~z|U?bbVJ zR8bJd@n1B?*hoZB!T3OY5(uJ*AVCz=fQglMwt|9^65L8g{Z6S)- zq_7YRUuZ})@xdk*=WJMx_wI|`wJ;wHTxRZ^|J>o+bA~zn?`o^@{Z8yfAGV?+`hVaB z?&B_gHK@K>_23F7FjK+Ca1omt0bY+0OjiL;tq^n9)dOzBDNNM?PVF0x*8*RP>kR;> zb`4#X;M?%73Gkx5!InJuZhUDXyl9`WGllQLWDDS>`=YN1-`t`vPwk`lhdlWQ@S@#; z?Xe}ThK~sc95{rZErd_vfJB2@vk@n-FNGJ?tGVaE+tRk@X#<`&0sa(g%YoalIzBJN zkoqp6)TVI(3($_0c?BHBSM-~NEbfDq%#@C4d8Z_9Vy@j z_9tsBiyt_HV<})L23`qm%F`O0#4sLVG}=R4#R+9vjMI_xS-5qHz|j~O$VlqNW#Oi* zRy$%r=~UDaSp^&{4J^m`oW;(?;w~lrPV5q9!&JjD=WIr-ABXd6|69-EVuOi)WAwky z$T<>Y_i6!UX@$_P?^skr0gHvB{kO3Db2YC*0o`~njN4O{>z&m&9>?778uBvLj#U}{ zavczJ=2u$0;tRsRKc3+)2;numqcBPx;Xf(qfSLT_zHy|Nidx{ zh^x?wptuR*-_W^h2ZstSPJ);`@**T1RB&#GzOJHOQVAt_zu(WnCzKd)?!gWB<-T|K zy*oJfCbO|I=DvtL6p?$tl@k8}41u?4ntq&Hz!-B=RbKGgVhb9Qr{?Kjf@he;WR Rg>$xWmd9-hqAW<3Wcso0!dJ`#jGZ5s~Laq+co30UQkE zEnpM)Q7N^o>-x2Yg@v{M!+@mI=~qSME#Sx=3@hL}5xH0@m97Nw-VB(g`MjoS7l3D) zY`Pnkfs>YH-Dt`{e}BIokH@E#Qsa#b?h#5vW;Ql9-d$N)al?WZ4n{{uABxB0SCvu| z_h{|{dEfVYec$f|@&VTjL@6~9i^aYf7#L{#mr%PH85!wtU3U(6F{Il{DG?D9$Xk~6 zNqBKOoz9EMRD;Ih^)-~Yx3^zeT3WgT!44D(1d+gH$Fo4#c&e?f?J~je8o=V>;%VUJP~j7nWla_e1s~`Ea9!80uO5j+c73`7^vurA zdX{D7fr$`*ER)Hc0?-Br2OkGM2#KHCwtX=a{{awt6u4uKOl%rcrkhxfPBpmCET@ES3VE z23nL-(@_y=3FX}F>guZB*15od4xDpc_gtfcWIRMBE0xN} zbyHj-xD9*6@4%%n5sgNtfER*r+w;8fh~qdLhGA?0!!;9qeSN>KuCCq$a2)53VHke` z**zLKW!tu03o@C^I1nE09ox3AM}j6d5{bkUz>@$Xa?~&keQa#3TrQWD<2XMg5{V9A zpvmUvEz9}{AeYNUdU|@MfU`AGDfOjo+j)RUjqL93zSi2>`YezLs3Ys^>q)~f%8uh~ zI*wB`3}Zbo@$fE{QUes4`TfYxm+$%sZ=I`_rp5`c))d~l&xvnisyN^Ha9nK19WzFKB{TjVWrel znxib9}@?No6T)vln-{Ur&P7epK z>M(VuX9IY^f{1)xDwT?j5}Q8nP18IiB1c2NWL>}`f&3eAo8XsBMCL5ZT5q=YKKAio Z<1f+1Yiy&t4WR%4002ovPDHLkV1kvA1cm?r literal 0 HcmV?d00001 diff --git a/src/libs/vmisc/share/resources/icon/svg/closed_eye.svg b/src/libs/vmisc/share/resources/icon/svg/closed_eye.svg new file mode 100644 index 000000000..c22134f20 --- /dev/null +++ b/src/libs/vmisc/share/resources/icon/svg/closed_eye.svg @@ -0,0 +1,99 @@ + + + + + + image/svg+xml + + Closed Eye + + + + + + Closed Eye + Created with Sketch (http://www.bohemiancoding.com/sketch) + + + + + + + + + + + + + diff --git a/src/libs/vmisc/share/resources/icon/svg/open_eye.svg b/src/libs/vmisc/share/resources/icon/svg/open_eye.svg new file mode 100644 index 000000000..11b37c377 --- /dev/null +++ b/src/libs/vmisc/share/resources/icon/svg/open_eye.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp index b41c53e4b..0fc8aca76 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.cpp @@ -66,6 +66,7 @@ VToolSinglePoint::VToolSinglePoint(VAbstractPattern *doc, VContainer *data, quin connect(namePoint, &VGraphicsSimpleTextItem::ShowContextMenu, this, &VToolSinglePoint::contextMenuEvent); connect(namePoint, &VGraphicsSimpleTextItem::DeleteTool, this, &VToolSinglePoint::DeleteFromLabel); connect(namePoint, &VGraphicsSimpleTextItem::PointChoosed, this, &VToolSinglePoint::PointChoosed); + connect(namePoint, &VGraphicsSimpleTextItem::PointSelected, this, &VToolSinglePoint::PointSelected); connect(namePoint, &VGraphicsSimpleTextItem::NameChangePosition, this, &VToolSinglePoint::NameChangePosition); lineName = new QGraphicsLineItem(this); this->setBrush(QBrush(Qt::NoBrush)); @@ -174,6 +175,12 @@ void VToolSinglePoint::PointChoosed() emit ChoosedTool(id, SceneObject::Point); } +//--------------------------------------------------------------------------------------------------------------------- +void VToolSinglePoint::PointSelected(bool selected) +{ + setSelected(selected); +} + //--------------------------------------------------------------------------------------------------------------------- /** * @brief FullUpdateFromFile update tool data form file. diff --git a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h index 9c0cf5710..dbacedea4 100644 --- a/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h +++ b/src/libs/vtools/tools/drawTools/toolpoint/toolsinglepoint/vtoolsinglepoint.h @@ -60,6 +60,7 @@ public slots: virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE; virtual void EnableToolMove(bool move) Q_DECL_OVERRIDE; void PointChoosed(); + void PointSelected(bool selected); virtual void FullUpdateFromFile() Q_DECL_OVERRIDE; virtual void DoChangePosition(quint32 id, qreal mx, qreal my) Q_DECL_OVERRIDE; virtual void AllowHover(bool enabled) Q_DECL_OVERRIDE; diff --git a/src/libs/vtools/undocommands/addgroup.cpp b/src/libs/vtools/undocommands/addgroup.cpp index 2a5bdf65b..fbb4f05c7 100644 --- a/src/libs/vtools/undocommands/addgroup.cpp +++ b/src/libs/vtools/undocommands/addgroup.cpp @@ -64,6 +64,7 @@ void AddGroup::undo() qCDebug(vUndo, "Can't delete group."); return; } + emit UpdateGroups(); } else { @@ -99,6 +100,7 @@ void AddGroup::redo() { groups.appendChild(xml); doc->ParseGroups(groups); + emit UpdateGroups(); } else { diff --git a/src/libs/vtools/undocommands/addgroup.h b/src/libs/vtools/undocommands/addgroup.h index ae3273253..ca0807fdf 100644 --- a/src/libs/vtools/undocommands/addgroup.h +++ b/src/libs/vtools/undocommands/addgroup.h @@ -39,6 +39,8 @@ public: virtual ~AddGroup(); virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; +signals: + void UpdateGroups(); private: Q_DISABLE_COPY(AddGroup) const QString nameActivDraw; diff --git a/src/libs/vtools/undocommands/delgroup.cpp b/src/libs/vtools/undocommands/delgroup.cpp index 17ce0c0ce..818e5e1a6 100644 --- a/src/libs/vtools/undocommands/delgroup.cpp +++ b/src/libs/vtools/undocommands/delgroup.cpp @@ -57,6 +57,7 @@ void DelGroup::undo() { groups.appendChild(xml); doc->ParseGroups(groups); + emit UpdateGroups(); } else { @@ -87,6 +88,7 @@ void DelGroup::redo() qCDebug(vUndo, "Can't delete group."); return; } + emit UpdateGroups(); if (groups.childNodes().isEmpty()) { diff --git a/src/libs/vtools/undocommands/delgroup.h b/src/libs/vtools/undocommands/delgroup.h index fc8638445..a04372470 100644 --- a/src/libs/vtools/undocommands/delgroup.h +++ b/src/libs/vtools/undocommands/delgroup.h @@ -39,6 +39,8 @@ public: virtual ~DelGroup(); virtual void undo() Q_DECL_OVERRIDE; virtual void redo() Q_DECL_OVERRIDE; +signals: + void UpdateGroups(); private: Q_DISABLE_COPY(DelGroup) const QString nameActivDraw; From be062fff7daa474958a81508b7c07c6862e27e9f Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 Apr 2016 19:48:20 +0300 Subject: [PATCH 09/12] Better tooltipe. --HG-- branch : feature --- src/app/valentina/mainwindow.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/valentina/mainwindow.cpp b/src/app/valentina/mainwindow.cpp index a54c5aed8..4125aed5d 100644 --- a/src/app/valentina/mainwindow.cpp +++ b/src/app/valentina/mainwindow.cpp @@ -1006,7 +1006,8 @@ void MainWindow::ToolGroup(bool checked) ToolSelectGroupObjects(); currentScene->clearSelection(); SetToolButton(checked, Tool::Group, ":/cursor/group_plus_cursor.png", - tr("Select objects, Enter - finish creation"), &MainWindow::ClosedDialogGroup); + tr("Select one or more objects, Enter - finish creation"), + &MainWindow::ClosedDialogGroup); } //--------------------------------------------------------------------------------------------------------------------- From 526363a84c41ed9d63a5b87e64141d9664aba13e Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 Apr 2016 19:56:06 +0300 Subject: [PATCH 10/12] Better look of group name. --HG-- branch : feature --- src/app/valentina/dialogs/vwidgetgroups.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/valentina/dialogs/vwidgetgroups.cpp b/src/app/valentina/dialogs/vwidgetgroups.cpp index 3d5965a5f..abc3d34f0 100644 --- a/src/app/valentina/dialogs/vwidgetgroups.cpp +++ b/src/app/valentina/dialogs/vwidgetgroups.cpp @@ -150,7 +150,7 @@ void VWidgetGroups::FillTable(const QMap > &groups ui->tableWidget->setItem(currentRow, 0, item); item = new QTableWidgetItem(data.first); - item->setTextAlignment(Qt::AlignLeft); + item->setTextAlignment(Qt::AlignLeft | Qt::AlignVCenter); ui->tableWidget->setItem(currentRow, 1, item); ++i; } From 42e356ccbd9b85d3f3fa592ad15a942192fff9d6 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 Apr 2016 19:56:41 +0300 Subject: [PATCH 11/12] New pattern format version 0.3.0. --HG-- branch : feature --- src/libs/ifc/schema.qrc | 1 + src/libs/ifc/schema/pattern/v0.3.0.xsd | 480 +++++++++++++++++++++++++ src/libs/ifc/xml/vpatternconverter.cpp | 20 +- src/libs/ifc/xml/vpatternconverter.h | 1 + 4 files changed, 500 insertions(+), 2 deletions(-) create mode 100644 src/libs/ifc/schema/pattern/v0.3.0.xsd diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index 1fe74a4c7..d8aa89e47 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -13,6 +13,7 @@ schema/pattern/v0.2.5.xsd schema/pattern/v0.2.6.xsd schema/pattern/v0.2.7.xsd + schema/pattern/v0.3.0.xsd schema/standard_measurements/v0.3.0.xsd schema/standard_measurements/v0.4.0.xsd schema/standard_measurements/v0.4.1.xsd diff --git a/src/libs/ifc/schema/pattern/v0.3.0.xsd b/src/libs/ifc/schema/pattern/v0.3.0.xsd new file mode 100644 index 000000000..b868553f3 --- /dev/null +++ b/src/libs/ifc/schema/pattern/v0.3.0.xsd @@ -0,0 +1,480 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vpatternconverter.cpp b/src/libs/ifc/xml/vpatternconverter.cpp index f725d1d65..46e09ae74 100644 --- a/src/libs/ifc/xml/vpatternconverter.cpp +++ b/src/libs/ifc/xml/vpatternconverter.cpp @@ -43,8 +43,8 @@ */ const QString VPatternConverter::PatternMinVerStr = QStringLiteral("0.1.0"); -const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.2.7"); -const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.2.7.xsd"); +const QString VPatternConverter::PatternMaxVerStr = QStringLiteral("0.3.0"); +const QString VPatternConverter::CurrentSchema = QStringLiteral("://schema/pattern/v0.3.0.xsd"); //--------------------------------------------------------------------------------------------------------------------- VPatternConverter::VPatternConverter(const QString &fileName) @@ -111,6 +111,8 @@ QString VPatternConverter::XSDSchema(int ver) const case (0x000206): return QStringLiteral("://schema/pattern/v0.2.6.xsd"); case (0x000207): + return QStringLiteral("://schema/pattern/v0.3.0.xsd"); + case (0x000300): return CurrentSchema; default: InvalidVersion(ver); @@ -210,6 +212,13 @@ void VPatternConverter::ApplyPatches() V_FALLTHROUGH } case (0x000207): + { + ToV0_3_0(); + const QString schema = XSDSchema(0x000300); + ValidateXML(schema, fileName); + V_FALLTHROUGH + } + case (0x000300): break; default: break; @@ -331,6 +340,13 @@ void VPatternConverter::ToV0_2_7() Save(); } +//--------------------------------------------------------------------------------------------------------------------- +void VPatternConverter::ToV0_3_0() +{ + SetVersion(QStringLiteral("0.3.0")); + Save(); +} + //--------------------------------------------------------------------------------------------------------------------- void VPatternConverter::TagUnitToV0_2_0() { diff --git a/src/libs/ifc/xml/vpatternconverter.h b/src/libs/ifc/xml/vpatternconverter.h index d1a0be553..1a4de28d8 100644 --- a/src/libs/ifc/xml/vpatternconverter.h +++ b/src/libs/ifc/xml/vpatternconverter.h @@ -68,6 +68,7 @@ private: void ToV0_2_5(); void ToV0_2_6(); void ToV0_2_7(); + void ToV0_3_0(); void TagUnitToV0_2_0(); void TagIncrementToV0_2_0(); From 94df00b8cfaede2a5556922ec588ba1788cad9db Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Thu, 7 Apr 2016 19:59:16 +0300 Subject: [PATCH 12/12] Updated changelog. --HG-- branch : feature --- ChangeLog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/ChangeLog.txt b/ChangeLog.txt index 4e5dda37b..05fd011eb 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,4 +1,5 @@ # Version 0.5.0 +- New feature. Groups. - Tool "Curve intersect axis" store data about subpaths. - [#444] Length along Path seems not valid. - Added new curve path segment variables.