# HG changeset patch # User Jacob Dawid # Date 1302604398 -7200 # Node ID 1e76b221bc4aa2c4b5c26a094d9804cfe1dddd09 # Parent e954cbe099fe758a686d386afc88113089cbfbcc Refactored code edit code, wired undo and redo. diff -r e954cbe099fe -r 1e76b221bc4a gui//src/CodeEdit.h --- a/gui//src/CodeEdit.h Tue Apr 12 12:27:52 2011 +0200 +++ b/gui//src/CodeEdit.h Tue Apr 12 12:33:18 2011 +0200 @@ -36,74 +36,71 @@ }; /**TextEdit that supports highlited syntax and autocompletion.*/ -class CodeEdit: public QTextEdit -{ - Q_OBJECT - - bool auto_indent; - QCompleter completion; - QStringListModel *completion_model; - QTimer braketsTimer, octaveCommandTimer, completionTimer; - QStringList completion_list; - int completionPosition; - - /**Builds auto completion list from block blockInit to blockEnd.*/ - void buildAutoCompletionListSlide(QStringList &list, QTextBlock blockInit, QTextBlock blockEnd, QString word_to_complete, QString actual_word); +class CodeEdit: public QTextEdit { + Q_OBJECT +public: + CodeEdit(QWidget *parent = 0, QString syntaxF = QString()); + ~CodeEdit(); + void setAutoindent(bool ai_ok); + bool getAutoindent(); + bool getbraketsMatchOk(); + + /**List of y top left positions of bounding rects of each visible block of text. + * @param list List of top left positions. + * @param first_line First visible block in TextEdit. + */ + void publicBlockBoundingRectList(QVector &list, int &first_line); - bool text_modified_stop_ok; //Stops emit of text_modified signal - bool context_changed_ok; - - //Editor properties +public slots: + void undo(); + void redo(); + void deleteSelection(); + void toggleBreakpoint(); + void braketsMatch(bool rehigh=true); + void cursorChanged_cb(); + void buildAutoCompletionList(int pos, int charsRemoved, int charsAdded ); + void buildAutoCompletionList(); + void doCompletion(const QModelIndex &index); + void octaveCommandCompletion(); + void textModified_cb(bool ok); - /**Automatic indention for while, if, for, switch, do and try statements.*/ - bool automatic_indention_statement_ok; - /**Auto completion*/ - bool autocompletion_ok; - /**Brackets Macth*/ - bool brakets_match_ok; +signals: + void toggleBreakpoint(int lineno); - protected: - Syntax *syntax; - QMenu contextMenu; - - void contextMenuEvent(QContextMenuEvent *e); - bool event( QEvent * e ); + /**Dinamic help required.*/ + void dynamic_help_required(const QString &text); - public slots: - void undo(); - void redo(); - void deleteSelection(); - void toggleBreakpoint(); - void braketsMatch(bool rehigh=true); - void cursorChanged_cb(); - void buildAutoCompletionList(int pos, int charsRemoved, int charsAdded ); - void buildAutoCompletionList(); - void doCompletion(const QModelIndex &index); - void octaveCommandCompletion(); - void textModified_cb(bool ok); + /**Text modified.*/ + void text_modified(bool ok); - public: - CodeEdit(QWidget *parent = 0, QString syntaxF = QString()); - ~CodeEdit(); - void setAutoindent(bool ai_ok); - bool getAutoindent(); +protected: + Syntax *syntax; + QMenu contextMenu; + + void contextMenuEvent(QContextMenuEvent *e); + bool event( QEvent * e ); - bool getbraketsMatchOk(); - - /**List of y top left positions of bounding rects of each visible block of text. - * @param list List of top left positions. - * @param first_line First visible block in TextEdit. - */ - void publicBlockBoundingRectList(QVector &list, int &first_line); +private: + bool auto_indent; + QCompleter completion; + QStringListModel *completion_model; + QTimer braketsTimer, octaveCommandTimer, completionTimer; + QStringList completion_list; + int completionPosition; + + /**Builds auto completion list from block blockInit to blockEnd.*/ + void buildAutoCompletionListSlide(QStringList &list, QTextBlock blockInit, QTextBlock blockEnd, QString word_to_complete, QString actual_word); - signals: - void toggleBreakpoint(int lineno); + bool text_modified_stop_ok; //Stops emit of text_modified signal + bool context_changed_ok; - /**Dinamic help required.*/ - void dynamic_help_required(const QString &text); + //Editor properties - /**Text modified.*/ - void text_modified(bool ok); + /**Automatic indention for while, if, for, switch, do and try statements.*/ + bool automatic_indention_statement_ok; + /**Auto completion*/ + bool autocompletion_ok; + /**Brackets Macth*/ + bool brakets_match_ok; }; - #endif diff -r e954cbe099fe -r 1e76b221bc4a gui//src/FileEditorMdiSubWindow.cpp --- a/gui//src/FileEditorMdiSubWindow.cpp Tue Apr 12 12:27:52 2011 +0200 +++ b/gui//src/FileEditorMdiSubWindow.cpp Tue Apr 12 12:33:18 2011 +0200 @@ -47,4 +47,7 @@ layout->addWidget(m_statusBar); layout->setMargin(2); widget()->setLayout(layout); + + connect(undoAction, SIGNAL(triggered()), m_codeEdit, SLOT(undo())); + connect(redoAction, SIGNAL(triggered()), m_codeEdit, SLOT(redo())); }