git-svn-id: svn://db.shs.com.ru/libs@341 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -11,12 +11,19 @@ QT_BEGIN_HEADER
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class QCodeEdit;
|
||||
}
|
||||
|
||||
|
||||
class QCodeEdit: public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString text READ text WRITE setText)
|
||||
Q_PROPERTY(bool showSpaces READ showSpaces WRITE setShowSpaces)
|
||||
Q_PROPERTY(bool showLineNumbers READ showLineNumbers WRITE setShowLineNumbers)
|
||||
Q_PROPERTY(QFont editorFont READ editorFont WRITE setEditorFont)
|
||||
|
||||
public:
|
||||
QCodeEdit(QWidget * parent = 0);
|
||||
@@ -28,21 +35,24 @@ public:
|
||||
Namespace
|
||||
};
|
||||
|
||||
QTextCursor textCursor() const {return textCode->textCursor();}
|
||||
QTextDocument * document() const {return textCode->document();}
|
||||
void setTextCursor(const QTextCursor & c) {textCode->setTextCursor(c);}
|
||||
void centerCursor() {textCode->centerCursor(); updateLines();}
|
||||
void insertText(const QString & text) {textCode->insertPlainText(text); updateLines();}
|
||||
void appendText(const QString & text) {textCode->appendPlainText(text); updateLines();}
|
||||
void setCustomExtraSelection(const QList<QTextEdit::ExtraSelection> & es) {es_custom = es; applyExtraSelection();}
|
||||
QRect cursorRect() const {return textCode->cursorRect();}
|
||||
QRect cursorRect(const QTextCursor & cursor) const {return textCode->cursorRect(cursor);}
|
||||
QString text() const {return textCode->toPlainText();}
|
||||
QStringList cursorScope() const {return cursor_scope;}
|
||||
QTextCursor textCursor() const;
|
||||
QTextDocument * document() const;
|
||||
void setTextCursor(const QTextCursor & c);
|
||||
void centerCursor();
|
||||
void insertText(const QString & text);
|
||||
void appendText(const QString & text);
|
||||
void setCustomExtraSelection(const QList<QTextEdit::ExtraSelection> & es);
|
||||
QRect cursorRect() const;
|
||||
QRect cursorRect(const QTextCursor & cursor) const;
|
||||
QString text() const;
|
||||
QStringList cursorScope() const;
|
||||
bool showSpaces() const {return spaces_;}
|
||||
bool showLineNumbers() const {return textLines->isVisible();}
|
||||
bool showLineNumbers() const;
|
||||
|
||||
void setEditorFont(QFont f);
|
||||
QFont editorFont() const;
|
||||
|
||||
QPlainTextEdit * textEdit() const {return textCode;}
|
||||
QPlainTextEdit * textEdit() const;
|
||||
|
||||
void registerAutoCompletitionClass(int id, ACClassType ac_class, const QString & name, const QIcon & icon = QIcon()) {ac_classes[id] = ACClass(id, ac_class, name, icon);}
|
||||
|
||||
@@ -64,6 +74,8 @@ protected:
|
||||
static bool matchWritten(QString s, QString w);
|
||||
static QChar pairChar(QChar c);
|
||||
|
||||
Ui::QCodeEdit * ui;
|
||||
|
||||
private:
|
||||
struct ACClass {
|
||||
ACClass(int i = -2, ACClassType c = QCodeEdit::Keyword, const QString & n = QString(), const QIcon & ic = QIcon()): id(i), class_(c), name(n), icon(ic) {}
|
||||
@@ -73,24 +85,27 @@ private:
|
||||
QIcon icon;
|
||||
};
|
||||
|
||||
QPlainTextEdit * textCode, * textLines;
|
||||
QTreeWidget * completer;
|
||||
IconedLabel * lbl_help[2];
|
||||
QFrame * widget_help;
|
||||
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range;
|
||||
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets;
|
||||
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range, es_search;
|
||||
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets, es_search_list;
|
||||
QMap<int, ACClass> ac_classes;
|
||||
QStringList cursor_scope;
|
||||
int prev_lc, auto_comp_pl, timer;
|
||||
bool spaces_, _ignore_focus_out, _first, _destructor;
|
||||
int prev_lc, auto_comp_pl, timer, cur_search_ind;
|
||||
bool spaces_, _ignore_focus_out, _first, _destructor, _replacing;
|
||||
|
||||
bool eventFilter(QObject * o, QEvent * e);
|
||||
void showEvent(QShowEvent * );
|
||||
void timerEvent(QTimerEvent * );
|
||||
void leaveEvent(QEvent * );
|
||||
void highlightBrackets();
|
||||
void applyExtraSelection();
|
||||
void nextCompletition();
|
||||
void previousCompletition();
|
||||
void clearSearch();
|
||||
void moveToSearch();
|
||||
int searchIndFromCursor();
|
||||
|
||||
private slots:
|
||||
void syncScrolls();
|
||||
@@ -104,17 +119,27 @@ private slots:
|
||||
void autoIndent();
|
||||
void invokeAutoCompletition(bool force = false);
|
||||
void commitCompletition();
|
||||
void searchAll();
|
||||
void search_triggered();
|
||||
void textEdit_cursorPositionChanged();
|
||||
void textEdit_textChanged();
|
||||
void textEdit_selectionChanged();
|
||||
|
||||
void on_comboSearch_currentTextChanged(const QString & t);
|
||||
void on_buttonReplace_clicked();
|
||||
void on_buttonReplaceSearch_clicked();
|
||||
void on_buttonReplaceAll_clicked();
|
||||
|
||||
public slots:
|
||||
void updateLines();
|
||||
void scrollToTop();
|
||||
void setFocus() {textCode->setFocus();}
|
||||
void setText(const QString & t) {textCode->setPlainText(t);}
|
||||
void setFocus();
|
||||
void setText(const QString & t);
|
||||
void setShowSpaces(bool yes);
|
||||
void setShowLineNumbers(bool yes) {textLines->setVisible(yes);}
|
||||
void setShowLineNumbers(bool yes);
|
||||
void search(const QString & t);
|
||||
void searchNext(bool next = true);
|
||||
void searchPrevious();
|
||||
void hideSearch();
|
||||
|
||||
signals:
|
||||
void textChanged();
|
||||
|
||||
Reference in New Issue
Block a user