mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 01:59:02 +00:00
Fix bug 11099.
Adds simple search/find functionality to preamble.
This commit is contained in:
parent
bcd1814746
commit
2bb9d49527
@ -469,6 +469,29 @@ PreambleModule::PreambleModule(QWidget * parent)
|
||||
preambleTE->setWordWrapMode(QTextOption::NoWrap);
|
||||
setFocusProxy(preambleTE);
|
||||
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
||||
connect(findLE, SIGNAL(textEdited(const QString &)), this, SLOT(checkFindButton()));
|
||||
connect(findButtonPB, SIGNAL(clicked()), this, SLOT(findText()));
|
||||
connect(findLE, SIGNAL(returnPressed()), this, SLOT(findText()));
|
||||
checkFindButton();
|
||||
}
|
||||
|
||||
|
||||
void PreambleModule::checkFindButton()
|
||||
{
|
||||
findButtonPB->setEnabled(!findLE->text().isEmpty());
|
||||
}
|
||||
|
||||
|
||||
void PreambleModule::findText()
|
||||
{
|
||||
bool const found = preambleTE->find(findLE->text());
|
||||
if (!found) {
|
||||
// wrap
|
||||
QTextCursor qtcur = preambleTE->textCursor();
|
||||
qtcur.movePosition(QTextCursor::Start);
|
||||
preambleTE->setTextCursor(qtcur);
|
||||
preambleTE->find(findLE->text());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -332,10 +332,14 @@ private:
|
||||
void closeEvent(QCloseEvent *);
|
||||
void on_preambleTE_textChanged() { changed(); }
|
||||
|
||||
private:
|
||||
typedef std::map<BufferId, std::pair<int,int> > Coords;
|
||||
Coords preamble_coords_;
|
||||
BufferId current_id_;
|
||||
|
||||
private Q_SLOTS:
|
||||
///
|
||||
void checkFindButton();
|
||||
void findText();
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>PreambleUi</class>
|
||||
<widget class="QWidget" name="PreambleUi">
|
||||
@ -13,13 +14,32 @@
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin" >
|
||||
<property name="leftMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>11</number>
|
||||
</property>
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLineEdit" name="findLE"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="findButtonPB">
|
||||
<property name="text">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QTextEdit" name="preambleTE">
|
||||
<property name="acceptRichText">
|
||||
<bool>false</bool>
|
||||
|
Loading…
Reference in New Issue
Block a user