-
Notifications
You must be signed in to change notification settings - Fork 0
/
gotodialog.cpp
34 lines (30 loc) · 928 Bytes
/
gotodialog.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "gotodialog.h"
#include "ui_gotodialog.h"
GotoDialog::GotoDialog(QTextEdit * grammar,QWidget *parent) :
QDialog(parent),
ui(new Ui::GotoDialog)
{
ui->setupUi(this);
this->setLayout(ui->horizontalLayout);
ui->horizontalLayout->setMargin(10);
this->setFixedSize(this->sizeHint().width()+40,this->sizeHint().height());
connect(this,SIGNAL(accepted()),this,SLOT(onaccept()));
this->grammar=grammar;
this->setWindowTitle("Ïåðåéòè");
}
GotoDialog::~GotoDialog()
{
delete ui;
}
void GotoDialog::showEvent(QShowEvent *e)
{
ui->line->setMaximum(grammar->document()->lineCount());
ui->line->setValue(1);
}
void GotoDialog::onaccept()
{
grammar->moveCursor(QTextCursor::Start,QTextCursor::MoveAnchor);
QTextCursor cursor=grammar->textCursor();
cursor.movePosition(QTextCursor::Down,QTextCursor::MoveAnchor,ui->line->value()-1);
grammar->setTextCursor(cursor);
}