umbrello 2.34.70-5524f40e1
Umbrello UML Modeller is a Unified Modelling Language (UML) diagram program based on KDE Technology
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CodeEditor Class Reference

#include <codeeditor.h>

Inheritance diagram for CodeEditor:
Collaboration diagram for CodeEditor:

Public Slots

void insertParagraph (const QString &text, int para)
 
void removeParagraph (int para)
 
void changeHighlighting (int signal)
 
void changeShowHidden (int signal)
 
void slotRedrawText ()
 

Public Member Functions

 CodeEditor (const QString &text, CodeViewerDialog *parent=0, CodeDocument *doc=0)
 
 CodeEditor (CodeViewerDialog *parent=0, CodeDocument *doc=0)
 
 ~CodeEditor ()
 
Settings::CodeViewerState state ()
 

Protected Slots

void slotCursorPositionChanged ()
 
void slotCopyTextBlock ()
 
void slotCutTextBlock ()
 
void slotPasteTextBlock ()
 
void slotChangeSelectedBlockView ()
 
void slotChangeSelectedBlockCommentView ()
 
void slotInsertCodeBlockAfterSelected ()
 
void slotInsertCodeBlockBeforeSelected ()
 

Protected Member Functions

bool close ()
 
void appendText (TextBlock *tblock)
 
void appendText (HierarchicalCodeBlock *hblock)
 
void appendText (CodeClassFieldDeclarationBlock *db)
 
void appendText (TextBlockList *items)
 
void appendText (CodeMethodBlock *mb)
 
void appendText (CodeComment *comment, TextBlock *parent, UMLObject *umlObj=0, const QString &compName=QString())
 
void appendText (CodeBlockWithComments *cb)
 
void rebuildView (int startCursorPos)
 
void contextMenuEvent (QContextMenuEvent *event)
 
void contentsMouseMoveEvent (QMouseEvent *e)
 
void keyPressEvent (QKeyEvent *e)
 
void mouseDoubleClickEvent (QMouseEvent *e)
 
void loadFromDocument ()
 
KMenu * createPopup ()
 

Private Member Functions

void insertText (const QString &text, TextBlock *parent, bool isEditable=false, const QColor &fgcolor=QColor("black"), const QColor &bgcolor=QColor("white"), UMLObject *umlobj=0, const QString &displayName=QString(), int startLine=-1)
 
void editTextBlock (TextBlock *tBlock, int para)
 
void clearText ()
 
QLabel * componentLabel ()
 
bool paraIsNotSingleLine (int para)
 
void expandSelectedParagraph (int where)
 
void contractSelectedParagraph (int where)
 
void updateTextBlockFromText (TextBlock *block)
 
void initText (CodeDocument *doc)
 
void init (CodeViewerDialog *parentDialog, CodeDocument *parentDoc)
 
void changeTextBlockHighlighting (TextBlock *tb, bool selected)
 
void setParagraphBackgroundColor (int position, const QColor &color)
 
bool isParaEditable (int para)
 
bool textBlockIsClickable (UMLObject *obj)
 
TextBlockfindTextBlockAt (int characterPos)
 
void clicked (int para, int pos)
 

Static Private Member Functions

static bool isNonBlank (const QString &str)
 

Private Attributes

QString m_parentDocName
 
CodeDocumentm_parentDoc
 
CodeViewerDialogm_parentDialog
 
int m_lastPara
 
int m_lastPos
 
bool m_newLinePressed
 
bool m_backspacePressed
 
bool m_isHighlighted
 
bool m_showHiddenBlocks
 
TextBlockm_textBlockToPaste
 
TextBlockm_selectedTextBlock
 
TextBlockm_lastTextBlockToBeEdited
 
QMap< TextBlock *, TextBlockInfo * > m_tbInfoMap
 
TextBlockList m_textBlockList
 

Constructor & Destructor Documentation

◆ CodeEditor() [1/2]

CodeEditor::CodeEditor ( const QString &  text,
CodeViewerDialog parent = 0,
CodeDocument doc = 0 
)
explicit

Constructor.

Here is the call graph for this function:

◆ CodeEditor() [2/2]

CodeEditor::CodeEditor ( CodeViewerDialog parent = 0,
CodeDocument doc = 0 
)
explicit

Constructor.

Here is the call graph for this function:

◆ ~CodeEditor()

CodeEditor::~CodeEditor ( )

Destructor.

Member Function Documentation

◆ appendText() [1/7]

void CodeEditor::appendText ( CodeBlockWithComments cb)
protected

Appends a CodeBlockWithComments to the widget.

Parameters
cbthe code block to add
Here is the call graph for this function:

◆ appendText() [2/7]

void CodeEditor::appendText ( CodeClassFieldDeclarationBlock db)
protected

Appends a CodeClassFieldDeclarationBlock to the widget.

Parameters
dbthe code class field declaration block to add
Here is the call graph for this function:

◆ appendText() [3/7]

void CodeEditor::appendText ( CodeComment comment,
TextBlock parent,
UMLObject umlObj = 0,
const QString &  componentName = QString() 
)
protected

Appends a CodeComment to the widget.

Parameters
commentthe code comment to add
parentthe parent text block
umlObjthe UML object
componentNamethe name of the component
Here is the call graph for this function:

◆ appendText() [4/7]

void CodeEditor::appendText ( CodeMethodBlock mb)
protected

Appends a CodeMethodBlock to the widget.

Parameters
mbthe code method block to add
Here is the call graph for this function:

◆ appendText() [5/7]

void CodeEditor::appendText ( HierarchicalCodeBlock hblock)
protected

Appends a HierarchicalCodeBlock to the widget.

Parameters
hblockthe hierarchical code block to add
Here is the call graph for this function:

◆ appendText() [6/7]

void CodeEditor::appendText ( TextBlock tb)
protected

Appends a TextBlock to the widget.

Parameters
tbthe text block to add
Here is the call graph for this function:

◆ appendText() [7/7]

void CodeEditor::appendText ( TextBlockList items)
protected

Appends a TextBlockList to the widget.

Parameters
itemslist of TextBlock items
Here is the call graph for this function:

◆ changeHighlighting

void CodeEditor::changeHighlighting ( int  signal)
slot

Colorizes/uncolorizes type for ALL paragraphs.

Here is the call graph for this function:

◆ changeShowHidden

void CodeEditor::changeShowHidden ( int  signal)
slot

:TODO:

Here is the call graph for this function:

◆ changeTextBlockHighlighting()

void CodeEditor::changeTextBlockHighlighting ( TextBlock tBlock,
bool  selected 
)
private

:TODO:

Here is the call graph for this function:

◆ clearText()

void CodeEditor::clearText ( )
private

Clear the display of all text.

◆ clicked()

void CodeEditor::clicked ( int  para,
int  pos 
)
private

TODO: Used only for debugging right now. int para = tc.position(); –> is the character in the editor int pos = tc.blockNumber(); –> is the row in the editor

Here is the call graph for this function:

◆ close()

bool CodeEditor::close ( )
protected

Slot which closes this widget. Returns true if the widget was closed; otherwise returns false. Reimplemented from QWidget.

Returns
state of close action
Here is the call graph for this function:

◆ componentLabel()

QLabel * CodeEditor::componentLabel ( )
private

Return the label on the dialog window. Some info can be shown.

Returns
label widget of dialog

◆ contentsMouseMoveEvent()

void CodeEditor::contentsMouseMoveEvent ( QMouseEvent *  e)
protected

Override the QT event so we can do appropriate things.

Here is the call graph for this function:

◆ contextMenuEvent()

void CodeEditor::contextMenuEvent ( QContextMenuEvent *  event)
protected

Shows the context menu. Reimplemented from QWidget::contextMenuEvent().

Here is the call graph for this function:

◆ contractSelectedParagraph()

void CodeEditor::contractSelectedParagraph ( int  paraToRemove)
private

:TODO:

◆ createPopup()

KMenu * CodeEditor::createPopup ( )
protected

Create the popup menu.

Returns
the popup menu
Here is the call graph for this function:

◆ editTextBlock()

void CodeEditor::editTextBlock ( TextBlock tBlock,
int  para 
)
private

Allow us to edit, as appropriate, the parent UMLObject of the given text block.

Here is the call graph for this function:

◆ expandSelectedParagraph()

void CodeEditor::expandSelectedParagraph ( int  priorPara)
private

:TODO:

Here is the call graph for this function:

◆ findTextBlockAt()

TextBlock * CodeEditor::findTextBlockAt ( int  characterPos)
private

Find the text block in which the character position is located.

Parameters
characterPosthe given character position
Returns
the text block in which the character position is found

◆ init()

void CodeEditor::init ( CodeViewerDialog parentDialog,
CodeDocument parentDoc 
)
private

Initialization routine which is used in the constructors.

Parameters
parentDialogthe parent CodeViewerDialog
parentDocthe parent CodeDocument
Here is the call graph for this function:

◆ initText()

void CodeEditor::initText ( CodeDocument doc)
private

◆ insertParagraph

void CodeEditor::insertParagraph ( const QString &  text,
int  para 
)
slot

Insert a paragraph at a given position.

Parameters
textthe paragraph text
parathe position where to add the text

◆ insertText()

void CodeEditor::insertText ( const QString &  text,
TextBlock parent,
bool  editable = false,
const QColor &  fgcolor = QColor("black"),
const QColor &  bgcolor = QColor("white"),
UMLObject umlobj = 0,
const QString &  displayName = QString(),
int  startLine = -1 
)
private

Main insert routine. Will append if startLine is not supplied or -1.

Parameters
textthe text which has to be inserted
parentthe parent TextBlock
editableflag if editable
fgcolorforeground color
bgcolorbackground color
umlobjthe UML object
displayNamethe name which can be displayed
startLinethe starting line
Here is the call graph for this function:

◆ isNonBlank()

bool CodeEditor::isNonBlank ( const QString &  str)
staticprivate

Return whether or not the passed string is empty or contains nothing but whitespace. Note: The logic is the other way round. In this way we do not need all the "!" in if statements.

◆ isParaEditable()

bool CodeEditor::isParaEditable ( int  para)
private

Checks if paragraph is editable or not. Method is used only in slotCursorPositionChanged.

Parameters
parathe desired paragraph (character number)
Returns
flag if paragraph is editable or not
Here is the call graph for this function:

◆ keyPressEvent()

void CodeEditor::keyPressEvent ( QKeyEvent *  e)
protected

Implemented so we may capture certain key presses, namely backspace and 'return' events.

◆ loadFromDocument()

void CodeEditor::loadFromDocument ( )
protected

(Re) Load the parent code document into the editor.

Here is the call graph for this function:

◆ mouseDoubleClickEvent()

void CodeEditor::mouseDoubleClickEvent ( QMouseEvent *  e)
protected

Override the QT event so we can do appropriate things.

Here is the call graph for this function:

◆ paraIsNotSingleLine()

bool CodeEditor::paraIsNotSingleLine ( int  para)
private

Check whether a block at a given position is on a single line.

Parameters
parathe index of the block in the list
Returns
flag whether block is on a single line

◆ rebuildView()

void CodeEditor::rebuildView ( int  startCursorPos)
protected

Rebuild our view of the document. Happens whenever we change some field/aspect of an underlying UML object used to create the view. If connections are right, then the UMLObject will send out the modified() signal which will trigger a call to re-generate the appropriate code within the code document. Our burden is to appropriately prepare the tool: we clear out ALL the textblocks in the KTextEdit widget and then re-show them after the dialog disappears.

Here is the call graph for this function:

◆ removeParagraph

void CodeEditor::removeParagraph ( int  para)
slot

Remove a paragraph from a given position.

Parameters
parathe position from where to remove the text

◆ setParagraphBackgroundColor()

void CodeEditor::setParagraphBackgroundColor ( int  position,
const QColor &  color 
)
private

Set the background color at the cursor position.

Parameters
positionthe character position
colorthe desired color

◆ slotChangeSelectedBlockCommentView

void CodeEditor::slotChangeSelectedBlockCommentView ( )
protectedslot

Change the status of the comment writeOutText value to opposite of current value.

Here is the call graph for this function:

◆ slotChangeSelectedBlockView

void CodeEditor::slotChangeSelectedBlockView ( )
protectedslot

Slot to change the view of the selected block. This is called from a popup menu item.

Here is the call graph for this function:

◆ slotCopyTextBlock

void CodeEditor::slotCopyTextBlock ( )
protectedslot

Slot to copy a text block.

Here is the call graph for this function:

◆ slotCursorPositionChanged

void CodeEditor::slotCursorPositionChanged ( )
protectedslot

Slot for cursor position changed signal.

Here is the call graph for this function:

◆ slotCutTextBlock

void CodeEditor::slotCutTextBlock ( )
protectedslot

Slot to cut a text block.

Here is the call graph for this function:

◆ slotInsertCodeBlockAfterSelected

void CodeEditor::slotInsertCodeBlockAfterSelected ( )
protectedslot

Slot to insert a code block after the selection.

Here is the call graph for this function:

◆ slotInsertCodeBlockBeforeSelected

void CodeEditor::slotInsertCodeBlockBeforeSelected ( )
protectedslot

Slot to insert a code block before the selection.

Here is the call graph for this function:

◆ slotPasteTextBlock

void CodeEditor::slotPasteTextBlock ( )
protectedslot

Slot to paste a text block.

Here is the call graph for this function:

◆ slotRedrawText

void CodeEditor::slotRedrawText ( )
slot

Slot to redraw the text.

Here is the call graph for this function:

◆ state()

Settings::CodeViewerState CodeEditor::state ( )

Return code viewer state.

Returns
state of the code viewer
Here is the call graph for this function:

◆ textBlockIsClickable()

bool CodeEditor::textBlockIsClickable ( UMLObject obj)
private

All umlobjects which may have pop-up boxes should return true here. Yes, a CRAPPY way of doing this. Im not proud. =b.t.

Here is the call graph for this function:

◆ updateTextBlockFromText()

void CodeEditor::updateTextBlockFromText ( TextBlock block)
private

Read the text under the cursor and add it to the text block.

Parameters
blockthe text block to which the text is added
Here is the call graph for this function:

Member Data Documentation

◆ m_backspacePressed

bool CodeEditor::m_backspacePressed
private

◆ m_isHighlighted

bool CodeEditor::m_isHighlighted
private

◆ m_lastPara

int CodeEditor::m_lastPara
private

◆ m_lastPos

int CodeEditor::m_lastPos
private

◆ m_lastTextBlockToBeEdited

TextBlock* CodeEditor::m_lastTextBlockToBeEdited
private

◆ m_newLinePressed

bool CodeEditor::m_newLinePressed
private

◆ m_parentDialog

CodeViewerDialog* CodeEditor::m_parentDialog
private

◆ m_parentDoc

CodeDocument* CodeEditor::m_parentDoc
private

◆ m_parentDocName

QString CodeEditor::m_parentDocName
private

◆ m_selectedTextBlock

TextBlock* CodeEditor::m_selectedTextBlock
private

◆ m_showHiddenBlocks

bool CodeEditor::m_showHiddenBlocks
private

◆ m_tbInfoMap

QMap<TextBlock*, TextBlockInfo*> CodeEditor::m_tbInfoMap
private

◆ m_textBlockList

TextBlockList CodeEditor::m_textBlockList
private

◆ m_textBlockToPaste

TextBlock* CodeEditor::m_textBlockToPaste
private

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