mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +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);
|
preambleTE->setWordWrapMode(QTextOption::NoWrap);
|
||||||
setFocusProxy(preambleTE);
|
setFocusProxy(preambleTE);
|
||||||
connect(preambleTE, SIGNAL(textChanged()), this, SIGNAL(changed()));
|
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 closeEvent(QCloseEvent *);
|
||||||
void on_preambleTE_textChanged() { changed(); }
|
void on_preambleTE_textChanged() { changed(); }
|
||||||
|
|
||||||
private:
|
|
||||||
typedef std::map<BufferId, std::pair<int,int> > Coords;
|
typedef std::map<BufferId, std::pair<int,int> > Coords;
|
||||||
Coords preamble_coords_;
|
Coords preamble_coords_;
|
||||||
BufferId current_id_;
|
BufferId current_id_;
|
||||||
|
|
||||||
|
private Q_SLOTS:
|
||||||
|
///
|
||||||
|
void checkFindButton();
|
||||||
|
void findText();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<ui version="4.0" >
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
<class>PreambleUi</class>
|
<class>PreambleUi</class>
|
||||||
<widget class="QWidget" name="PreambleUi" >
|
<widget class="QWidget" name="PreambleUi">
|
||||||
<property name="geometry" >
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
@ -9,19 +10,38 @@
|
|||||||
<height>278</height>
|
<height>278</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle" >
|
<property name="windowTitle">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" >
|
<layout class="QGridLayout">
|
||||||
<property name="margin" >
|
<property name="leftMargin">
|
||||||
<number>11</number>
|
<number>11</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="spacing" >
|
<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>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0" >
|
<item row="1" column="0">
|
||||||
<widget class="QTextEdit" name="preambleTE" >
|
<widget class="QLineEdit" name="findLE"/>
|
||||||
<property name="acceptRichText" >
|
</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>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
@ -29,7 +49,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<includes>
|
<includes>
|
||||||
<include location="local" >qt_i18n.h</include>
|
<include location="local">qt_i18n.h</include>
|
||||||
</includes>
|
</includes>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
Loading…
Reference in New Issue
Block a user