Skip to content

Commit

Permalink
Fix 'No documentation edit possible in class attribute, operation and…
Browse files Browse the repository at this point in the history
… template dialog'.

This commit introduces a new class DocumentationWidget in sub directory dialogs/widgets
to prepare properties window support.

BUG:342330
FIXED-IN:2.15.1 (KDE 14.12.1)
  • Loading branch information
rhabacker committed Dec 30, 2014
1 parent 4a7aee8 commit 739d8c0
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 0 deletions.
2 changes: 2 additions & 0 deletions umbrello/CMakeLists.txt
Expand Up @@ -51,6 +51,7 @@ include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/debug/
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/pages/
${CMAKE_CURRENT_SOURCE_DIR}/dialogs/widgets/
${CMAKE_CURRENT_SOURCE_DIR}/docgenerators/
${CMAKE_CURRENT_SOURCE_DIR}/finder/
${CMAKE_CURRENT_SOURCE_DIR}/refactoring/
Expand Down Expand Up @@ -222,6 +223,7 @@ set(libdialogs_SRCS
dialogs/pages/diagramprintpage.cpp
dialogs/pages/umlroleproperties.cpp
dialogs/pages/umlwidgetstylepage.cpp
dialogs/widgets/documentationwidget.cpp
)

kde4_add_ui_files( libdialogs_SRCS
Expand Down
6 changes: 6 additions & 0 deletions umbrello/dialogs/umlattributedialog.cpp
Expand Up @@ -14,6 +14,7 @@
// app includes
#include "attribute.h"
#include "classifier.h"
#include "documentationwidget.h"
#include "template.h"
#include "umldoc.h"
#include "uml.h"
Expand Down Expand Up @@ -136,6 +137,9 @@ void UMLAttributeDialog::setupDialog()
//now add the Concepts
insertTypesSorted(m_pAttribute->getTypeName());

m_docWidget = new DocumentationWidget(m_pAttribute, this);
mainLayout->addWidget(m_docWidget);

m_pNameLE->setFocus();
connect(m_pNameLE, SIGNAL(textChanged(QString)), SLOT(slotNameChanged(QString)));
slotNameChanged(m_pNameLE->text());
Expand Down Expand Up @@ -229,6 +233,8 @@ bool UMLAttributeDialog::apply()
classifier = static_cast<UMLClassifier*>(obj);
}
m_pAttribute->setType(classifier);
m_docWidget->apply();

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions umbrello/dialogs/umlattributedialog.h
Expand Up @@ -13,6 +13,7 @@

#include <kdialog.h>

class DocumentationWidget;
class QCheckBox;
class QGroupBox;
class QRadioButton;
Expand Down Expand Up @@ -53,6 +54,7 @@ class UMLAttributeDialog : public KDialog
KComboBox * m_pTypeCB;
KLineEdit * m_pNameLE, * m_pInitialLE, * m_pStereoTypeLE;
QCheckBox* m_pStaticCB;
DocumentationWidget *m_docWidget;

public slots:

Expand Down
5 changes: 5 additions & 0 deletions umbrello/dialogs/umloperationdialog.cpp
Expand Up @@ -21,6 +21,7 @@
#include "listpopupmenu.h"
#include "umlattributelist.h"
#include "classifierlistitem.h"
#include "documentationwidget.h"
#include "umlclassifierlistitemlist.h"
#include "dialog_utils.h"
#include "parameterpropertiesdialog.h"
Expand Down Expand Up @@ -137,6 +138,8 @@ void UMLOperationDialog::setupDialog()
m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeGB);
scopeLayout->addWidget(m_pImplementationRB);

m_docWidget = new DocumentationWidget(m_operation, this);

m_pParmsGB = new QGroupBox(i18n("Parameters"), frame);
QVBoxLayout* parmsLayout = new QVBoxLayout(m_pParmsGB);
parmsLayout->setMargin(margin);
Expand Down Expand Up @@ -176,6 +179,7 @@ void UMLOperationDialog::setupDialog()

topLayout->addWidget(m_pGenGB);
topLayout->addWidget(m_pScopeGB);
topLayout->addWidget(m_docWidget);
topLayout->addWidget(m_pParmsGB);

m_pDeleteButton->setEnabled(false);
Expand Down Expand Up @@ -485,6 +489,7 @@ bool UMLOperationDialog::apply()
}
m_operation->setStatic(m_pStaticCB->isChecked());
m_operation->setConst(m_pQueryCB->isChecked());
m_docWidget->apply();

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions umbrello/dialogs/umloperationdialog.h
Expand Up @@ -17,6 +17,7 @@
//qt includes
#include <QListWidgetItem>

class DocumentationWidget;
class UMLOperation;
class ListPopupMenu;
class QGroupBox;
Expand Down Expand Up @@ -77,6 +78,7 @@ class UMLOperationDialog : public KDialog
QPushButton* m_pPropertiesButton;
QToolButton* m_pUpButton;
QToolButton* m_pDownButton;
DocumentationWidget* m_docWidget;

public slots:
void slotParmRightButtonPressed(const QPoint &p);
Expand Down
5 changes: 5 additions & 0 deletions umbrello/dialogs/umltemplatedialog.cpp
Expand Up @@ -14,6 +14,7 @@
// app includes
#include "template.h"
#include "classifier.h"
#include "documentationwidget.h"
#include "umldoc.h"
#include "uml.h"
#include "dialog_utils.h"
Expand Down Expand Up @@ -83,6 +84,9 @@ void UMLTemplateDialog::setupDialog()

mainLayout->addWidget(m_pValuesGB);

m_docWidget = new DocumentationWidget(m_pTemplate, this);
mainLayout->addWidget(m_docWidget);

m_pTypeCB->setEditable(true);
m_pTypeCB->setDuplicatesEnabled(false); // only allow one of each type in box
m_pTypeCB->setCompletionMode(KGlobalSettings::CompletionPopup);
Expand Down Expand Up @@ -164,6 +168,7 @@ bool UMLTemplateDialog::apply()
m_pTemplate->setName(name);

m_pTemplate->setStereotype(m_pStereoTypeLE->text());
m_docWidget->apply();

return true;
}
Expand Down
2 changes: 2 additions & 0 deletions umbrello/dialogs/umltemplatedialog.h
Expand Up @@ -13,6 +13,7 @@

#include <kdialog.h>

class DocumentationWidget;
class KComboBox;
class KLineEdit;
class QGroupBox;
Expand Down Expand Up @@ -48,6 +49,7 @@ class UMLTemplateDialog : public KDialog
QLabel *m_pTypeL, *m_pNameL, *m_pStereoTypeL;
KComboBox *m_pTypeCB;
KLineEdit *m_pNameLE, *m_pStereoTypeLE;
DocumentationWidget *m_docWidget;

public slots:

Expand Down
51 changes: 51 additions & 0 deletions umbrello/dialogs/widgets/documentationwidget.cpp
@@ -0,0 +1,51 @@
/***************************************************************************
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2002-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/

#include "documentationwidget.h"

#include "umlobject.h"

#include <KTextEdit>
#include <KLocalizedString>

#include <QGroupBox>
#include <QHBoxLayout>

DocumentationWidget::DocumentationWidget(UMLObject *o, QWidget *parent) :
QWidget(parent),
m_object(o)
{
Q_ASSERT(o);

QVBoxLayout *l = new QVBoxLayout;
m_box = new QGroupBox;
m_box->setTitle(i18n("Documentation"));
m_editField = new KTextEdit(m_box);
m_editField->setText(o->doc());
QVBoxLayout *layout = new QVBoxLayout(m_box);
layout->addWidget(m_editField);
l->addWidget(m_box);
setLayout(l);
}

DocumentationWidget::~DocumentationWidget()
{
delete m_editField;
delete m_box;
}

/**
* Apply changes to the related UMLObject.
*/
void DocumentationWidget::apply()
{
m_object->setDoc(m_editField->toPlainText());
}

38 changes: 38 additions & 0 deletions umbrello/dialogs/widgets/documentationwidget.h
@@ -0,0 +1,38 @@
/***************************************************************************
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2002-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/

#ifndef DOCUMENTATIONWIDGET_H
#define DOCUMENTATIONWIDGET_H

#include <QWidget>

class UMLObject;

class KTextEdit;

class QGridLayout;
class QGroupBox;

class DocumentationWidget : public QWidget
{
Q_OBJECT
public:
DocumentationWidget(UMLObject *o, QWidget *parent = 0);
~DocumentationWidget();

void apply();

protected:
QGroupBox *m_box;
KTextEdit *m_editField;
UMLObject *m_object;
};

#endif // DOCUMENTATIONWIDGET_H

0 comments on commit 739d8c0

Please sign in to comment.