@@ -664,6 +664,7 @@ PlainTextEdit::PlainTextEdit(BaseEditor *pBaseEditor)
664664 : QPlainTextEdit(pBaseEditor), mpBaseEditor(pBaseEditor)
665665{
666666 setObjectName (" BaseEditor" );
667+ setMouseTracking (true );
667668 QTextDocument *pTextDocument = document ();
668669 pTextDocument->setDocumentMargin (2 );
669670 BaseEditorDocumentLayout *pModelicaTextDocumentLayout = new BaseEditorDocumentLayout (pTextDocument);
@@ -1375,7 +1376,6 @@ void PlainTextEdit::toggleBlockVisible(const QTextBlock &block)
13751376 pBaseEditorDocumentLayout->emitDocumentSizeChanged ();
13761377}
13771378
1378-
13791379/* !
13801380 * \brief BaseEditor::updateLineNumberAreaWidth
13811381 * Updates the width of LineNumberArea.
@@ -2053,6 +2053,38 @@ void PlainTextEdit::wheelEvent(QWheelEvent *event)
20532053 QPlainTextEdit::wheelEvent (event);
20542054}
20552055
2056+ /* !
2057+ * \brief PlainTextEdit::mousePressEvent
2058+ * Reimplementation of QPlainTextEdit::mousePressEvent
2059+ * \param event
2060+ */
2061+ void PlainTextEdit::mousePressEvent (QMouseEvent *event)
2062+ {
2063+ bool controlModifier = event->modifiers ().testFlag (Qt::ControlModifier);
2064+ if (controlModifier) {
2065+ mpBaseEditor->symbolAtPosition (event->pos ());
2066+ viewport ()->unsetCursor ();
2067+ }
2068+ QPlainTextEdit::mousePressEvent (event);
2069+ }
2070+
2071+ /* !
2072+ * \brief PlainTextEdit::mouseMoveEvent
2073+ * Reimplementation of QPlainTextEdit::mouseMoveEvent
2074+ * \param event
2075+ */
2076+ void PlainTextEdit::mouseMoveEvent (QMouseEvent *event)
2077+ {
2078+ bool controlModifier = event->modifiers ().testFlag (Qt::ControlModifier);
2079+ if (controlModifier) {
2080+ viewport ()->setCursor (Qt::PointingHandCursor);
2081+ } else {
2082+ viewport ()->unsetCursor ();
2083+ }
2084+
2085+ QPlainTextEdit::mouseMoveEvent (event);
2086+ }
2087+
20562088/* !
20572089 * \class BaseEditor
20582090 * Base class for all editors.
@@ -2074,6 +2106,7 @@ BaseEditor::BaseEditor(QWidget *pParent)
20742106
20752107/* !
20762108 * \brief BaseEditor::wordUnderCursor
2109+ * Returns the word under cursor.
20772110 */
20782111QString BaseEditor::wordUnderCursor ()
20792112{
@@ -2082,6 +2115,19 @@ QString BaseEditor::wordUnderCursor()
20822115 return cursor.selectedText ();
20832116}
20842117
2118+ /* !
2119+ * \brief BaseEditor::symbolAtPosition
2120+ * Navigates to the symbol at position.\n
2121+ * The default implementation does nothing.\n
2122+ * Reimplement in the child class to navigate to the correct symbol based on the language.
2123+ * \param pos
2124+ */
2125+ void BaseEditor::symbolAtPosition (const QPoint &pos)
2126+ {
2127+ Q_UNUSED (pos);
2128+ // Do nothing. Reimplement in the child class.
2129+ }
2130+
20852131bool BaseEditor::isModelicaModelInPackageOneFile ()
20862132{
20872133 return (mpModelWidget && mpModelWidget->getLibraryTreeItem () &&
@@ -2161,6 +2207,10 @@ void BaseEditor::createActions()
21612207 connect (mpZoomOutAction, SIGNAL (triggered ()), mpPlainTextEdit, SLOT (zoomOut ()));
21622208 mpPlainTextEdit->addAction (mpZoomOutAction);
21632209 }
2210+ // open class action
2211+ mpOpenClassAction = new QAction (Helper::openClass, this );
2212+ mpOpenClassAction->setStatusTip (Helper::openClassTip);
2213+ connect (mpOpenClassAction, SIGNAL (triggered ()), SLOT (openClass ()));
21642214 // toggle comment action
21652215 mpToggleCommentSelectionAction = new QAction (tr (" Toggle Comment Selection" ), this );
21662216 mpToggleCommentSelectionAction->setShortcut (QKeySequence (" Ctrl+k" ));
@@ -2325,6 +2375,17 @@ void BaseEditor::showGotoLineNumberDialog()
23252375 pGotoLineWidget->exec ();
23262376}
23272377
2378+ /* !
2379+ * \brief BaseEditor::openClass
2380+ * Slot activated when open class is seleteted from context menu.
2381+ */
2382+ void BaseEditor::openClass ()
2383+ {
2384+ if (mContextMenuStartPositionValid ) {
2385+ symbolAtPosition (mContextMenuStartPosition );
2386+ }
2387+ }
2388+
23282389/* !
23292390 * \brief BaseEditor::toggleCommentSelection
23302391 * Slot activated when toggle comment selection is seleteted from context menu or ctrl+k is pressed.
0 commit comments