1 /* 2 SPDX-License-Identifier: GPL-2.0-or-later 3 SPDX-FileCopyrightText: 2016-2021 Umbrello UML Modeller Authors <umbrello-devel@kde.org> 4 */ 5 6 //local includes 7 #include "umlinstanceattributedialog.h" 8 #include "ui_umlinstanceattributedialog.h" 9 #include "attribute.h" 10 #include "uml.h" 11 12 // kde includes 13 #include <KLocalizedString> 14 #include <KMessageBox> 15 UMLInstanceAttributeDialog(QWidget * parent,UMLInstanceAttribute * pInstanceAttr)16UMLInstanceAttributeDialog::UMLInstanceAttributeDialog(QWidget *parent, UMLInstanceAttribute *pInstanceAttr) 17 : SinglePageDialogBase(parent), 18 ui(new Ui::UMLInstanceAttributeDialog), 19 m_pInstanceAttr(pInstanceAttr) 20 { 21 setCaption(i18n("Object Attribute Properties")); 22 ui->setupUi(mainWidget()); 23 ui->nameLE->setReadOnly(true); 24 ui->nameLE->setText(pInstanceAttr->getAttribute()->name()); 25 QString initValue = pInstanceAttr->getValue(); 26 if (initValue.isEmpty()) 27 initValue = pInstanceAttr->getAttribute()->getInitialValue(); 28 ui->valueLE->setText(initValue); 29 } 30 ~UMLInstanceAttributeDialog()31UMLInstanceAttributeDialog::~UMLInstanceAttributeDialog() 32 { 33 delete ui; 34 } 35 apply()36bool UMLInstanceAttributeDialog::apply() 37 { 38 QString value = ui->valueLE->text(); 39 if (value.isEmpty()) { 40 KMessageBox::error(this, i18n("You have entered an invalid attribute value."), 41 i18n("Value Invalid"), 0); 42 return false; 43 } 44 m_pInstanceAttr->setValue(value); 45 m_pInstanceAttr->emitModified(); 46 return true; 47 } 48 49