Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit cbbd1db4 authored by Ralf Habacker's avatar Ralf Habacker

Use class DocumentationWidget instance in class general page.

parent c4fb26c4
......@@ -13,6 +13,7 @@
// app includes
#include "debug_utils.h"
#include "documentationwidget.h"
#include "dialog_utils.h"
#include "classifier.h"
#include "umlobject.h"
......@@ -205,19 +206,11 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
scopeLayout->addWidget(m_pImplementationRB);
topLayout->addWidget(m_pButtonGB);
// setup documentation
m_docGB = new QGroupBox(this);
QHBoxLayout * docLayout = new QHBoxLayout(m_docGB);
docLayout->setMargin(margin);
m_docGB->setTitle(i18n("Documentation"));
m_doc = new KTextEdit(m_docGB);
docLayout->addWidget(m_doc);
topLayout->addWidget(m_docGB);
m_docWidget = new DocumentationWidget(m_pObject, this);
topLayout->addWidget(m_docWidget);
// setup fields
m_pClassNameLE->setText(m_pObject->name());
m_doc->setText(m_pObject->doc());
switch (m_pObject->visibility()) {
case Uml::Visibility::Public:
......@@ -238,8 +231,6 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLObject* o)
m_pStereoTypeCB->setDuplicatesEnabled(false); // only allow one of each type in box
m_pStereoTypeCB->setCompletionMode(KGlobalSettings::CompletionPopup);
Dialog_Utils::insertStereotypesSorted(m_pStereoTypeCB, m_pObject->stereotype());
m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
}
ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, ObjectWidget* o)
......@@ -254,8 +245,6 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, ObjectWidget* o)
m_pDeconCB = 0;
m_pMultiCB = 0;
int margin = fontMetrics().height();
setMinimumSize(310, 330);
QVBoxLayout * topLayout = new QVBoxLayout(this);
topLayout->setSpacing(6);
......@@ -296,17 +285,9 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, ObjectWidget* o)
m_pDeconCB->setChecked(m_pWidget->showDestruction());
m_pNameLayout->addWidget(m_pDeconCB, 2, 1);
}
// setup documentation
m_docGB = new QGroupBox(this);
QHBoxLayout * docLayout = new QHBoxLayout(m_docGB);
docLayout->setMargin(margin);
m_docGB->setTitle(i18n("Documentation"));
m_doc = new KTextEdit(m_docGB);
m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
m_doc->setText(m_pWidget->documentation());
docLayout->addWidget(m_doc);
topLayout->addWidget(m_docGB);
m_docWidget = new DocumentationWidget(m_pObject, this);
topLayout->addWidget(m_docWidget);
if (m_pMultiCB) {
connect(m_pDrawActorCB, SIGNAL(toggled(bool)), this, SLOT(slotActorToggled(bool)));
}
......@@ -319,8 +300,6 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLWidget* widget
m_pDeconCB = 0;
m_pMultiCB = 0;
int margin = fontMetrics().height();
setMinimumSize(310, 330);
QGridLayout* topLayout = new QGridLayout(this);
topLayout->setSpacing(6);
......@@ -360,17 +339,8 @@ ClassGeneralPage::ClassGeneralPage(UMLDoc* d, QWidget* parent, UMLWidget* widget
m_pInstanceLE->setText(widget->instanceName());
m_pNameLayout->addWidget(m_pInstanceLE, 2, 1);
//setup documentation
m_docGB = new QGroupBox(this);
topLayout->addWidget(m_docGB, 1, 0);
QHBoxLayout* docLayout = new QHBoxLayout(m_docGB);
docLayout->setMargin(margin);
m_docGB->setTitle(i18n("Documentation"));
m_doc = new KTextEdit(m_docGB);
m_doc->setLineWrapMode(QTextEdit::WidgetWidth);
m_doc->setText(widget->documentation());
docLayout->addWidget(m_doc);
m_docWidget = new DocumentationWidget(widget, this);
topLayout->addWidget(m_docWidget);
}
ClassGeneralPage::~ClassGeneralPage()
......@@ -386,7 +356,7 @@ void ClassGeneralPage::updateObject()
if (m_pObject) {
QString name = m_pClassNameLE->text();
m_pObject->setDoc(m_doc->toPlainText());
m_docWidget->apply();
if (m_pStereoTypeCB) {
m_pObject->setStereotype(m_pStereoTypeCB->currentText());
......@@ -461,7 +431,6 @@ void ClassGeneralPage::updateObject()
m_pWidget->setShowDestruction(m_pDeconCB->isChecked());
}
QString name = m_pClassNameLE->text();
m_pWidget->setDocumentation(m_doc->toPlainText());
UMLObject * o = m_pWidget->umlObject();
UMLObject * old = m_pUmldoc->findUMLObject(name);
if (old && o != old) {
......@@ -474,7 +443,6 @@ void ClassGeneralPage::updateObject()
else if (m_pInstanceWidget) {
m_pInstanceWidget->setInstanceName(m_pInstanceLE->text());
QString name = m_pClassNameLE->text();
m_pInstanceWidget->setDocumentation(m_doc->toPlainText());
UMLObject* o = m_pInstanceWidget->umlObject();
UMLObject* old = m_pUmldoc->findUMLObject(name);
if (old && o != old) {
......
......@@ -13,13 +13,13 @@
#include "dialogpagebase.h"
class DocumentationWidget;
class QGroupBox;
class QLabel;
class QRadioButton;
class QCheckBox;
class KComboBox;
class KLineEdit;
class KTextEdit;
class UMLObject;
class UMLWidget;
......@@ -78,14 +78,13 @@ private:
UMLWidget * m_pInstanceWidget;
UMLDoc * m_pUmldoc;
QGroupBox * m_docGB;
QGroupBox * m_pButtonGB;
QLabel * m_pNameL, * m_pInstanceL, * m_pStereoTypeL, * m_pPackageL;
KLineEdit * m_pClassNameLE, * m_pInstanceLE, * m_pPackageLE;
KComboBox * m_pStereoTypeCB, * m_pPackageCB ;
QRadioButton * m_pPublicRB, * m_pPrivateRB, * m_pProtectedRB, * m_pImplementationRB;
QCheckBox * m_pMultiCB, * m_pDrawActorCB, * m_pAbstractCB, * m_pDeconCB;
KTextEdit * m_doc;
DocumentationWidget *m_docWidget;
QGroupBox * m_pDrawAsGB;
QRadioButton * m_pDefaultRB, * m_pFileRB, * m_pLibraryRB, * m_pTableRB;
QCheckBox * m_pExecutableCB;
......
......@@ -11,6 +11,7 @@
#include "documentationwidget.h"
#include "umlobject.h"
#include "umlwidget.h"
#include <KTextEdit>
#include <KLocalizedString>
......@@ -20,19 +21,20 @@
DocumentationWidget::DocumentationWidget(UMLObject *o, QWidget *parent) :
QWidget(parent),
m_object(o)
m_object(o),
m_widget(0)
{
Q_ASSERT(o);
init(o->doc());
}
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(UMLWidget *w, QWidget *parent) :
QWidget(parent),
m_object(0),
m_widget(w)
{
Q_ASSERT(w);
init(w->documentation());
}
DocumentationWidget::~DocumentationWidget()
......@@ -46,6 +48,27 @@ DocumentationWidget::~DocumentationWidget()
*/
void DocumentationWidget::apply()
{
m_object->setDoc(m_editField->toPlainText());
if (m_object)
m_object->setDoc(m_editField->toPlainText());
else if (m_widget)
m_widget->setDocumentation(m_editField->toPlainText());
}
/**
* initialize widget
* @param text text to display
*/
void DocumentationWidget::init(const QString &text)
{
QHBoxLayout *l = new QHBoxLayout;
m_box = new QGroupBox;
m_box->setTitle(i18n("Documentation"));
m_editField = new KTextEdit(m_box);
m_editField->setLineWrapMode(QTextEdit::WidgetWidth);
m_editField->setText(text);
QHBoxLayout *layout = new QHBoxLayout(m_box);
layout->addWidget(m_editField);
layout->setMargin(fontMetrics().height());
l->addWidget(m_box);
setLayout(l);
}
......@@ -14,6 +14,7 @@
#include <QWidget>
class UMLObject;
class UMLWidget;
class KTextEdit;
......@@ -25,6 +26,7 @@ class DocumentationWidget : public QWidget
Q_OBJECT
public:
DocumentationWidget(UMLObject *o, QWidget *parent = 0);
DocumentationWidget(UMLWidget *w, QWidget *parent = 0);
~DocumentationWidget();
void apply();
......@@ -33,6 +35,8 @@ protected:
QGroupBox *m_box;
KTextEdit *m_editField;
UMLObject *m_object;
UMLWidget *m_widget;
void init(const QString &text);
};
#endif // DOCUMENTATIONWIDGET_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment