From kde-commits Sat Feb 28 21:36:14 2015 From: Ralf Habacker Date: Sat, 28 Feb 2015 21:36:14 +0000 To: kde-commits Subject: [umbrello] umbrello: Fix bug 'Note widget text disappears on selection change (edit)'. Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=142515938324385 Git commit eb929df31389b2adc50818098d833560e5bc43e2 by Ralf Habacker. Committed on 28/02/2015 at 19:08. Pushed by habacker into branch 'master'. Fix bug 'Note widget text disappears on selection change (edit)'. The NoteWidget properties dialog has been refactored to keep api in sync with other widgets dialogs. BUG:344501 FIXED-IN:2.15.80 (KDE 14.12.80) M +1 -0 umbrello/CMakeLists.txt A +59 -0 umbrello/dialogs/notedialog.cpp [License: GPL (v2+)] A +39 -0 umbrello/dialogs/notedialog.h [License: GPL (v2+)] M +13 -11 umbrello/widgets/notewidget.cpp M +2 -2 umbrello/widgets/notewidget.h http://commits.kde.org/umbrello/eb929df31389b2adc50818098d833560e5bc43e2 diff --git a/umbrello/CMakeLists.txt b/umbrello/CMakeLists.txt index 4fbba28..ef625d3 100644 --- a/umbrello/CMakeLists.txt +++ b/umbrello/CMakeLists.txt @@ -187,6 +187,7 @@ set(libdialogs_SRCS dialogs/dialogbase.cpp dialogs/exportallviewsdialog.cpp dialogs/finddialog.cpp + dialogs/notedialog.cpp dialogs/objectnodedialog.cpp dialogs/overwritedialog.cpp dialogs/parameterpropertiesdialog.cpp diff --git a/umbrello/dialogs/notedialog.cpp b/umbrello/dialogs/notedialog.= cpp new file mode 100644 index 0000000..a464a6e --- /dev/null +++ b/umbrello/dialogs/notedialog.cpp @@ -0,0 +1,59 @@ +/*************************************************************************= ** + * 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-2015 = * + * Umbrello UML Modeller Authors = * + *************************************************************************= **/ + +// own header +#include "notedialog.h" + +#include "notewidget.h" +#include "documentationwidget.h" + +// kde includes +#include + +// qt includes +#include +#include + +/** + * Constructs an NoteDialog. + */ +NoteDialog::NoteDialog(QWidget * parent, NoteWidget * pNote) + : KDialog(parent) +{ + setCaption(i18n("Note Documentation")); + setButtons(Ok | Cancel); + setDefaultButton(Ok); + setModal(true); + showButtonSeparator(true); + + m_pNoteWidget =3D pNote; + QFrame *frame =3D new QFrame(this); + setMainWidget(frame); + m_docWidget =3D new DocumentationWidget(m_pNoteWidget); + QVBoxLayout *layout =3D new QVBoxLayout(frame); + layout->addWidget(m_docWidget, 10); + setMinimumSize(600, 250); + connect(this, SIGNAL(okClicked()), this, SLOT(slotOk())); +} + +/** + * Standard destructor. + */ +NoteDialog::~NoteDialog() +{ +} + +void NoteDialog::slotOk() +{ + m_docWidget->apply(); + accept(); +} + +#include "notedialog.moc" diff --git a/umbrello/dialogs/notedialog.h b/umbrello/dialogs/notedialog.h new file mode 100644 index 0000000..ffeff94 --- /dev/null +++ b/umbrello/dialogs/notedialog.h @@ -0,0 +1,39 @@ +/*************************************************************************= ** + * 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-2015 = * + * Umbrello UML Modeller Authors = * + *************************************************************************= **/ + +#ifndef NOTEDIALOG_H +#define NOTEDIALOG_H + +// kde includes +#include + +class DocumentationWidget; +class NoteWidget; + +/** + * @author Paul Hensgen + * Bugs and comments to umbrello-devel@kde.org or http://bugs.kde.org + */ +class NoteDialog : public KDialog +{ + Q_OBJECT +public: + NoteDialog(QWidget *parent, NoteWidget *pNote); + ~NoteDialog(); + +public slots: + void slotOk(); + +private: + DocumentationWidget *m_docWidget; ///< widget holding the documentation + NoteWidget *m_pNoteWidget; ///< note widget to show documentation for +}; + +#endif diff --git a/umbrello/widgets/notewidget.cpp b/umbrello/widgets/notewidget.= cpp index a450623..3b4ea7b 100644 --- a/umbrello/widgets/notewidget.cpp +++ b/umbrello/widgets/notewidget.cpp @@ -15,6 +15,7 @@ #include "debug_utils.h" #include "docwindow.h" #include "listpopupmenu.h" +#include "notedialog.h" #include "uml.h" #include "umldoc.h" #include "umlscene.h" @@ -228,18 +229,19 @@ void NoteWidget::saveToXMI(QDomDocument & qDoc, QDomE= lement & qElement) } = /** - * Rename the text of the note widget. + * Show a properties dialog for a NoteWidget. */ -void NoteWidget::rename() +void NoteWidget::showPropertiesDialog() { - bool ok =3D false; - QString newNote =3D KInputDialog::getMultiLineText(i18n("Changing note= "), - i18n("Enter note:"), - documentation(), &ok, - (QWidget*)UMLApp::app= ()); - if (ok) { - setDocumentation(newNote); + NoteDialog * dlg =3D 0; + UMLApp::app()->docWindow()->updateDocumentation(false); + dlg =3D new NoteDialog(umlScene()->activeView(), this); + if (dlg->exec()) { + UMLApp::app()->docWindow()->showDocumentation(this, true); + UMLApp::app()->document()->setModified(true); + update(); } + delete dlg; } = /** @@ -253,7 +255,7 @@ void NoteWidget::slotMenuSelection(QAction* action) ListPopupMenu::MenuType sel =3D ListPopupMenu::typeFromAction(action); switch(sel) { case ListPopupMenu::mt_Rename: - rename(); + showPropertiesDialog(); break; = default: @@ -491,7 +493,7 @@ void NoteWidget::mouseDoubleClickEvent(QGraphicsSceneMo= useEvent *event) { if (event->button() =3D=3D Qt::LeftButton) { if (m_diagramLink =3D=3D Uml::ID::None) { - rename(); + showPropertiesDialog(); } else { UMLDoc *umldoc =3D UMLApp::app()->document(); umldoc->changeCurrentView(m_diagramLink); diff --git a/umbrello/widgets/notewidget.h b/umbrello/widgets/notewidget.h index f929ae3..3216140 100644 --- a/umbrello/widgets/notewidget.h +++ b/umbrello/widgets/notewidget.h @@ -58,6 +58,8 @@ public: = void askForNoteType(UMLWidget* &targetWidget); = + virtual void showPropertiesDialog(); + virtual bool loadFromXMI(QDomElement & qElement); virtual void saveToXMI(QDomDocument & qDoc, QDomElement & qElement); = @@ -76,8 +78,6 @@ protected: private: Uml::ID::Type m_diagramLink; ///< The diagram/scene this note links t= o. NoteType m_noteType; ///< The type of note. @see NoteWidget::= NoteType - - void rename(); }; = #endif