KTutorial  0.5.1
Public Member Functions | Protected Member Functions
ktutorial::view::StepTextWidget Class Reference

A TextEdit with the appearance of a label to show the text of a step. More...

#include <StepTextWidget.h>

List of all members.

Public Member Functions

 StepTextWidget (QWidget *parent=0)
 Creates a new StepTextWidget.
virtual ~StepTextWidget ()
 Destroys this StepTextWidget.
virtual bool eventFilter (QObject *watched, QEvent *event)
 Watches the widget currently being highlighted and stops the highlighting when it is focused.
virtual int heightForWidth (int width) const
 Returns the height of the size for the given width.
virtual QSize minimumSizeHint () const
 Returns the recommended minimum size for this StepTextWidget.
virtual QSize sizeHint () const
 Returns the recommended size for this StepTextWidget.

Protected Member Functions

virtual void contextMenuEvent (QContextMenuEvent *event)
 Shows a custom context menu when a context menu is requested on a "widget:" anchor.
virtual void mouseMoveEvent (QMouseEvent *event)
 Changes the cursor to a pointing hand when it is over a "widget:" anchor.
virtual void mousePressEvent (QMouseEvent *event)
 When the mouse is pressed on a "widget:" anchor, it is highlighted or stopped being highlighted.

Detailed Description

A TextEdit with the appearance of a label to show the text of a step.

It behaves like a QLabel with custom behavior for links. However, as QLabel doesn't provide a way to easily extend its link related behavior, a KTextEdit with a QLabel appearance (read only, size fit to text, no scroll bars...) is used instead.

Links that exhibit a custom behavior are those with the format "widget:nameOfTheWidget". When the link is pressed with the left mouse button, the widget with the specified name is highlighted. When it is pressed again, the highlighting is stopped. If the right button is pressed, a context menu with an item to highlight or stop highlighting is shown.

If a widget was being highlighted when the highglighting is started in another widget, the highlighting in the previous widget is stopped. The highlighting is also stopped when the widget gets the focus, or when the text is changed in the StepTextWidget.

When the mouse cursor is moved over a "widget:" link, the arrow cursor is changed to a pointing hand cursor.

The links are specified using HTML markup, for example, <a href="widget:theNameOfTheWidget">the text of the link</a>

Definition at line 54 of file StepTextWidget.h.


Constructor & Destructor Documentation

ktutorial::view::StepTextWidget::StepTextWidget ( QWidget *  parent = 0) [explicit]

Creates a new StepTextWidget.

Parameters:
parentThe parent widget.

Definition at line 42 of file StepTextWidget.cpp.

Destroys this StepTextWidget.

If there is a widget being highlighted, the highlighting is stopped.

Definition at line 70 of file StepTextWidget.cpp.


Member Function Documentation

void ktutorial::view::StepTextWidget::contextMenuEvent ( QContextMenuEvent *  event) [protected, virtual]

Shows a custom context menu when a context menu is requested on a "widget:" anchor.

The context menu will contain a "Stop highlighting" or a "Highlight" item depending on whether the widget is the one currently being highlighted or not.

Parameters:
eventThe context menu event.

Definition at line 108 of file StepTextWidget.cpp.

bool ktutorial::view::StepTextWidget::eventFilter ( QObject *  watched,
QEvent *  event 
) [virtual]

Watches the widget currently being highlighted and stops the highlighting when it is focused.

Parameters:
watchedThe filtered object that received an event.
eventThe event received.
Returns:
False, to allow the event to be handled further.

Definition at line 76 of file StepTextWidget.cpp.

int ktutorial::view::StepTextWidget::heightForWidth ( int  width) const [virtual]

Returns the height of the size for the given width.

Parameters:
widthThe width to get its height.
Returns:
The height for the width.

Definition at line 90 of file StepTextWidget.cpp.

Returns the recommended minimum size for this StepTextWidget.

The size has the width of the longest word in the text and the height of a single line.

Returns:
The recommended minimum size.

Definition at line 94 of file StepTextWidget.cpp.

void ktutorial::view::StepTextWidget::mouseMoveEvent ( QMouseEvent *  event) [protected, virtual]

Changes the cursor to a pointing hand when it is over a "widget:" anchor.

Parameters:
eventThe mouse move event.

Definition at line 130 of file StepTextWidget.cpp.

void ktutorial::view::StepTextWidget::mousePressEvent ( QMouseEvent *  event) [protected, virtual]

When the mouse is pressed on a "widget:" anchor, it is highlighted or stopped being highlighted.

Parameters:
eventThe mouse press event.

Definition at line 140 of file StepTextWidget.cpp.

QSize ktutorial::view::StepTextWidget::sizeHint ( ) const [virtual]

Returns the recommended size for this StepTextWidget.

The size is adjusted to fit the text as a rectangle, with a width bigger then the height.

Returns:
The recommended size.

Definition at line 102 of file StepTextWidget.cpp.


The documentation for this class was generated from the following files: