git-svn-id: svn://db.shs.com.ru/libs@341 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
15
make_android.bat
Normal file
15
make_android.bat
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
set Qt5_ROOT=d:\Qt\5.10.0\android_armv7\lib\cmake\
|
||||||
|
set Qt5_DIR=%Qt5_ROOT%\Qt5
|
||||||
|
set Qt5LinguistTools_DIR=%Qt5_ROOT%\Qt5LinguistTools
|
||||||
|
set Qt5UiPlugin_DIR=%Qt5_ROOT%\Qt5UiPlugin
|
||||||
|
set Qt5Widgets_DIR=%Qt5_ROOT%\Qt5Widgets
|
||||||
|
set Qt5Core_DIR=%Qt5_ROOT%\Qt5Core
|
||||||
|
set Qt5Gui_DIR=%Qt5_ROOT%\Qt5Gui
|
||||||
|
set Qt5Sql_DIR=%Qt5_ROOT%\Qt5Sql
|
||||||
|
set Qt5OpenGL_DIR=%Qt5_ROOT%\Qt5OpenGL
|
||||||
|
set Qt5Designer_DIR=%Qt5_ROOT%\Qt5Designer
|
||||||
|
set Qt5PrintSupport_DIR=%Qt5_ROOT%\Qt5PrintSupport
|
||||||
|
set Qt5Script_DIR=%Qt5_ROOT%\Qt5Script
|
||||||
|
cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=d:\Distrib\Android\android-sdk-windows\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DICU=0 -DQt4=0 -DQt5=1 -DQGLVIEW=0 -DQt5_DIR=%Qt5_ROOT%\Qt5 -DQt5LinguistTools_DIR=%Qt5_ROOT%\Qt5LinguistTools -DQt5UiPlugin_DIR=%Qt5_ROOT%\Qt5UiPlugin -DQt5Widgets_DIR=%Qt5_ROOT%\Qt5Widgets -DQt5Core_DIR=%Qt5_ROOT%\Qt5Core -DQt5Gui_DIR=%Qt5_ROOT%\Qt5Gui -DQt5Sql_DIR=%Qt5_ROOT%\Qt5Sql -DQt5OpenGL_DIR=%Qt5_ROOT%\Qt5OpenGL -DQt5PrintSupport_DIR=%Qt5_ROOT%\Qt5PrintSupport -DQt5Script_DIR=%Qt5_ROOT%\Qt5Script ..\libs
|
||||||
|
|
||||||
|
:cmake_mgw -Wno-dev -DCMAKE_TOOLCHAIN_FILE=d:\Distrib\Android\android-sdk-windows\ndk-bundle\build\cmake\android.toolchain.cmake -DANDROID_PLATFORM=android-24 -DICU=0 -DQt4=0 -DQt5=1 -DQt5_DIR=%Qt5_ROOT%\Qt5 ..\libs
|
||||||
@@ -222,8 +222,13 @@ void Graphic::canvasPaintEvent() {
|
|||||||
gridborder += QPoint(font_sz.width(), font_sz.height());
|
gridborder += QPoint(font_sz.width(), font_sz.height());
|
||||||
if (hasLblY) gridborder += QPoint(font_sz.height(), 0);
|
if (hasLblY) gridborder += QPoint(font_sz.height(), 0);
|
||||||
if (hasLblX) gridborder += QPoint(0, font_sz.height());
|
if (hasLblX) gridborder += QPoint(0, font_sz.height());
|
||||||
drawGrid();
|
|
||||||
}
|
}
|
||||||
|
painter->setClipping(true);
|
||||||
|
painter->setClipRect(QRect(gridborder.x(), 0, wid - gridborder.x(), hei - gridborder.y()));
|
||||||
|
emit beforeGraphicPaintEvent(painter);
|
||||||
|
painter->setClipping(false);
|
||||||
|
if (grid)
|
||||||
|
drawGrid();
|
||||||
p.setRenderHint(QPainter::Antialiasing, aalias);
|
p.setRenderHint(QPainter::Antialiasing, aalias);
|
||||||
if (isOGL) {
|
if (isOGL) {
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
@@ -236,7 +241,7 @@ void Graphic::canvasPaintEvent() {
|
|||||||
drawGraphics();
|
drawGraphics();
|
||||||
drawGuides();
|
drawGuides();
|
||||||
if (pause_) drawPause();
|
if (pause_) drawPause();
|
||||||
emit graphicPaintEvent(&p);
|
emit graphicPaintEvent(painter);
|
||||||
p.end();
|
p.end();
|
||||||
if (isOGL) return;
|
if (isOGL) return;
|
||||||
p.begin(canvas);
|
p.begin(canvas);
|
||||||
|
|||||||
@@ -403,6 +403,7 @@ protected slots:
|
|||||||
void leaveFullscreen();
|
void leaveFullscreen();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
void beforeGraphicPaintEvent(QPainter * );
|
||||||
void graphicPaintEvent(QPainter * );
|
void graphicPaintEvent(QPainter * );
|
||||||
void graphicMouseMoveEvent(QPointF point, int buttons);
|
void graphicMouseMoveEvent(QPointF point, int buttons);
|
||||||
void graphicMousePressEvent(QPointF point, int buttons);
|
void graphicMousePressEvent(QPointF point, int buttons);
|
||||||
|
|||||||
@@ -1,44 +1,46 @@
|
|||||||
<RCC>
|
<RCC>
|
||||||
<qresource prefix="/">
|
<qresource prefix="/">
|
||||||
<file>lang/qad_widgets_ru.ts</file>
|
<file>../icons/go-next.png</file>
|
||||||
<file>../icons/dialog-close.png</file>
|
<file>../icons/go-previous.png</file>
|
||||||
<file>../icons/edit-clear.png</file>
|
<file>lang/qad_widgets_ru.ts</file>
|
||||||
<file>../icons/edit-guides.png</file>
|
<file>../icons/dialog-close.png</file>
|
||||||
<file>../icons/view-grid.png</file>
|
<file>../icons/edit-clear.png</file>
|
||||||
<file>../icons/zoom-fit-best.png</file>
|
<file>../icons/edit-guides.png</file>
|
||||||
<file>../icons/configure.png</file>
|
<file>../icons/view-grid.png</file>
|
||||||
<file>../icons/alpha.png</file>
|
<file>../icons/zoom-fit-best.png</file>
|
||||||
<file>../icons/document-save.png</file>
|
<file>../icons/configure.png</file>
|
||||||
<file>../icons/edit-clear-locationbar-rtl.png</file>
|
<file>../icons/alpha.png</file>
|
||||||
<file>../icons/edit-find.png</file>
|
<file>../icons/document-save.png</file>
|
||||||
<file>../icons/list-add.png</file>
|
<file>../icons/edit-clear-locationbar-rtl.png</file>
|
||||||
<file>../icons/edit-delete.png</file>
|
<file>../icons/edit-find.png</file>
|
||||||
<file>../icons/item-add.png</file>
|
<file>../icons/list-add.png</file>
|
||||||
<file>../icons/item.png</file>
|
<file>../icons/edit-delete.png</file>
|
||||||
<file>../icons/node-add.png</file>
|
<file>../icons/item-add.png</file>
|
||||||
<file>../icons/node.png</file>
|
<file>../icons/item.png</file>
|
||||||
<file>../icons/edit-copy.png</file>
|
<file>../icons/node-add.png</file>
|
||||||
<file>../icons/edit-paste.png</file>
|
<file>../icons/node.png</file>
|
||||||
<file>../icons/expand_s_x.png</file>
|
<file>../icons/edit-copy.png</file>
|
||||||
<file>../icons/expand_s_y.png</file>
|
<file>../icons/edit-paste.png</file>
|
||||||
<file>../icons/expand_x.png</file>
|
<file>../icons/expand_s_x.png</file>
|
||||||
<file>../icons/expand_y.png</file>
|
<file>../icons/expand_s_y.png</file>
|
||||||
<file>../icons/border-line.png</file>
|
<file>../icons/expand_x.png</file>
|
||||||
<file>../icons/legend.png</file>
|
<file>../icons/expand_y.png</file>
|
||||||
<file>../icons/chardialog.png</file>
|
<file>../icons/border-line.png</file>
|
||||||
<file>../icons/clineedit.png</file>
|
<file>../icons/legend.png</file>
|
||||||
<file>../icons/colorbutton.png</file>
|
<file>../icons/chardialog.png</file>
|
||||||
<file>../icons/ecombobox.png</file>
|
<file>../icons/clineedit.png</file>
|
||||||
<file>../icons/qpiconsole.png</file>
|
<file>../icons/colorbutton.png</file>
|
||||||
<file>../icons/spinslider.png</file>
|
<file>../icons/ecombobox.png</file>
|
||||||
<file>../icons/etabwidget.png</file>
|
<file>../icons/qpiconsole.png</file>
|
||||||
<file>../icons/qcodeedit.png</file>
|
<file>../icons/spinslider.png</file>
|
||||||
<file>../icons/qvariantedit.png</file>
|
<file>../icons/etabwidget.png</file>
|
||||||
<file>../icons/code-word.png</file>
|
<file>../icons/qcodeedit.png</file>
|
||||||
<file>../icons/f1.png</file>
|
<file>../icons/qvariantedit.png</file>
|
||||||
<file>../icons/dialog-ok-apply.png</file>
|
<file>../icons/code-word.png</file>
|
||||||
<file>../icons/dialog-warning.png</file>
|
<file>../icons/f1.png</file>
|
||||||
<file>../icons/tools-wizard.png</file>
|
<file>../icons/dialog-ok-apply.png</file>
|
||||||
<file>../icons/evalspinbox.png</file>
|
<file>../icons/dialog-warning.png</file>
|
||||||
</qresource>
|
<file>../icons/tools-wizard.png</file>
|
||||||
|
<file>../icons/evalspinbox.png</file>
|
||||||
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
@@ -10,21 +10,25 @@
|
|||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include "ecombobox.h"
|
||||||
#include "qad_types.h"
|
#include "qad_types.h"
|
||||||
|
#include "ui_qcodeedit.h"
|
||||||
|
|
||||||
|
|
||||||
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
||||||
prev_lc = auto_comp_pl = -1;
|
ui = new Ui::QCodeEdit();
|
||||||
textCode = textLines = 0;
|
ui->setupUi(this);
|
||||||
|
ui->widgetSearch->hide();
|
||||||
|
prev_lc = auto_comp_pl = cur_search_ind = -1;
|
||||||
timer = 0;
|
timer = 0;
|
||||||
_ignore_focus_out = _destructor = false;
|
_ignore_focus_out = _destructor = _replacing = false;
|
||||||
_first = true;
|
_first = true;
|
||||||
es_line.format.setBackground(QColor(240, 245, 240));
|
es_line.format.setBackground(QColor(240, 245, 240));
|
||||||
es_line.format.setProperty(QTextFormat::FullWidthSelection, true);
|
es_line.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
es_cursor.format.setBackground(QColor(220, 255, 200));
|
es_cursor.format.setBackground(QColor(220, 255, 200));
|
||||||
es_bracket.format.setBackground(QColor(180, 238, 180));
|
es_bracket.format.setBackground(QColor(180, 238, 180));
|
||||||
es_bracket.format.setForeground(Qt::red);
|
es_bracket.format.setForeground(Qt::red);
|
||||||
|
es_search.format.setBackground(QColor(255, 240, 10));
|
||||||
es_range.format.setBackground(QColor(230, 246, 255));
|
es_range.format.setBackground(QColor(230, 246, 255));
|
||||||
es_range.format.setProperty(QTextFormat::FullWidthSelection, true);
|
es_range.format.setProperty(QTextFormat::FullWidthSelection, true);
|
||||||
widget_help = new QFrame();
|
widget_help = new QFrame();
|
||||||
@@ -58,60 +62,51 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
|||||||
#endif
|
#endif
|
||||||
(QHeaderView::ResizeToContents);
|
(QHeaderView::ResizeToContents);
|
||||||
completer->header()->setStretchLastSection(true);
|
completer->header()->setStretchLastSection(true);
|
||||||
//completer->setColumnWidth(0, 180);
|
|
||||||
//completer->resize(500, 200);
|
ui->textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1));
|
||||||
textCode = new QPlainTextEdit();
|
ui->textLines->viewport()->setAutoFillBackground(false);
|
||||||
textLines = new QPlainTextEdit();
|
ui->textLines->viewport()->setCursor(Qt::ArrowCursor);
|
||||||
textCode->setFrameShadow(QFrame::Plain);
|
ui->textLines->setFixedWidth(ui->textLines->fontMetrics().width(" "));
|
||||||
textCode->setFrameShape(QFrame::NoFrame);
|
|
||||||
textCode->setLineWrapMode(QPlainTextEdit::NoWrap);
|
|
||||||
textCode->setTabChangesFocus(false);
|
|
||||||
textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1));
|
|
||||||
textLines->setFrameShadow(QFrame::Plain);
|
|
||||||
textLines->setFrameShape(QFrame::NoFrame);
|
|
||||||
textLines->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
||||||
textLines->setFocusPolicy(Qt::NoFocus);
|
|
||||||
textLines->setTextInteractionFlags(Qt::NoTextInteraction);
|
|
||||||
textLines->setLineWrapMode(QPlainTextEdit::NoWrap);
|
|
||||||
textLines->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
textLines->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
textLines->viewport()->setAutoFillBackground(false);
|
|
||||||
textLines->viewport()->setCursor(Qt::ArrowCursor);
|
|
||||||
textLines->setFixedWidth(textLines->fontMetrics().width(" "));
|
|
||||||
setLayout(new QBoxLayout(QBoxLayout::BottomToTop));
|
|
||||||
layout()->setContentsMargins(0, 0, 0, 0);
|
|
||||||
QFrame * frame = new QFrame();
|
|
||||||
frame->setFrameShadow(QFrame::Sunken);
|
|
||||||
frame->setFrameShape(QFrame::StyledPanel);
|
|
||||||
frame->setLayout(new QBoxLayout(QBoxLayout::LeftToRight));
|
|
||||||
frame->layout()->setContentsMargins(0, 0, 0, 0);
|
|
||||||
frame->layout()->setSpacing(0);
|
|
||||||
frame->layout()->addWidget(textLines);
|
|
||||||
frame->layout()->addWidget(textCode);
|
|
||||||
layout()->addWidget(frame);
|
|
||||||
|
|
||||||
QAction * a = new QAction(this);
|
QAction * a = new QAction(this);
|
||||||
a->setShortcut(QKeySequence("Shift+Tab"));
|
a->setShortcut(QKeySequence("Shift+Tab"));
|
||||||
a->setShortcutContext(Qt::WidgetShortcut);
|
a->setShortcutContext(Qt::WidgetShortcut);
|
||||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(deindent()));
|
connect(a, SIGNAL(triggered(bool)), this, SLOT(deindent()));
|
||||||
textCode->addAction(a);
|
ui->textCode->addAction(a);
|
||||||
a = new QAction(this);
|
a = new QAction(this);
|
||||||
a->setShortcut(QKeySequence("Ctrl+D"));
|
a->setShortcut(QKeySequence("Ctrl+D"));
|
||||||
a->setShortcutContext(Qt::WidgetShortcut);
|
a->setShortcutContext(Qt::WidgetShortcut);
|
||||||
connect(a, SIGNAL(triggered(bool)), this, SLOT(deleteLine()));
|
connect(a, SIGNAL(triggered(bool)), this, SLOT(deleteLine()));
|
||||||
textCode->addAction(a);
|
ui->textCode->addAction(a);
|
||||||
frame->setFocusProxy(textCode);
|
ui->frame->setFocusProxy(ui->textCode);
|
||||||
QTextOption to = textLines->document()->defaultTextOption();
|
QTextOption to = ui->textLines->document()->defaultTextOption();
|
||||||
to.setAlignment(Qt::AlignTop | Qt::AlignRight);
|
to.setAlignment(Qt::AlignTop | Qt::AlignRight);
|
||||||
textLines->document()->setDefaultTextOption(to);
|
ui->textLines->document()->setDefaultTextOption(to);
|
||||||
|
/*to = ui->textCode->document()->defaultTextOption();
|
||||||
|
to.setFlags(QTextOption::SuppressColors);
|
||||||
|
ui->textCode->document()->setDefaultTextOption(to);*/
|
||||||
setShowSpaces(true);
|
setShowSpaces(true);
|
||||||
|
|
||||||
|
a = new QAction(this);
|
||||||
|
a->setShortcut(QKeySequence("Ctrl+F"));
|
||||||
|
a->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect(a, SIGNAL(triggered(bool)), this, SLOT(search_triggered()));
|
||||||
|
addAction(a);
|
||||||
|
|
||||||
|
a = new QAction(this);
|
||||||
|
a->setShortcut(QKeySequence("Esc"));
|
||||||
|
a->setShortcutContext(Qt::WidgetWithChildrenShortcut);
|
||||||
|
connect(a, SIGNAL(triggered(bool)), this, SLOT(hideSearch()));
|
||||||
|
addAction(a);
|
||||||
|
|
||||||
connect(completer, SIGNAL(itemDoubleClicked(QTreeWidgetItem * ,int)), this, SLOT(commitCompletition()));
|
connect(completer, SIGNAL(itemDoubleClicked(QTreeWidgetItem * ,int)), this, SLOT(commitCompletition()));
|
||||||
connect(textCode->verticalScrollBar(), SIGNAL(valueChanged(int)), textLines->verticalScrollBar(), SLOT(setValue(int)));
|
connect(ui->textCode->verticalScrollBar(), SIGNAL(valueChanged(int)), ui->textLines->verticalScrollBar(), SLOT(setValue(int)));
|
||||||
connect(textCode, SIGNAL(textChanged()), this, SLOT(updateLines()));
|
connect(ui->textCode, SIGNAL(textChanged()), this, SLOT(textEdit_textChanged()));
|
||||||
connect(textCode, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
|
connect(ui->textCode, SIGNAL(textChanged()), this, SIGNAL(textChanged()));
|
||||||
connect(textCode, SIGNAL(cursorPositionChanged()), this, SLOT(textEdit_cursorPositionChanged()));
|
connect(ui->textCode, SIGNAL(cursorPositionChanged()), this, SLOT(textEdit_cursorPositionChanged()));
|
||||||
connect(textCode, SIGNAL(selectionChanged()), this, SLOT(textEdit_selectionChanged()));
|
connect(ui->textCode, SIGNAL(selectionChanged()), this, SLOT(textEdit_selectionChanged()));
|
||||||
|
connect(ui->comboSearch->lineEdit(), SIGNAL(returnPressed()), this, SLOT(searchNext()));
|
||||||
|
connect(ui->comboReplace->lineEdit(), SIGNAL(returnPressed()), this, SLOT(on_buttonReplaceSearch_clicked()));
|
||||||
updateLines();
|
updateLines();
|
||||||
|
|
||||||
registerAutoCompletitionClass(-1, QCodeEdit::Keyword, "Words", QIcon(":/icons/code-word.png"));
|
registerAutoCompletitionClass(-1, QCodeEdit::Keyword, "Words", QIcon(":/icons/code-word.png"));
|
||||||
@@ -120,12 +115,91 @@ QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
|||||||
|
|
||||||
QCodeEdit::~QCodeEdit() {
|
QCodeEdit::~QCodeEdit() {
|
||||||
_destructor = true;
|
_destructor = true;
|
||||||
delete textCode;
|
|
||||||
delete textLines;
|
|
||||||
delete completer;
|
delete completer;
|
||||||
//for (int i = 0; i < 2; ++i)
|
//for (int i = 0; i < 2; ++i)
|
||||||
// delete lbl_help[i];
|
// delete lbl_help[i];
|
||||||
delete widget_help;
|
delete widget_help;
|
||||||
|
//delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTextCursor QCodeEdit::textCursor() const {
|
||||||
|
return ui->textCode->textCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QTextDocument * QCodeEdit::document() const {
|
||||||
|
return ui->textCode->document();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setTextCursor(const QTextCursor & c) {
|
||||||
|
ui->textCode->setTextCursor(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::centerCursor() {
|
||||||
|
ui->textCode->centerCursor();
|
||||||
|
updateLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::insertText(const QString & text) {
|
||||||
|
ui->textCode->insertPlainText(text);
|
||||||
|
updateLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::appendText(const QString & text) {
|
||||||
|
ui->textCode->appendPlainText(text);
|
||||||
|
updateLines();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setCustomExtraSelection(const QList<QTextEdit::ExtraSelection> & es) {
|
||||||
|
es_custom = es;
|
||||||
|
applyExtraSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRect QCodeEdit::cursorRect() const {
|
||||||
|
return ui->textCode->cursorRect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QRect QCodeEdit::cursorRect(const QTextCursor & cursor) const {
|
||||||
|
return ui->textCode->cursorRect(cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString QCodeEdit::text() const {
|
||||||
|
return ui->textCode->toPlainText();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QStringList QCodeEdit::cursorScope() const {
|
||||||
|
return cursor_scope;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool QCodeEdit::showLineNumbers() const {
|
||||||
|
return ui->textLines->isVisible();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setEditorFont(QFont f) {
|
||||||
|
ui->textCode->setFont(f);
|
||||||
|
ui->textLines->setFont(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QFont QCodeEdit::editorFont() const {
|
||||||
|
return ui->textCode->font();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QPlainTextEdit * QCodeEdit::textEdit() const {
|
||||||
|
return ui->textCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -197,13 +271,13 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
if (_destructor) return QWidget::eventFilter(o, e);
|
if (_destructor) return QWidget::eventFilter(o, e);
|
||||||
if (e->type() == QEvent::Destroy) {
|
if (e->type() == QEvent::Destroy) {
|
||||||
completer->removeEventFilter(this);
|
completer->removeEventFilter(this);
|
||||||
textCode->removeEventFilter(this);
|
ui->textCode->removeEventFilter(this);
|
||||||
textCode->viewport()->removeEventFilter(this);
|
ui->textCode->viewport()->removeEventFilter(this);
|
||||||
textLines->viewport()->removeEventFilter(this);
|
ui->textLines->viewport()->removeEventFilter(this);
|
||||||
return QWidget::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
if (textLines) {
|
if (ui->textLines) {
|
||||||
if (o == textLines->viewport()) {
|
if (o == ui->textLines->viewport()) {
|
||||||
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease ||
|
if (e->type() == QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonRelease ||
|
||||||
e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonDblClick) {
|
e->type() == QEvent::MouseMove || e->type() == QEvent::MouseButtonDblClick) {
|
||||||
#if (QT_VERSION < 0x050000)
|
#if (QT_VERSION < 0x050000)
|
||||||
@@ -211,11 +285,11 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
#else
|
#else
|
||||||
const_cast<QPointF&>(((QMouseEvent*)e)->localPos()) = QPointF(0, ((QMouseEvent*)e)->localPos().y());
|
const_cast<QPointF&>(((QMouseEvent*)e)->localPos()) = QPointF(0, ((QMouseEvent*)e)->localPos().y());
|
||||||
#endif
|
#endif
|
||||||
QApplication::sendEvent(textCode->viewport(), e);
|
QApplication::sendEvent(ui->textCode->viewport(), e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (e->type() == QEvent::Wheel) {
|
if (e->type() == QEvent::Wheel) {
|
||||||
QApplication::sendEvent(textCode->viewport(), e);
|
QApplication::sendEvent(ui->textCode->viewport(), e);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,20 +301,20 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
//qDebug() << e;
|
//qDebug() << e;
|
||||||
return QWidget::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
if (textCode) {
|
if (ui->textCode) {
|
||||||
if (o == textCode->viewport()) {
|
if (o == ui->textCode->viewport()) {
|
||||||
if (e->type() == QEvent::MouseButtonPress) {
|
if (e->type() == QEvent::MouseButtonPress) {
|
||||||
completer->hide();
|
completer->hide();
|
||||||
hideHelp();
|
hideHelp();
|
||||||
}
|
}
|
||||||
if (e->type() == QEvent::ToolTip) {
|
if (e->type() == QEvent::ToolTip) {
|
||||||
QTextCursor tc = textCode->cursorForPosition(((QHelpEvent*)e)->pos());
|
QTextCursor tc = ui->textCode->cursorForPosition(((QHelpEvent*)e)->pos());
|
||||||
tc.select(QTextCursor::WordUnderCursor);
|
tc.select(QTextCursor::WordUnderCursor);
|
||||||
raiseHelp(tc);
|
raiseHelp(tc);
|
||||||
}
|
}
|
||||||
return QWidget::eventFilter(o, e);
|
return QWidget::eventFilter(o, e);
|
||||||
}
|
}
|
||||||
if (o == textCode) {
|
if (o == ui->textCode) {
|
||||||
//qDebug() << o << e;
|
//qDebug() << o << e;
|
||||||
QMetaObject::invokeMethod(this, "syncScrolls", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "syncScrolls", Qt::QueuedConnection);
|
||||||
QKeyEvent * ke;
|
QKeyEvent * ke;
|
||||||
@@ -313,11 +387,11 @@ bool QCodeEdit::eventFilter(QObject * o, QEvent * e) {
|
|||||||
completer->hide();
|
completer->hide();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (textCode->textCursor().selectedText().isEmpty())
|
if (ui->textCode->textCursor().selectedText().isEmpty())
|
||||||
QMetaObject::invokeMethod(this, "autoIndent", Qt::QueuedConnection);
|
QMetaObject::invokeMethod(this, "autoIndent", Qt::QueuedConnection);
|
||||||
break;
|
break;
|
||||||
case Qt::Key_Tab:
|
case Qt::Key_Tab:
|
||||||
if (!textCode->textCursor().selectedText().isEmpty()) {
|
if (!ui->textCode->textCursor().selectedText().isEmpty()) {
|
||||||
if (ke->modifiers().testFlag(Qt::ShiftModifier))
|
if (ke->modifiers().testFlag(Qt::ShiftModifier))
|
||||||
deindent();
|
deindent();
|
||||||
else
|
else
|
||||||
@@ -366,9 +440,9 @@ void QCodeEdit::showEvent(QShowEvent * ) {
|
|||||||
if (!_first) return;
|
if (!_first) return;
|
||||||
_first = false;
|
_first = false;
|
||||||
completer->installEventFilter(this);
|
completer->installEventFilter(this);
|
||||||
textCode->installEventFilter(this);
|
ui->textCode->installEventFilter(this);
|
||||||
textCode->viewport()->installEventFilter(this);
|
ui->textCode->viewport()->installEventFilter(this);
|
||||||
textLines->viewport()->installEventFilter(this);
|
ui->textLines->viewport()->installEventFilter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -380,6 +454,12 @@ void QCodeEdit::timerEvent(QTimerEvent * ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::leaveEvent(QEvent * e) {
|
||||||
|
hideHelp();
|
||||||
|
QWidget::leaveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char antiBracket(char c) {
|
char antiBracket(char c) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '(': return ')';
|
case '(': return ')';
|
||||||
@@ -397,7 +477,7 @@ char antiBracket(char c) {
|
|||||||
|
|
||||||
void QCodeEdit::highlightBrackets() {
|
void QCodeEdit::highlightBrackets() {
|
||||||
es_brackets.clear();
|
es_brackets.clear();
|
||||||
QTextCursor stc = textCode->textCursor(), tc;
|
QTextCursor stc = ui->textCode->textCursor(), tc;
|
||||||
QTextEdit::ExtraSelection es;
|
QTextEdit::ExtraSelection es;
|
||||||
stc.setPosition(stc.position());
|
stc.setPosition(stc.position());
|
||||||
QTextCursor::MoveOperation mop[2] = {QTextCursor::Left, QTextCursor::Right};
|
QTextCursor::MoveOperation mop[2] = {QTextCursor::Left, QTextCursor::Right};
|
||||||
@@ -436,7 +516,8 @@ void QCodeEdit::highlightBrackets() {
|
|||||||
|
|
||||||
|
|
||||||
void QCodeEdit::applyExtraSelection() {
|
void QCodeEdit::applyExtraSelection() {
|
||||||
textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected << es_custom << es_brackets << es_cursor);
|
ui->textCode->setExtraSelections(QList<QTextEdit::ExtraSelection>() << es_line << es_selected
|
||||||
|
<< es_custom << es_brackets << es_search_list << es_cursor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -464,13 +545,72 @@ void QCodeEdit::previousCompletition() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::clearSearch() {
|
||||||
|
es_search_list.clear();
|
||||||
|
applyExtraSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::moveToSearch() {
|
||||||
|
if (es_search_list.isEmpty()) return;
|
||||||
|
if (cur_search_ind < 0) cur_search_ind += es_search_list.size();
|
||||||
|
if (cur_search_ind >= es_search_list.size()) cur_search_ind = 0;
|
||||||
|
if (cur_search_ind < 0 || cur_search_ind >= es_search_list.size()) return;
|
||||||
|
ui->textCode->setTextCursor(es_search_list[cur_search_ind].cursor);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int QCodeEdit::searchIndFromCursor() {
|
||||||
|
if (es_search_list.isEmpty()) return -1;
|
||||||
|
int ci = ui->textCode->textCursor().anchor();
|
||||||
|
for (int i = 0; i < es_search_list.size(); ++i)
|
||||||
|
if (es_search_list[i].cursor.anchor() > ci)
|
||||||
|
return i - 1;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::searchAll() {
|
||||||
|
QString st = ui->comboSearch->currentText();
|
||||||
|
es_search_list.clear();
|
||||||
|
if (!st.isEmpty() && !ui->widgetSearch->isHidden()) {
|
||||||
|
QTextDocument::FindFlags ff = 0;
|
||||||
|
if (ui->buttonSearchCase->isChecked()) ff |= QTextDocument::FindCaseSensitively;
|
||||||
|
if (ui->buttonSearchWord->isChecked()) ff |= QTextDocument::FindWholeWords;
|
||||||
|
QTextCursor tc(ui->textCode->document()->begin());
|
||||||
|
QTextEdit::ExtraSelection es = es_search;
|
||||||
|
while (true) {
|
||||||
|
tc = ui->textCode->document()->find(st, tc, ff);
|
||||||
|
if (tc.isNull()) break;
|
||||||
|
es.cursor = tc;
|
||||||
|
es_search_list << es;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
applyExtraSelection();
|
||||||
|
QString ss;
|
||||||
|
if (es_search_list.isEmpty())
|
||||||
|
ss = "color: rgb(180, 0, 0);";
|
||||||
|
ui->comboSearch->lineEdit()->setStyleSheet(ss);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::search_triggered() {
|
||||||
|
QString st = ui->textCode->textCursor().selectedText();
|
||||||
|
search(st);
|
||||||
|
//QMetaObject::invokeMethod(ui->comboSearch->lineEdit(), "returnPressed");
|
||||||
|
if (ui->comboSearch->findText(st) < 0)
|
||||||
|
ui->comboSearch->insertItem(0, st);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::syncScrolls() {
|
void QCodeEdit::syncScrolls() {
|
||||||
textLines->verticalScrollBar()->setValue(textCode->verticalScrollBar()->value());
|
ui->textLines->verticalScrollBar()->setValue(ui->textCode->verticalScrollBar()->value());
|
||||||
|
hideHelp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::deleteLine() {
|
void QCodeEdit::deleteLine() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
tc.movePosition(QTextCursor::EndOfLine);
|
tc.movePosition(QTextCursor::EndOfLine);
|
||||||
tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
tc.movePosition(QTextCursor::StartOfLine, QTextCursor::KeepAnchor);
|
||||||
bool md = true;
|
bool md = true;
|
||||||
@@ -483,12 +623,12 @@ void QCodeEdit::deleteLine() {
|
|||||||
tc.removeSelectedText();
|
tc.removeSelectedText();
|
||||||
tc.movePosition(QTextCursor::StartOfLine);
|
tc.movePosition(QTextCursor::StartOfLine);
|
||||||
if (md) tc.movePosition(QTextCursor::Down);
|
if (md) tc.movePosition(QTextCursor::Down);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::copyLineUp() {
|
void QCodeEdit::copyLineUp() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -510,12 +650,12 @@ void QCodeEdit::copyLineUp() {
|
|||||||
tc.setPosition(ss_);
|
tc.setPosition(ss_);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
tc.endEditBlock();
|
tc.endEditBlock();
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::copyLineDown() {
|
void QCodeEdit::copyLineDown() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -540,12 +680,12 @@ void QCodeEdit::copyLineDown() {
|
|||||||
tc.setPosition(ss_);
|
tc.setPosition(ss_);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
tc.endEditBlock();
|
tc.endEditBlock();
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::moveLineUp() {
|
void QCodeEdit::moveLineUp() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -578,12 +718,12 @@ void QCodeEdit::moveLineUp() {
|
|||||||
tc.setPosition(ss_);
|
tc.setPosition(ss_);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
tc.endEditBlock();
|
tc.endEditBlock();
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::moveLineDown() {
|
void QCodeEdit::moveLineDown() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -616,12 +756,12 @@ void QCodeEdit::moveLineDown() {
|
|||||||
tc.setPosition(ss_);
|
tc.setPosition(ss_);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
tc.endEditBlock();
|
tc.endEditBlock();
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::indent() {
|
void QCodeEdit::indent() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -640,12 +780,12 @@ void QCodeEdit::indent() {
|
|||||||
}
|
}
|
||||||
tc.setPosition(ss_ + 1);
|
tc.setPosition(ss_ + 1);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::deindent() {
|
void QCodeEdit::deindent() {
|
||||||
QTextCursor tc = textCode->textCursor();
|
QTextCursor tc = ui->textCode->textCursor();
|
||||||
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
int ss = tc.selectionStart(), ss_ = ss, se = tc.selectionEnd(), se_ = se;
|
||||||
QString st_ = tc.selection().toPlainText();
|
QString st_ = tc.selection().toPlainText();
|
||||||
if (st_.endsWith("\n")) {
|
if (st_.endsWith("\n")) {
|
||||||
@@ -684,12 +824,12 @@ void QCodeEdit::deindent() {
|
|||||||
}
|
}
|
||||||
tc.setPosition(ss_);
|
tc.setPosition(ss_);
|
||||||
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
tc.setPosition(se_, QTextCursor::KeepAnchor);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::autoIndent() {
|
void QCodeEdit::autoIndent() {
|
||||||
QTextCursor tc = textCode->textCursor(), stc = tc;
|
QTextCursor tc = ui->textCode->textCursor(), stc = tc;
|
||||||
tc.movePosition(QTextCursor::StartOfLine);
|
tc.movePosition(QTextCursor::StartOfLine);
|
||||||
if (!tc.movePosition(QTextCursor::Up)) return;
|
if (!tc.movePosition(QTextCursor::Up)) return;
|
||||||
tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
|
tc.movePosition(QTextCursor::Down, QTextCursor::KeepAnchor);
|
||||||
@@ -706,30 +846,40 @@ void QCodeEdit::autoIndent() {
|
|||||||
tabs.append(QString("\t").repeated(nt));
|
tabs.append(QString("\t").repeated(nt));
|
||||||
if (tabs.isEmpty()) return;
|
if (tabs.isEmpty()) return;
|
||||||
stc.insertText(tabs);
|
stc.insertText(tabs);
|
||||||
textCode->setTextCursor(stc);
|
ui->textCode->setTextCursor(stc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::scrollToTop() {
|
void QCodeEdit::scrollToTop() {
|
||||||
prev_lc = -1;
|
prev_lc = -1;
|
||||||
updateLines();
|
updateLines();
|
||||||
textCode->verticalScrollBar()->setValue(0);
|
ui->textCode->verticalScrollBar()->setValue(0);
|
||||||
textLines->verticalScrollBar()->setValue(0);
|
ui->textLines->verticalScrollBar()->setValue(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setFocus() {
|
||||||
|
ui->textCode->setFocus();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setText(const QString & t) {
|
||||||
|
ui->textCode->setPlainText(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::updateLines() {
|
void QCodeEdit::updateLines() {
|
||||||
if (timer > 0) killTimer(timer);
|
if (timer > 0) killTimer(timer);
|
||||||
timer = startTimer(500);
|
timer = startTimer(500);
|
||||||
textCode->setTabStopWidth(textCode->fontMetrics().width(" "));
|
ui->textCode->setTabStopWidth(ui->textCode->fontMetrics().width(" "));
|
||||||
int lc = textCode->document()->lineCount();
|
int lc = ui->textCode->document()->lineCount();
|
||||||
if (prev_lc == lc) return;
|
if (prev_lc == lc) return;
|
||||||
prev_lc = lc;
|
prev_lc = lc;
|
||||||
textLines->setFixedWidth(textLines->fontMetrics().width(QString(" %1").arg(lc)));
|
ui->textLines->setFixedWidth(ui->textLines->fontMetrics().width(QString(" %1").arg(lc)));
|
||||||
textLines->clear();
|
ui->textLines->clear();
|
||||||
for (int i = 1; i <= lc; ++i)
|
for (int i = 1; i <= lc; ++i)
|
||||||
textLines->appendPlainText(QString("%1").arg(i));
|
ui->textLines->appendPlainText(QString("%1").arg(i));
|
||||||
textLines->verticalScrollBar()->setValue(textCode->verticalScrollBar()->value());
|
ui->textLines->verticalScrollBar()->setValue(ui->textCode->verticalScrollBar()->value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -799,13 +949,13 @@ void QCodeEdit::raiseHelp(QTextCursor tc, int arg) {
|
|||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
widget_help->resize(widget_help->sizeHint());
|
widget_help->resize(widget_help->sizeHint());
|
||||||
qApp->processEvents();
|
qApp->processEvents();
|
||||||
QRect whr = textCode->cursorRect(tc);
|
QRect whr = ui->textCode->cursorRect(tc);
|
||||||
whr.setWidth(textCode->fontMetrics().width(st));
|
whr.setWidth(ui->textCode->fontMetrics().width(st));
|
||||||
QPoint whp;
|
QPoint whp;
|
||||||
whp.setX(whr.left() - whr.width() - (widget_help->width() - whr.width()) / 2);
|
whp.setX(whr.left() - whr.width() - (widget_help->width() - whr.width()) / 2);
|
||||||
whp.setY(whr.top() - widget_help->height() - (fontHeight() / 3));
|
whp.setY(whr.top() - widget_help->height() - (fontHeight() / 3));
|
||||||
//qDebug() << whr << whp << widget_help->width() << ", " << st;
|
//qDebug() << whr << whp << widget_help->width() << ", " << st;
|
||||||
widget_help->move(textCode->viewport()->mapToGlobal(whp));
|
widget_help->move(ui->textCode->viewport()->mapToGlobal(whp));
|
||||||
widget_help->show();
|
widget_help->show();
|
||||||
widget_help->raise();
|
widget_help->raise();
|
||||||
cursor_scope = scope.first;
|
cursor_scope = scope.first;
|
||||||
@@ -823,7 +973,7 @@ void QCodeEdit::hideHelp() {
|
|||||||
|
|
||||||
|
|
||||||
QTextCursor QCodeEdit::functionStart(QTextCursor tc, int * arg) {
|
QTextCursor QCodeEdit::functionStart(QTextCursor tc, int * arg) {
|
||||||
QString doc = textCode->toPlainText();
|
QString doc = ui->textCode->toPlainText();
|
||||||
int bcnt = 0, a = 0, i = -1;
|
int bcnt = 0, a = 0, i = -1;
|
||||||
for (i = tc.position() - 1; i >= 0; --i) {
|
for (i = tc.position() - 1; i >= 0; --i) {
|
||||||
if (doc[i] == ')') bcnt++;
|
if (doc[i] == ')') bcnt++;
|
||||||
@@ -838,7 +988,7 @@ QTextCursor QCodeEdit::functionStart(QTextCursor tc, int * arg) {
|
|||||||
}
|
}
|
||||||
if (i < 0) return QTextCursor();
|
if (i < 0) return QTextCursor();
|
||||||
if (arg) *arg = a;
|
if (arg) *arg = a;
|
||||||
QTextCursor ret(textCode->document());
|
QTextCursor ret(ui->textCode->document());
|
||||||
ret.setPosition(i);
|
ret.setPosition(i);
|
||||||
//qDebug() << "found" << i << a;
|
//qDebug() << "found" << i << a;
|
||||||
return ret;
|
return ret;
|
||||||
@@ -848,11 +998,11 @@ QTextCursor QCodeEdit::functionStart(QTextCursor tc, int * arg) {
|
|||||||
QCodeEdit::ACList QCodeEdit::wordsCompletitionList(const QString & written) const {
|
QCodeEdit::ACList QCodeEdit::wordsCompletitionList(const QString & written) const {
|
||||||
QCodeEdit::ACList ret;
|
QCodeEdit::ACList ret;
|
||||||
if (!written.isEmpty()) {
|
if (!written.isEmpty()) {
|
||||||
QTextCursor tc = QTextCursor(textCode->document()->begin()), stc;
|
QTextCursor tc = QTextCursor(ui->textCode->document()->begin()), stc;
|
||||||
QStringList acwl;
|
QStringList acwl;
|
||||||
tc = QTextCursor(textCode->document()->begin());
|
tc = QTextCursor(ui->textCode->document()->begin());
|
||||||
while (true) {
|
while (true) {
|
||||||
tc = textCode->document()->find(written, tc);
|
tc = ui->textCode->document()->find(written, tc);
|
||||||
if (tc.isNull()) break;
|
if (tc.isNull()) break;
|
||||||
stc = tc;
|
stc = tc;
|
||||||
stc.movePosition(QTextCursor::Left);
|
stc.movePosition(QTextCursor::Left);
|
||||||
@@ -888,7 +1038,7 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QString doc = textCode->toPlainText();
|
QString doc = ui->textCode->toPlainText();
|
||||||
auto_comp_pl = line;
|
auto_comp_pl = line;
|
||||||
completer->clear();
|
completer->clear();
|
||||||
int spos = tc.position(), cpos = spos;
|
int spos = tc.position(), cpos = spos;
|
||||||
@@ -928,13 +1078,13 @@ QPair<QStringList, QString> QCodeEdit::getScope(QTextCursor tc, bool * ok) {
|
|||||||
|
|
||||||
void QCodeEdit::invokeAutoCompletition(bool force) {
|
void QCodeEdit::invokeAutoCompletition(bool force) {
|
||||||
int arg = -1;
|
int arg = -1;
|
||||||
QTextCursor htc = functionStart(textCode->textCursor(), &arg);
|
QTextCursor htc = functionStart(ui->textCode->textCursor(), &arg);
|
||||||
if (!htc.isNull()) {
|
if (!htc.isNull()) {
|
||||||
//qDebug() << "raise";
|
//qDebug() << "raise";
|
||||||
raiseHelp(htc, arg);
|
raiseHelp(htc, arg);
|
||||||
}
|
}
|
||||||
bool ok;
|
bool ok;
|
||||||
QPair<QStringList, QString> scope = getScope(textCode->textCursor(), &ok);
|
QPair<QStringList, QString> scope = getScope(ui->textCode->textCursor(), &ok);
|
||||||
if (!ok) return;
|
if (!ok) return;
|
||||||
ACList acl(autoCompletitionList(scope.first, scope.second));
|
ACList acl(autoCompletitionList(scope.first, scope.second));
|
||||||
//qDebug() << written << scope << acl.size();
|
//qDebug() << written << scope << acl.size();
|
||||||
@@ -969,7 +1119,7 @@ void QCodeEdit::invokeAutoCompletition(bool force) {
|
|||||||
if (completer->topLevelItemCount() > 1)
|
if (completer->topLevelItemCount() > 1)
|
||||||
completer->setCurrentItem(completer->topLevelItem(1));
|
completer->setCurrentItem(completer->topLevelItem(1));
|
||||||
if (completer->isHidden())
|
if (completer->isHidden())
|
||||||
completer->move(textCode->mapToGlobal(textCode->cursorRect().bottomRight()));
|
completer->move(ui->textCode->mapToGlobal(ui->textCode->cursorRect().bottomRight()));
|
||||||
if (completer->topLevelItemCount() > 0) {
|
if (completer->topLevelItemCount() > 0) {
|
||||||
completer->setVisible(true);
|
completer->setVisible(true);
|
||||||
//qApp->processEvents();
|
//qApp->processEvents();
|
||||||
@@ -986,7 +1136,7 @@ void QCodeEdit::commitCompletition() {
|
|||||||
if (completer->currentItem() == 0) return;
|
if (completer->currentItem() == 0) return;
|
||||||
if (!completer->currentItem()->flags().testFlag(Qt::ItemIsSelectable)) return;
|
if (!completer->currentItem()->flags().testFlag(Qt::ItemIsSelectable)) return;
|
||||||
QString ins = completer->currentItem()->text(1), ret = completer->currentItem()->text(0);
|
QString ins = completer->currentItem()->text(1), ret = completer->currentItem()->text(0);
|
||||||
QTextCursor tc = textCode->textCursor(), stc = tc;
|
QTextCursor tc = ui->textCode->textCursor(), stc = tc;
|
||||||
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||||
bool ins_br = true, shifted = false;
|
bool ins_br = true, shifted = false;
|
||||||
if (!tc.selectedText().isEmpty()) {
|
if (!tc.selectedText().isEmpty()) {
|
||||||
@@ -1014,29 +1164,29 @@ void QCodeEdit::commitCompletition() {
|
|||||||
if (shifted)
|
if (shifted)
|
||||||
tc.movePosition(QTextCursor::Right);
|
tc.movePosition(QTextCursor::Right);
|
||||||
}
|
}
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
textCode->textCursor().insertText(ins);
|
ui->textCode->textCursor().insertText(ins);
|
||||||
tc = textCode->textCursor();
|
tc = ui->textCode->textCursor();
|
||||||
if (ins_br) {
|
if (ins_br) {
|
||||||
if (ret == "void") {
|
if (ret == "void") {
|
||||||
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||||
if (tc.selectedText() != ";") {
|
if (tc.selectedText() != ";") {
|
||||||
textCode->textCursor().insertText(";");
|
ui->textCode->textCursor().insertText(";");
|
||||||
tc.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 2);
|
tc.movePosition(QTextCursor::Left, QTextCursor::MoveAnchor, 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ins.endsWith(")") && !completer->currentItem()->text(1).endsWith("()")) {
|
if (ins.endsWith(")") && !completer->currentItem()->text(1).endsWith("()")) {
|
||||||
tc.movePosition(QTextCursor::Left);
|
tc.movePosition(QTextCursor::Left);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (completer->currentItem()->text(1).endsWith(")")) {
|
if (completer->currentItem()->text(1).endsWith(")")) {
|
||||||
tc.movePosition(QTextCursor::Right);
|
tc.movePosition(QTextCursor::Right);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
if (completer->currentItem()->text(1).endsWith("()")) {
|
if (completer->currentItem()->text(1).endsWith("()")) {
|
||||||
tc.movePosition(QTextCursor::Right);
|
tc.movePosition(QTextCursor::Right);
|
||||||
textCode->setTextCursor(tc);
|
ui->textCode->setTextCursor(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
completer->hide();
|
completer->hide();
|
||||||
@@ -1044,7 +1194,7 @@ void QCodeEdit::commitCompletition() {
|
|||||||
|
|
||||||
|
|
||||||
void QCodeEdit::textEdit_cursorPositionChanged() {
|
void QCodeEdit::textEdit_cursorPositionChanged() {
|
||||||
es_line.cursor = textCode->textCursor();
|
es_line.cursor = ui->textCode->textCursor();
|
||||||
es_line.cursor.select(QTextCursor::LineUnderCursor);
|
es_line.cursor.select(QTextCursor::LineUnderCursor);
|
||||||
es_line.cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
es_line.cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
|
||||||
highlightBrackets();
|
highlightBrackets();
|
||||||
@@ -1053,22 +1203,24 @@ void QCodeEdit::textEdit_cursorPositionChanged() {
|
|||||||
|
|
||||||
|
|
||||||
void QCodeEdit::textEdit_textChanged() {
|
void QCodeEdit::textEdit_textChanged() {
|
||||||
|
if (_replacing) return;
|
||||||
|
searchAll();
|
||||||
updateLines();
|
updateLines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QCodeEdit::textEdit_selectionChanged() {
|
void QCodeEdit::textEdit_selectionChanged() {
|
||||||
es_selected.clear();
|
es_selected.clear();
|
||||||
QString sf = textCode->textCursor().selectedText();
|
QString sf = ui->textCode->textCursor().selectedText();
|
||||||
if (sf.trimmed().isEmpty() || sf.contains("\n")) {
|
if (sf.trimmed().isEmpty() || sf.contains("\n")) {
|
||||||
applyExtraSelection();
|
applyExtraSelection();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QTextCursor tc(textCode->document()->begin());
|
QTextCursor tc(ui->textCode->document()->begin());
|
||||||
QTextEdit::ExtraSelection es;
|
QTextEdit::ExtraSelection es;
|
||||||
es.format.setBackground(QColor(251, 250, 150));
|
es.format.setBackground(QColor(251, 250, 150));
|
||||||
while (true) {
|
while (true) {
|
||||||
tc = textCode->document()->find(sf, tc, QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords);
|
tc = ui->textCode->document()->find(sf, tc, QTextDocument::FindCaseSensitively | QTextDocument::FindWholeWords);
|
||||||
if (tc.isNull()) break;
|
if (tc.isNull()) break;
|
||||||
es.cursor = tc;
|
es.cursor = tc;
|
||||||
es_selected << es;
|
es_selected << es;
|
||||||
@@ -1079,7 +1231,77 @@ void QCodeEdit::textEdit_selectionChanged() {
|
|||||||
|
|
||||||
void QCodeEdit::setShowSpaces(bool yes) {
|
void QCodeEdit::setShowSpaces(bool yes) {
|
||||||
spaces_ = yes;
|
spaces_ = yes;
|
||||||
QTextOption to = textCode->document()->defaultTextOption();
|
QTextOption to = ui->textCode->document()->defaultTextOption();
|
||||||
to.setFlags(yes ? QTextOption::ShowTabsAndSpaces : (QTextOption::Flags)0);
|
QTextOption::Flags tof = to.flags();
|
||||||
textCode->document()->setDefaultTextOption(to);
|
if (yes) tof |= QTextOption::ShowTabsAndSpaces;
|
||||||
|
else tof &= ~QTextOption::ShowTabsAndSpaces;
|
||||||
|
to.setFlags(tof);
|
||||||
|
ui->textCode->document()->setDefaultTextOption(to);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::setShowLineNumbers(bool yes) {
|
||||||
|
ui->textLines->setVisible(yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::search(const QString & t) {
|
||||||
|
ui->widgetSearch->show();
|
||||||
|
ui->comboSearch->setEditText(QString());
|
||||||
|
ui->comboSearch->setEditText(t);
|
||||||
|
ui->comboSearch->setFocus();
|
||||||
|
//searchAll();
|
||||||
|
searchNext(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::searchNext(bool next) {
|
||||||
|
if (es_search_list.isEmpty())
|
||||||
|
return;
|
||||||
|
cur_search_ind = searchIndFromCursor() + (next ? 1 : 0);
|
||||||
|
moveToSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::searchPrevious() {
|
||||||
|
if (es_search_list.isEmpty())
|
||||||
|
return;
|
||||||
|
cur_search_ind = searchIndFromCursor() - 1;
|
||||||
|
moveToSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::hideSearch() {
|
||||||
|
ui->widgetSearch->hide();
|
||||||
|
searchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::on_comboSearch_currentTextChanged(const QString & t) {
|
||||||
|
searchAll();
|
||||||
|
searchNext(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::on_buttonReplace_clicked() {
|
||||||
|
if (es_search_list.isEmpty() || cur_search_ind < 0 || cur_search_ind >= es_search_list.size()) return;
|
||||||
|
if (ui->textCode->textCursor() != es_search_list[cur_search_ind].cursor) return;
|
||||||
|
if (ui->textCode->textCursor().selectedText().size() != es_search_list[cur_search_ind].cursor.selectedText().size()) return;
|
||||||
|
ui->textCode->textCursor().insertText(ui->comboReplace->currentText());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::on_buttonReplaceSearch_clicked() {
|
||||||
|
on_buttonReplace_clicked();
|
||||||
|
searchNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void QCodeEdit::on_buttonReplaceAll_clicked() {
|
||||||
|
_replacing = true;
|
||||||
|
QString rt = ui->comboReplace->currentText();
|
||||||
|
for (int i = es_search_list.size() - 1; i >= 0; --i)
|
||||||
|
es_search_list[i].cursor.insertText(rt);
|
||||||
|
_replacing = false;
|
||||||
|
textEdit_textChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,19 @@ QT_BEGIN_HEADER
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class QCodeEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class QCodeEdit: public QWidget
|
class QCodeEdit: public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(QString text READ text WRITE setText)
|
Q_PROPERTY(QString text READ text WRITE setText)
|
||||||
Q_PROPERTY(bool showSpaces READ showSpaces WRITE setShowSpaces)
|
Q_PROPERTY(bool showSpaces READ showSpaces WRITE setShowSpaces)
|
||||||
Q_PROPERTY(bool showLineNumbers READ showLineNumbers WRITE setShowLineNumbers)
|
Q_PROPERTY(bool showLineNumbers READ showLineNumbers WRITE setShowLineNumbers)
|
||||||
|
Q_PROPERTY(QFont editorFont READ editorFont WRITE setEditorFont)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QCodeEdit(QWidget * parent = 0);
|
QCodeEdit(QWidget * parent = 0);
|
||||||
@@ -28,21 +35,24 @@ public:
|
|||||||
Namespace
|
Namespace
|
||||||
};
|
};
|
||||||
|
|
||||||
QTextCursor textCursor() const {return textCode->textCursor();}
|
QTextCursor textCursor() const;
|
||||||
QTextDocument * document() const {return textCode->document();}
|
QTextDocument * document() const;
|
||||||
void setTextCursor(const QTextCursor & c) {textCode->setTextCursor(c);}
|
void setTextCursor(const QTextCursor & c);
|
||||||
void centerCursor() {textCode->centerCursor(); updateLines();}
|
void centerCursor();
|
||||||
void insertText(const QString & text) {textCode->insertPlainText(text); updateLines();}
|
void insertText(const QString & text);
|
||||||
void appendText(const QString & text) {textCode->appendPlainText(text); updateLines();}
|
void appendText(const QString & text);
|
||||||
void setCustomExtraSelection(const QList<QTextEdit::ExtraSelection> & es) {es_custom = es; applyExtraSelection();}
|
void setCustomExtraSelection(const QList<QTextEdit::ExtraSelection> & es);
|
||||||
QRect cursorRect() const {return textCode->cursorRect();}
|
QRect cursorRect() const;
|
||||||
QRect cursorRect(const QTextCursor & cursor) const {return textCode->cursorRect(cursor);}
|
QRect cursorRect(const QTextCursor & cursor) const;
|
||||||
QString text() const {return textCode->toPlainText();}
|
QString text() const;
|
||||||
QStringList cursorScope() const {return cursor_scope;}
|
QStringList cursorScope() const;
|
||||||
bool showSpaces() const {return spaces_;}
|
bool showSpaces() const {return spaces_;}
|
||||||
bool showLineNumbers() const {return textLines->isVisible();}
|
bool showLineNumbers() const;
|
||||||
|
|
||||||
QPlainTextEdit * textEdit() const {return textCode;}
|
void setEditorFont(QFont f);
|
||||||
|
QFont editorFont() const;
|
||||||
|
|
||||||
|
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);}
|
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 bool matchWritten(QString s, QString w);
|
||||||
static QChar pairChar(QChar c);
|
static QChar pairChar(QChar c);
|
||||||
|
|
||||||
|
Ui::QCodeEdit * ui;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ACClass {
|
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) {}
|
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;
|
QIcon icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
QPlainTextEdit * textCode, * textLines;
|
|
||||||
QTreeWidget * completer;
|
QTreeWidget * completer;
|
||||||
IconedLabel * lbl_help[2];
|
IconedLabel * lbl_help[2];
|
||||||
QFrame * widget_help;
|
QFrame * widget_help;
|
||||||
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range;
|
QTextEdit::ExtraSelection es_line, es_cursor, es_bracket, es_range, es_search;
|
||||||
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets;
|
QList<QTextEdit::ExtraSelection> es_selected, es_custom, es_brackets, es_search_list;
|
||||||
QMap<int, ACClass> ac_classes;
|
QMap<int, ACClass> ac_classes;
|
||||||
QStringList cursor_scope;
|
QStringList cursor_scope;
|
||||||
int prev_lc, auto_comp_pl, timer;
|
int prev_lc, auto_comp_pl, timer, cur_search_ind;
|
||||||
bool spaces_, _ignore_focus_out, _first, _destructor;
|
bool spaces_, _ignore_focus_out, _first, _destructor, _replacing;
|
||||||
|
|
||||||
bool eventFilter(QObject * o, QEvent * e);
|
bool eventFilter(QObject * o, QEvent * e);
|
||||||
void showEvent(QShowEvent * );
|
void showEvent(QShowEvent * );
|
||||||
void timerEvent(QTimerEvent * );
|
void timerEvent(QTimerEvent * );
|
||||||
|
void leaveEvent(QEvent * );
|
||||||
void highlightBrackets();
|
void highlightBrackets();
|
||||||
void applyExtraSelection();
|
void applyExtraSelection();
|
||||||
void nextCompletition();
|
void nextCompletition();
|
||||||
void previousCompletition();
|
void previousCompletition();
|
||||||
|
void clearSearch();
|
||||||
|
void moveToSearch();
|
||||||
|
int searchIndFromCursor();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void syncScrolls();
|
void syncScrolls();
|
||||||
@@ -104,17 +119,27 @@ private slots:
|
|||||||
void autoIndent();
|
void autoIndent();
|
||||||
void invokeAutoCompletition(bool force = false);
|
void invokeAutoCompletition(bool force = false);
|
||||||
void commitCompletition();
|
void commitCompletition();
|
||||||
|
void searchAll();
|
||||||
|
void search_triggered();
|
||||||
void textEdit_cursorPositionChanged();
|
void textEdit_cursorPositionChanged();
|
||||||
void textEdit_textChanged();
|
void textEdit_textChanged();
|
||||||
void textEdit_selectionChanged();
|
void textEdit_selectionChanged();
|
||||||
|
void on_comboSearch_currentTextChanged(const QString & t);
|
||||||
|
void on_buttonReplace_clicked();
|
||||||
|
void on_buttonReplaceSearch_clicked();
|
||||||
|
void on_buttonReplaceAll_clicked();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateLines();
|
void updateLines();
|
||||||
void scrollToTop();
|
void scrollToTop();
|
||||||
void setFocus() {textCode->setFocus();}
|
void setFocus();
|
||||||
void setText(const QString & t) {textCode->setPlainText(t);}
|
void setText(const QString & t);
|
||||||
void setShowSpaces(bool yes);
|
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:
|
signals:
|
||||||
void textChanged();
|
void textChanged();
|
||||||
|
|||||||
389
qad/widgets/qcodeedit.ui
Normal file
389
qad/widgets/qcodeedit.ui
Normal file
@@ -0,0 +1,389 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>QCodeEdit</class>
|
||||||
|
<widget class="QWidget" name="QCodeEdit">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>726</width>
|
||||||
|
<height>697</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="frame">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Sunken</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="textLines">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="focusPolicy">
|
||||||
|
<enum>Qt::NoFocus</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="verticalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="horizontalScrollBarPolicy">
|
||||||
|
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
<property name="textInteractionFlags">
|
||||||
|
<set>Qt::NoTextInteraction</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPlainTextEdit" name="textCode">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::NoFrame</enum>
|
||||||
|
</property>
|
||||||
|
<property name="tabChangesFocus">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="lineWrapMode">
|
||||||
|
<enum>QPlainTextEdit::NoWrap</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QWidget" name="widgetSearch" native="true">
|
||||||
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
|
<property name="leftMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="rightMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="verticalSpacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Search:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_5">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonSearchCase">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Case sensitive</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Aa</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonSearchWord">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Whole words</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>W</string>
|
||||||
|
</property>
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonSearchPrev">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Previous</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../nicirt/src/nics_admin/icons.qrc">
|
||||||
|
<normaloff>:/icons/go-previous.png</normaloff>:/icons/go-previous.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonSearchNext">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Next</string>
|
||||||
|
</property>
|
||||||
|
<property name="icon">
|
||||||
|
<iconset resource="../../../nicirt/src/nics_admin/icons.qrc">
|
||||||
|
<normaloff>:/icons/go-next.png</normaloff>:/icons/go-next.png</iconset>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Replace:</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonReplace">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Replace</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>R</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonReplaceSearch">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Replace and search</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Rs</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QToolButton" name="buttonReplaceAll">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Replace all</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Ra</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="EComboBox" name="comboSearch">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::InsertAtTop</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="EComboBox" name="comboReplace">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="editable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="insertPolicy">
|
||||||
|
<enum>QComboBox::InsertAtTop</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>EComboBox</class>
|
||||||
|
<extends>QComboBox</extends>
|
||||||
|
<header>ecombobox.h</header>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources>
|
||||||
|
<include location="../../../nicirt/src/nics_admin/icons.qrc"/>
|
||||||
|
</resources>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSearchNext</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>QCodeEdit</receiver>
|
||||||
|
<slot>searchNext()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>723</x>
|
||||||
|
<y>670</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>731</x>
|
||||||
|
<y>578</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSearchPrev</sender>
|
||||||
|
<signal>clicked()</signal>
|
||||||
|
<receiver>QCodeEdit</receiver>
|
||||||
|
<slot>searchPrevious()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>691</x>
|
||||||
|
<y>670</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>743</x>
|
||||||
|
<y>536</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSearchCase</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>QCodeEdit</receiver>
|
||||||
|
<slot>searchAll()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>612</x>
|
||||||
|
<y>654</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>740</x>
|
||||||
|
<y>499</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonSearchWord</sender>
|
||||||
|
<signal>toggled(bool)</signal>
|
||||||
|
<receiver>QCodeEdit</receiver>
|
||||||
|
<slot>searchAll()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>648</x>
|
||||||
|
<y>658</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>753</x>
|
||||||
|
<y>511</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
<slots>
|
||||||
|
<slot>search(QString)</slot>
|
||||||
|
<slot>searchNext()</slot>
|
||||||
|
<slot>searchPrevious()</slot>
|
||||||
|
<slot>searchAll()</slot>
|
||||||
|
</slots>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user