2013-09-18 21:16:19 +02:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2013 Valentina project All Rights Reserved.
|
|
|
|
**
|
|
|
|
** This file is part of Valentina.
|
|
|
|
**
|
|
|
|
** Tox 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.
|
|
|
|
**
|
|
|
|
** Tox 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 <http://www.gnu.org/licenses/>.
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-08-28 10:55:11 +02:00
|
|
|
#include "dialogdetail.h"
|
2013-09-12 16:18:31 +02:00
|
|
|
#include <QDebug>
|
2013-08-28 10:55:11 +02:00
|
|
|
|
2013-09-27 11:17:00 +02:00
|
|
|
DialogDetail::DialogDetail(const VContainer *data, Draw::Draws mode, QWidget *parent) :
|
2013-09-10 14:29:06 +02:00
|
|
|
DialogTool(data, mode, parent), ui(), details(VDetail()){
|
2013-08-28 10:55:11 +02:00
|
|
|
ui.setupUi(this);
|
|
|
|
bOk = ui.buttonBox->button(QDialogButtonBox::Ok);
|
|
|
|
connect(bOk, &QPushButton::clicked, this, &DialogDetail::DialogAccepted);
|
|
|
|
|
|
|
|
QPushButton *bCansel = ui.buttonBox->button(QDialogButtonBox::Cancel);
|
|
|
|
connect(bCansel, &QPushButton::clicked, this, &DialogDetail::DialogRejected);
|
|
|
|
}
|
|
|
|
|
2013-09-27 11:17:00 +02:00
|
|
|
void DialogDetail::ChoosedObject(qint64 id, Scene::Scenes type){
|
2013-09-10 14:29:06 +02:00
|
|
|
if(idDetail == 0 && mode == Draw::Modeling){
|
|
|
|
if(type == Scene::Detail){
|
|
|
|
idDetail = id;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(mode == Draw::Modeling){
|
|
|
|
if(!CheckObject(id)){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(type != Scene::Line && type != Scene::Detail){
|
|
|
|
switch(type){
|
|
|
|
case(Scene::Arc):
|
2013-09-27 11:17:00 +02:00
|
|
|
NewItem(id, Tool::NodeArc, mode, NodeDetail::Contour);
|
2013-09-10 14:29:06 +02:00
|
|
|
break;
|
|
|
|
case(Scene::Point):
|
2013-09-27 11:17:00 +02:00
|
|
|
NewItem(id, Tool::NodePoint, mode, NodeDetail::Contour);
|
2013-09-10 14:29:06 +02:00
|
|
|
break;
|
|
|
|
case(Scene::Spline):
|
2013-09-27 11:17:00 +02:00
|
|
|
NewItem(id, Tool::NodeSpline, mode, NodeDetail::Contour);
|
2013-09-10 14:29:06 +02:00
|
|
|
break;
|
|
|
|
case(Scene::SplinePath):
|
2013-09-27 11:17:00 +02:00
|
|
|
NewItem(id, Tool::NodeSplinePath, mode, NodeDetail::Contour);
|
2013-09-10 14:29:06 +02:00
|
|
|
break;
|
2013-09-12 16:18:31 +02:00
|
|
|
default:
|
2013-10-04 18:51:03 +02:00
|
|
|
qWarning()<<tr("Get wrong scene object. Ignore.");
|
2013-09-12 16:18:31 +02:00
|
|
|
break;
|
2013-09-10 14:29:06 +02:00
|
|
|
}
|
2013-08-28 10:55:11 +02:00
|
|
|
this->show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogDetail::DialogAccepted(){
|
|
|
|
details.Clear();
|
|
|
|
for(qint32 i = 0; i < ui.listWidget->count(); ++i){
|
|
|
|
QListWidgetItem *item = ui.listWidget->item(i);
|
|
|
|
details.append( qvariant_cast<VNodeDetail>(item->data(Qt::UserRole)));
|
|
|
|
}
|
|
|
|
details.setName(ui.lineEditNameDetail->text());
|
|
|
|
emit DialogClosed(QDialog::Accepted);
|
2013-10-07 13:11:56 +02:00
|
|
|
emit ToolTip("");
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
2013-09-27 11:17:00 +02:00
|
|
|
void DialogDetail::NewItem(qint64 id, Tool::Tools typeTool, Draw::Draws mode, NodeDetail::NodeDetails typeNode){
|
2013-08-28 10:55:11 +02:00
|
|
|
QString name;
|
|
|
|
switch(typeTool){
|
2013-09-27 11:17:00 +02:00
|
|
|
case(Tool::NodePoint):{
|
2013-09-10 14:29:06 +02:00
|
|
|
VPointF point;
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
point = data->GetPoint(id);
|
|
|
|
} else {
|
|
|
|
point = data->GetModelingPoint(id);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
name = point.name();
|
|
|
|
break;
|
|
|
|
}
|
2013-09-27 11:17:00 +02:00
|
|
|
case(Tool::NodeArc):{
|
2013-09-10 14:29:06 +02:00
|
|
|
VArc arc;
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
arc = data->GetArc(id);
|
|
|
|
} else {
|
|
|
|
arc = data->GetModelingArc(id);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
name = data->GetNameArc(arc.GetCenter(), id, mode);
|
|
|
|
break;
|
|
|
|
}
|
2013-09-27 11:17:00 +02:00
|
|
|
case(Tool::NodeSpline):{
|
2013-09-10 14:29:06 +02:00
|
|
|
VSpline spl;
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
spl = data->GetSpline(id);
|
|
|
|
} else {
|
|
|
|
spl = data->GetModelingSpline(id);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
name = spl.GetName();
|
|
|
|
break;
|
|
|
|
}
|
2013-09-27 11:17:00 +02:00
|
|
|
case(Tool::NodeSplinePath):{
|
2013-09-10 14:29:06 +02:00
|
|
|
VSplinePath splPath;
|
|
|
|
if(mode == Draw::Calculation){
|
|
|
|
splPath = data->GetSplinePath(id);
|
|
|
|
} else {
|
|
|
|
splPath = data->GetModelingSplinePath(id);
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
2013-09-10 14:29:06 +02:00
|
|
|
name = data->GetNameSplinePath(splPath, mode);
|
|
|
|
break;
|
|
|
|
}
|
2013-09-12 16:18:31 +02:00
|
|
|
default:
|
2013-10-04 18:51:03 +02:00
|
|
|
qWarning()<<tr("Get wrong tools. Ignore.");
|
2013-09-12 16:18:31 +02:00
|
|
|
break;
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem(name);
|
|
|
|
item->setFont(QFont("Times", 12, QFont::Bold));
|
2013-09-10 14:29:06 +02:00
|
|
|
VNodeDetail node(id, typeTool, mode, typeNode);
|
2013-08-28 10:55:11 +02:00
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(node));
|
|
|
|
ui.listWidget->addItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
VDetail DialogDetail::getDetails() const{
|
|
|
|
return details;
|
|
|
|
}
|
|
|
|
|
|
|
|
void DialogDetail::setDetails(const VDetail &value){
|
|
|
|
details = value;
|
|
|
|
ui.listWidget->clear();
|
|
|
|
for(qint32 i = 0; i < details.CountNode(); ++i){
|
2013-09-10 14:29:06 +02:00
|
|
|
NewItem(details[i].getId(), details[i].getTypeTool(),details[i].getMode(), details[i].getTypeNode());
|
2013-08-28 10:55:11 +02:00
|
|
|
}
|
|
|
|
details.setName(ui.lineEditNameDetail->text());
|
|
|
|
ui.listWidget->setFocus(Qt::OtherFocusReason);
|
|
|
|
}
|
|
|
|
|