-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathfinddialog.cpp
94 lines (62 loc) · 1.86 KB
/
finddialog.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Ted, a simple text editor/IDE.
Copyright 2012, Blitz Research Ltd.
See LICENSE.TXT for licensing terms.
*/
#include "finddialog.h"
#include "ui_finddialog.h"
#include "prefs.h"
FindDialog::FindDialog( QWidget *parent ):QDialog( parent ),_ui( new Ui::FindDialog ),_used( false ){
_ui->setupUi( this );
}
FindDialog::~FindDialog(){
delete _ui;
}
void FindDialog::readSettings(){
QSettings *set = Prefs::settings();
if( set->value( "settingsVersion" ).toInt()<2 ) return;
set->beginGroup( "findDialog" );
_ui->findText->setText( set->value( "findText" ).toString() );
_ui->replaceText->setText( set->value( "replaceText" ).toString() );
_ui->caseSensitive->setChecked( set->value( "caseSensitive" ).toBool() );
restoreGeometry( set->value( "geometry" ).toByteArray() );
set->endGroup();
}
void FindDialog::writeSettings(){
if( !_used ) return;
QSettings *set = Prefs::settings();
set->beginGroup( "findDialog" );
set->setValue( "findText",_ui->findText->text() );
set->setValue( "replaceText",_ui->replaceText->text() );
set->setValue( "caseSensitive",_ui->caseSensitive->isChecked() );
set->setValue( "geometry",saveGeometry() );
set->endGroup();
}
int FindDialog::exec(){
QDialog::show();
if( !_used ){
restoreGeometry( saveGeometry() );
_used=true;
}
_ui->findText->setFocus( Qt::OtherFocusReason );
_ui->findText->selectAll();
return QDialog::exec();
}
QString FindDialog::findText(){
return _ui->findText->text();
}
QString FindDialog::replaceText(){
return _ui->replaceText->text();
}
bool FindDialog::caseSensitive(){
return _ui->caseSensitive->isChecked();
}
void FindDialog::onFindNext(){
emit findReplace( 0 );
}
void FindDialog::onReplace(){
emit findReplace( 1 );
}
void FindDialog::onReplaceAll(){
emit findReplace( 2 );
}