Commit 52fe3a6e authored by Ralf Habacker's avatar Ralf Habacker

Fix 'Notes diagram link could not be changed'

The notes property dialog did not update the diagram link
into the related widget.

Diagram links are created by pasting a diagramm entry
from the tree view into a different diagram or by entering
'Diagram:' followed by the diagram name into a notes widget.

BUG:390891
FIXED-IN:2.24.3 (KDE Applications 17.12.3)
parent 1ee66330
......@@ -49,6 +49,14 @@ NoteDialog::~NoteDialog()
bool NoteDialog::apply()
{
m_docWidget->apply();
QString key = QLatin1String("Diagram:");
QString str = m_noteWidget->documentation();
if (!str.startsWith(key)) {
m_noteWidget->setDiagramLink(QString());
return true;
}
QString diagramName = str.remove(key).trimmed();
m_noteWidget->setDiagramLink(diagramName);
return true;
}
......@@ -181,6 +181,40 @@ void NoteWidget::setDiagramLink(Uml::ID::Type viewID)
update();
}
/**
* Set the given diagram as hyperlinked to this note.
* If the diagram name is empty or the related view
* could not be found, the link will be removed.
*
* @param diagramName name of diagram to link to
* @return true if link could be added
* @return false if link could not be added
*/
bool NoteWidget::setDiagramLink(const QString &diagramName)
{
if (diagramName.isEmpty()) {
m_diagramLink = Uml::ID::None;
return true;
}
UMLDoc *umldoc = UMLApp::app()->document();
UMLView *view = 0;
for (int i = 1; i < Uml::DiagramType::N_DIAGRAMTYPES; ++i) {
Uml::DiagramType::Enum dt = Uml::DiagramType::fromInt(i);
view = umldoc->findView(dt, diagramName, true);
if (view)
break;
}
if (view == 0 || view->umlScene() == 0) {
m_diagramLink = Uml::ID::None;
return false;
}
m_diagramLink = view->umlScene()->ID();
update();
return true;
}
/**
/**
* Display a dialog box to allow the user to choose the note's type.
*/
......
......@@ -55,6 +55,7 @@ public:
Uml::ID::Type diagramLink() const;
void setDiagramLink(Uml::ID::Type viewID);
bool setDiagramLink(const QString &diagramName);
void askForNoteType(UMLWidget* &targetWidget);
......
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