[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [umbrello] umbrello: Fix bug 'Note widget text disappears on selection change (edit)'.
From:       Ralf Habacker <ralf.habacker () freenet ! de>
Date:       2015-02-28 21:36:14
Message-ID: E1YRp3W-00036x-5J () scm ! kde ! org
[Download RAW message or body]

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 <umbrello-devel@kde.org>                *
+ ***************************************************************************/
+
+// own header
+#include "notedialog.h"
+
+#include "notewidget.h"
+#include "documentationwidget.h"
+
+// kde includes
+#include <klocale.h>
+
+// qt includes
+#include <QFrame>
+#include <QVBoxLayout>
+
+/**
+ * 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 = pNote;
+    QFrame *frame = new QFrame(this);
+    setMainWidget(frame);
+    m_docWidget = new DocumentationWidget(m_pNoteWidget);
+    QVBoxLayout *layout = 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 <umbrello-devel@kde.org>                *
+ ***************************************************************************/
+
+#ifndef NOTEDIALOG_H
+#define NOTEDIALOG_H
+
+// kde includes
+#include <KDialog>
+
+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, QDomElement & qElement)
 }
 
 /**
- * Rename the text of the note widget.
+ * Show a properties dialog for a NoteWidget.
  */
-void NoteWidget::rename()
+void NoteWidget::showPropertiesDialog()
 {
-    bool ok = false;
-    QString newNote = KInputDialog::getMultiLineText(i18n("Changing note"),
-                                                     i18n("Enter note:"),
-                                                     documentation(), &ok,
-                                                     (QWidget*)UMLApp::app());
-    if (ok) {
-        setDocumentation(newNote);
+    NoteDialog * dlg = 0;
+    UMLApp::app()->docWindow()->updateDocumentation(false);
+    dlg = 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 = ListPopupMenu::typeFromAction(action);
     switch(sel) {
     case ListPopupMenu::mt_Rename:
-        rename();
+        showPropertiesDialog();
         break;
 
     default:
@@ -491,7 +493,7 @@ void NoteWidget::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
 {
     if (event->button() == Qt::LeftButton) {
         if (m_diagramLink == Uml::ID::None) {
-            rename();
+            showPropertiesDialog();
         } else {
             UMLDoc *umldoc = 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 to.
     NoteType      m_noteType;     ///< The type of note. @see NoteWidget::NoteType
-
-    void rename();
 };
 
 #endif
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic