umbrello  2.38.5
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 ()
 
QMenu * 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::CodeEditor ( const QString &  text,
CodeViewerDialog parent = 0,
CodeDocument doc = 0 
)
explicit

Constructor.

Here is the call graph for this function:

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

Constructor.

Here is the call graph for this function:

CodeEditor::~CodeEditor ( )

Destructor.

Member Function Documentation

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:

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:

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:

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:

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:

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:

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:

void CodeEditor::changeHighlighting ( int  signal)
slot

Colorizes/uncolorizes type for ALL paragraphs.

Here is the call graph for this function:

void CodeEditor::changeShowHidden ( int  signal)
slot

:TODO:

Here is the call graph for this function:

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

:TODO:

Here is the call graph for this function:

void CodeEditor::clearText ( )
private

Clear the display of all text.

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:

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:

QLabel * CodeEditor::componentLabel ( )
private

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

Returns
label widget of dialog
void CodeEditor::contentsMouseMoveEvent ( QMouseEvent *  e)
protected

Override the QT event so we can do appropriate things.

Here is the call graph for this function:

void CodeEditor::contextMenuEvent ( QContextMenuEvent *  event)
protected

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

Here is the call graph for this function:

void CodeEditor::contractSelectedParagraph ( int  paraToRemove)
private

:TODO:

QMenu * CodeEditor::createPopup ( )
protected

Create the popup menu.

Returns
the popup menu

Here is the call graph for this function:

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:

void CodeEditor::expandSelectedParagraph ( int  priorPara)
private

:TODO:

Here is the call graph for this function:

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
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:

void CodeEditor::initText ( CodeDocument doc)
private
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
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:

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.

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:

void CodeEditor::keyPressEvent ( QKeyEvent *  e)
protected

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

void CodeEditor::loadFromDocument ( )
protected

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

Here is the call graph for this function:

void CodeEditor::mouseDoubleClickEvent ( QMouseEvent *  e)
protected

Override the QT event so we can do appropriate things.

Here is the call graph for this function:

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
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:

void CodeEditor::removeParagraph ( int  para)
slot

Remove a paragraph from a given position.

Parameters
parathe position from where to remove the text
void CodeEditor::setParagraphBackgroundColor ( int  position,
const QColor &  color 
)
private

Set the background color at the cursor position.

Parameters
positionthe character position
colorthe desired color
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:

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:

void CodeEditor::slotCopyTextBlock ( )
protectedslot

Slot to copy a text block.

Here is the call graph for this function:

void CodeEditor::slotCursorPositionChanged ( )
protectedslot

Slot for cursor position changed signal.

Here is the call graph for this function:

void CodeEditor::slotCutTextBlock ( )
protectedslot

Slot to cut a text block.

Here is the call graph for this function:

void CodeEditor::slotInsertCodeBlockAfterSelected ( )
protectedslot

Slot to insert a code block after the selection.

Here is the call graph for this function:

void CodeEditor::slotInsertCodeBlockBeforeSelected ( )
protectedslot

Slot to insert a code block before the selection.

Here is the call graph for this function:

void CodeEditor::slotPasteTextBlock ( )
protectedslot

Slot to paste a text block.

Here is the call graph for this function:

void CodeEditor::slotRedrawText ( )
slot

Slot to redraw the text.

Here is the call graph for this function:

Settings::CodeViewerState CodeEditor::state ( )

Return code viewer state.

Returns
state of the code viewer

Here is the call graph for this function:

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:

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

bool CodeEditor::m_backspacePressed
private
bool CodeEditor::m_isHighlighted
private
int CodeEditor::m_lastPara
private
int CodeEditor::m_lastPos
private
TextBlock* CodeEditor::m_lastTextBlockToBeEdited
private
bool CodeEditor::m_newLinePressed
private
CodeViewerDialog* CodeEditor::m_parentDialog
private
CodeDocument* CodeEditor::m_parentDoc
private
QString CodeEditor::m_parentDocName
private
TextBlock* CodeEditor::m_selectedTextBlock
private
bool CodeEditor::m_showHiddenBlocks
private
QMap<TextBlock*, TextBlockInfo*> CodeEditor::m_tbInfoMap
private
TextBlockList CodeEditor::m_textBlockList
private
TextBlock* CodeEditor::m_textBlockToPaste
private

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