git-svn-id: svn://db.shs.com.ru/libs@469 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -14,8 +14,10 @@
|
||||
#include "qad_types.h"
|
||||
#include "ui_qcodeedit.h"
|
||||
|
||||
Q_DECLARE_METATYPE(QTextCursor)
|
||||
|
||||
QCodeEdit::QCodeEdit(QWidget * parent): QWidget(parent) {
|
||||
qRegisterMetaType<QTextCursor>();
|
||||
ui = new Ui::QCodeEdit();
|
||||
ui->setupUi(this);
|
||||
ui->widgetSearch->hide();
|
||||
@@ -150,6 +152,31 @@ QTextDocument * QCodeEdit::document() const {
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::setDocument(QTextDocument * doc) {
|
||||
if (document()) {
|
||||
document()->setProperty("_cursor", QVariant::fromValue(textCursor()));
|
||||
document()->setProperty("_vpos", textEdit()->verticalScrollBar()->value());
|
||||
}
|
||||
documentUnset();
|
||||
if (!doc) {
|
||||
ui->textCode->setDocument(0);
|
||||
documentChanged(0);
|
||||
return;
|
||||
}
|
||||
if (!qobject_cast<QPlainTextDocumentLayout*>(doc->documentLayout()))
|
||||
doc->setDocumentLayout(new QPlainTextDocumentLayout(doc));
|
||||
ui->textCode->setDocument(doc);
|
||||
ui->textCode->setCursorWidth(qMax<int>(qRound(fontHeight() / 10.), 1));
|
||||
if (doc->property("_cursor").isValid()) {
|
||||
setTextCursor(doc->property("_cursor").value<QTextCursor>());
|
||||
textEdit()->verticalScrollBar()->setValue(doc->property("_vpos").toInt());
|
||||
}
|
||||
documentChanged(doc);
|
||||
doc->setDefaultFont(editorFont());
|
||||
updateLines();
|
||||
}
|
||||
|
||||
|
||||
void QCodeEdit::setTextCursor(const QTextCursor & c) {
|
||||
ui->textCode->setTextCursor(c);
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
|
||||
QTextCursor textCursor() const;
|
||||
QTextDocument * document() const;
|
||||
void setDocument(QTextDocument * doc);
|
||||
void setTextCursor(const QTextCursor & c);
|
||||
void centerCursor();
|
||||
void insertText(const QString & text);
|
||||
@@ -63,6 +64,8 @@ protected:
|
||||
|
||||
virtual ACList autoCompletitionList(const QStringList & scope, const QString & written) const {return ACList();}
|
||||
virtual void parse() {}
|
||||
virtual void documentUnset() {}
|
||||
virtual void documentChanged(QTextDocument * d) {}
|
||||
QString selectArg(QString s, int arg);
|
||||
void raiseHelp(QTextCursor tc, int arg = -1);
|
||||
QTextCursor functionStart(QTextCursor tc, int * arg);
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
<string>Previous</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_widgets.qrc">
|
||||
<iconset resource="../../../SHS/src/designers/SH_designer/SH_designer.qrc">
|
||||
<normaloff>:/icons/go-previous.png</normaloff>:/icons/go-previous.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -195,7 +195,7 @@
|
||||
<string>Next</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="qad_widgets.qrc">
|
||||
<iconset resource="../../../SHS/src/designers/SH_designer/SH_designer.qrc">
|
||||
<normaloff>:/icons/go-next.png</normaloff>:/icons/go-next.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
@@ -311,9 +311,7 @@
|
||||
<header>ecombobox.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="qad_widgets.qrc"/>
|
||||
</resources>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonSearchNext</sender>
|
||||
|
||||
Reference in New Issue
Block a user