1 /************************************************************************
2 **
3 ** @file dialoginsertnode.h
4 ** @author Roman Telezhynskyi <dismine(at)gmail.com>
5 ** @date 21 3, 2017
6 **
7 ** @brief
8 ** @copyright
9 ** This source code is part of the Valentina project, a pattern making
10 ** program, whose allow create and modeling patterns of clothing.
11 ** Copyright (C) 2017 Valentina project
12 ** <https://gitlab.com/smart-pattern/valentina> All Rights Reserved.
13 **
14 ** Valentina is free software: you can redistribute it and/or modify
15 ** it under the terms of the GNU General Public License as published by
16 ** the Free Software Foundation, either version 3 of the License, or
17 ** (at your option) any later version.
18 **
19 ** Valentina is distributed in the hope that it will be useful,
20 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ** GNU General Public License for more details.
23 **
24 ** You should have received a copy of the GNU General Public License
25 ** along with Valentina. If not, see <http://www.gnu.org/licenses/>.
26 **
27 *************************************************************************/
28
29 #ifndef DIALOGINSERTNODE_H
30 #define DIALOGINSERTNODE_H
31
32 #include "../dialogtool.h"
33 #include "../vpatterndb/vpiecenode.h"
34
35 namespace Ui
36 {
37 class DialogInsertNode;
38 }
39
40 class DialogInsertNode : public DialogTool
41 {
42 Q_OBJECT
43
44 public:
45 explicit DialogInsertNode(const VContainer *data, quint32 toolId, QWidget *parent = nullptr);
46 virtual ~DialogInsertNode();
47
48 virtual void SetPiecesList(const QVector<quint32> &list) override;
49
50 quint32 GetPieceId() const;
51 void SetPieceId(quint32 id);
52
53 QVector<VPieceNode> GetNodes() const;
54
55 virtual void ShowDialog(bool click) override;
56
57 public slots:
58 virtual void SelectedObject(bool selected, quint32 object, quint32 tool) override;
59
60 protected:
61 virtual bool IsValid() const final;
62
63 private slots:
64 void ShowContextMenu(const QPoint &pos);
65 void NodeSelected();
66 void NodeNumberChanged(int val);
67
68 private:
69 Q_DISABLE_COPY(DialogInsertNode)
70 Ui::DialogInsertNode *ui;
71
72 QVector<VPieceNode> m_nodes{};
73 bool m_flagNodes{false};
74 bool m_flagError{false};
75
76 QMap<quint32, int> nodeNumbers{};
77
78 void CheckPieces();
79 void CheckNodes();
80 };
81
82 //---------------------------------------------------------------------------------------------------------------------
IsValid()83 inline bool DialogInsertNode::IsValid() const
84 {
85 return m_flagNodes && m_flagError;
86 }
87
88 #endif // DIALOGINSERTNODE_H
89