Seamly2D
Code documentation
dialoggroup.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * Copyright (C) 2017 Seamly, LLC *
4  * *
5  * https://github.com/fashionfreedom/seamly2d *
6  * *
7  ***************************************************************************
8  **
9  ** Seamly2D is free software: you can redistribute it and/or modify
10  ** it under the terms of the GNU General Public License as published by
11  ** the Free Software Foundation, either version 3 of the License, or
12  ** (at your option) any later version.
13  **
14  ** Seamly2D is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  ** GNU General Public License for more details.
18  **
19  ** You should have received a copy of the GNU General Public License
20  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
21  **
22  **************************************************************************
23 
24  ************************************************************************
25  **
26  ** @file dialoggroup.cpp
27  ** @author Roman Telezhynskyi <dismine(at)gmail.com>
28  ** @date 4 4, 2016
29  **
30  ** @brief
31  ** @copyright
32  ** This source code is part of the Valentine project, a pattern making
33  ** program, whose allow create and modeling patterns of clothing.
34  ** Copyright (C) 2016 Seamly2D project
35  ** <https://github.com/fashionfreedom/seamly2d> All Rights Reserved.
36  **
37  ** Seamly2D is free software: you can redistribute it and/or modify
38  ** it under the terms of the GNU General Public License as published by
39  ** the Free Software Foundation, either version 3 of the License, or
40  ** (at your option) any later version.
41  **
42  ** Seamly2D is distributed in the hope that it will be useful,
43  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
44  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45  ** GNU General Public License for more details.
46  **
47  ** You should have received a copy of the GNU General Public License
48  ** along with Seamly2D. If not, see <http://www.gnu.org/licenses/>.
49  **
50  *************************************************************************/
51 
52 #include "dialoggroup.h"
53 
54 #include <QLineEdit>
55 
56 #include "ui_dialoggroup.h"
57 
58 //---------------------------------------------------------------------------------------------------------------------
59 EditGroupDialog::EditGroupDialog(const VContainer *data, const quint32 &toolId, QWidget *parent)
60  : DialogTool(data, toolId, parent),
61  ui(new Ui::EditGroupDialog),
62  group()
63 {
64  ui->setupUi(this);
65  setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
66  setWindowIcon(QIcon(":/toolicon/32x32/group.png"));
67 
70 
71  connect(ui->lineEditName, &QLineEdit::textChanged, this, &EditGroupDialog::NameChanged);
72 }
73 
74 //---------------------------------------------------------------------------------------------------------------------
76 {
77  delete ui;
78 }
79 
80 //---------------------------------------------------------------------------------------------------------------------
81 void EditGroupDialog::SetName(const QString &name)
82 {
83  ui->lineEditName->setText(name);
84 }
85 
86 //---------------------------------------------------------------------------------------------------------------------
87 QString EditGroupDialog::GetName() const
88 {
89  return ui->lineEditName->text();
90 }
91 
92 //---------------------------------------------------------------------------------------------------------------------
94 {
95  if (not click)
96  {
97  if (group.isEmpty())
98  {
99  return;
100  }
101 
102  SetName(tr("New group"));
103 
104  setModal(true);
105  emit ToolTip("");
106  show();
107  }
108 }
109 
110 //---------------------------------------------------------------------------------------------------------------------
111 void EditGroupDialog::SelectedObject(bool selected, quint32 object, quint32 tool)
112 {
113  if (selected)
114  {
115  group.insert(object, tool);
116  }
117  else
118  {
119  group.remove(object);
120  }
121 }
122 
123 //---------------------------------------------------------------------------------------------------------------------
125 {
126  ui->lineEditName->text().isEmpty() ? flagName = false : flagName = true;
127  CheckState();
128 }
129 
130 //---------------------------------------------------------------------------------------------------------------------
132 {
133  return group;
134 }
The DialogTool class parent for all dialog of tools.
Definition: dialogtool.h:107
void ToolTip(const QString &toolTip)
ToolTip emit tooltipe for tool.
virtual void CheckState()
CheckState enable, when all is correct, or disable, when something wrong, button ok.
bool flagName
flagName true if name is correct
Definition: dialogtool.h:183
void initializeOkCancel(T *ui)
initializeOkCancel initialize OK and Cancel buttons
Definition: dialogtool.h:379
QMap< quint32, quint32 > GetGroup() const
Ui::EditGroupDialog * ui
Definition: dialoggroup.h:92
QString GetName() const
Definition: dialoggroup.cpp:87
virtual void SelectedObject(bool selected, quint32 object, quint32 tool) Q_DECL_OVERRIDE
QMap< quint32, quint32 > group
Definition: dialoggroup.h:93
virtual void ShowDialog(bool click) Q_DECL_OVERRIDE
Definition: dialoggroup.cpp:93
void SetName(const QString &name)
Definition: dialoggroup.cpp:81
EditGroupDialog(const VContainer *data, const quint32 &toolId, QWidget *parent=nullptr)
Definition: dialoggroup.cpp:59
The VContainer class container of all variables.
Definition: vcontainer.h:141