codeeditor.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef CODEEDITOR_H
00020 #define CODEEDITOR_H
00021
00022 #include <qpopupmenu.h>
00023 #include <qstring.h>
00024 #include <qlabel.h>
00025 #include <qtextedit.h>
00026 #include "../codeviewerstate.h"
00027 #include "../textblocklist.h"
00028
00029 class UMLObject;
00030
00031 class CodeViewerDialog;
00032 class CodeComment;
00033 class CodeDocument;
00034 class CodeClassFieldDeclarationBlock;
00035 class CodeMethodBlock;
00036 class CodeBlockWithComments;
00037 class HierarchicalCodeBlock;
00038
00039 class TextBlockInfo;
00040 class TextBlock;
00041 class ParaInfo;
00042
00043 class CodeEditor : public QTextEdit
00044 {
00045 Q_OBJECT
00046 public:
00047
00048 explicit CodeEditor ( const QString & text, const QString & context = QString(), CodeViewerDialog * parent = 0, const char * name = 0 , CodeDocument * doc = 0);
00049 explicit CodeEditor ( CodeViewerDialog * parent, const char* name = 0, CodeDocument * doc = 0);
00050 ~CodeEditor ();
00051
00052
00053 Settings::CodeViewerState getState( );
00054
00055 protected:
00056
00057 bool close ( bool alsoDelete );
00058
00059
00060 void appendText (TextBlock * tblock);
00061 void appendText (HierarchicalCodeBlock * hblock);
00062 void appendText (CodeClassFieldDeclarationBlock * db );
00063 void appendText (TextBlockList * items);
00064 void appendText (CodeMethodBlock * mb);
00065 void appendText (CodeComment * comment, TextBlock * parent, UMLObject * umlObj = 0, const QString & compName="");
00066 void appendText (CodeBlockWithComments * cb );
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 void rebuildView( int startCursorPos );
00077
00078
00079 void contentsMouseMoveEvent ( QMouseEvent * e );
00080
00081
00082
00083 void keyPressEvent ( QKeyEvent * e );
00084
00085
00086 void loadFromDocument();
00087
00088
00089 QPopupMenu * createPopupMenu ( const QPoint & pos );
00090
00091 private:
00092
00093 QString parentDocName;
00094 CodeDocument * m_parentDoc;
00095 CodeViewerDialog * m_parentDlg;
00096
00097 int m_lastPara;
00098 int m_lastPos;
00099
00100 bool m_newLinePressed;
00101 bool m_backspacePressed;
00102 bool m_isHighlighted;
00103 bool m_showHiddenBlocks;
00104
00105 TextBlock * m_textBlockToPaste;
00106 TextBlock * m_selectedTextBlock;
00107 TextBlock * m_lastTextBlockToBeEdited;
00108
00109 QMap<TextBlock*, TextBlockInfo*> *m_tbInfoMap;
00110 TextBlockList m_textBlockList;
00111
00112
00113 void insert (const QString & text, TextBlock * parent, bool isEditable = false,
00114 const QColor & fgcolor = QColor("black"), const QColor & bgcolor = QColor("white"),
00115 UMLObject * umlobj = 0, const QString & displayName = "", int startLine = -1);
00116
00117 void editTextBlock(TextBlock * tBlock, int para);
00118 void clearText();
00119 QLabel * getComponentLabel();
00120 bool paraIsNotSingleLine (int para);
00121 void expandSelectedParagraph( int where );
00122 void contractSelectedParagraph( int where );
00123 void updateTextBlockFromText (TextBlock * block);
00124
00125 void initText ( CodeDocument * doc );
00126 void init ( CodeViewerDialog * parentDlg, CodeDocument * parentDoc );
00127
00128 void changeTextBlockHighlighting(TextBlock * tb, bool selected);
00129 bool isParaEditable (int para);
00130 bool textBlockIsClickable(UMLObject * obj);
00131
00132
00133
00134 static bool StringIsBlank( const QString &str );
00135
00136 public slots:
00137
00138 void insertParagraph ( const QString & text, int para );
00139 void removeParagraph ( int para );
00140 void changeHighlighting(int signal);
00141 void changeShowHidden (int signal);
00142 void slotRedrawText();
00143
00144 protected slots:
00145
00146 void clicked(int para, int pos );
00147 void doubleClicked(int para, int pos );
00148 void cursorPositionChanged(int para, int pos );
00149 void slotCopyTextBlock ( );
00150 void slotCutTextBlock ( );
00151 void slotPasteTextBlock ( );
00152 void slotChangeSelectedBlockView();
00153 void slotChangeSelectedBlockCommentView();
00154 void slotInsertCodeBlockAfterSelected();
00155 void slotInsertCodeBlockBeforeSelected();
00156
00157 signals:
00158
00159
00160
00161
00162
00163
00164 };
00165
00166 class ParaInfo {
00167 public:
00168 int start;
00169 int size;
00170 QColor fgcolor;
00171 QColor bgcolor;
00172 bool isEditable;
00173
00174 ParaInfo () { isEditable = false; }
00175 };
00176
00177 class TextBlockInfo {
00178 public:
00179 QPtrList<ParaInfo> m_paraList;
00180 UMLObject * m_parent;
00181 QString displayName;
00182 bool isClickable;
00183 bool isCodeAccessorMethod;
00184
00185 TextBlockInfo () { m_parent = 0; isClickable = false; isCodeAccessorMethod = false; }
00186 void setParent(UMLObject *p = 0) { m_parent = p; }
00187 UMLObject * getParent() { return m_parent; }
00188
00189 };
00190
00191 #endif // CODEEDITOR_H
This file is part of the documentation for umbrello Version 3.1.0.