some more work on find/replace. Find part implemented apart from the 'selected text' option
This commit is contained in:
@ -29,15 +29,39 @@
|
|||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include <qpushbutton.h>
|
||||||
|
#include <qcombobox.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
|
|
||||||
#include "PFindDialog.h"
|
#include "PFindDialog.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
PFindDialog::PFindDialog(PFindReplaceData *data, QWidget *parent, const char *name, bool modal, WFlags f) :
|
PFindDialog::PFindDialog(PFindReplaceData *data, const bool selection, QWidget *parent, const char *name, bool modal, WFlags f) :
|
||||||
PFindDialogBase(parent, name, modal, f), fData(data)
|
PFindDialogBase(parent, name, modal, f), fData(data)
|
||||||
{
|
{
|
||||||
|
// if only empty text, disable find button
|
||||||
|
if (fData->findText == "") {
|
||||||
|
fFind_button->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// if there is no selection, disable that option
|
||||||
|
if (!selection) {
|
||||||
|
fSelectedText_checkBox->setChecked(false);
|
||||||
|
fSelectedText_checkBox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
fFind_comboBox->setCurrentText(fData->findText);
|
||||||
|
fCaseSensitive_checkBox->setChecked(fData->caseSensitive);
|
||||||
|
fWholeWordsOnly_checkBox->setChecked(fData->wholeWordsOnly);
|
||||||
|
fFromCursor_checkBox->setChecked(fData->fromCursor);
|
||||||
|
fFindBackwards_checkBox->setChecked(fData->findBackwards);
|
||||||
|
|
||||||
|
if (selection) {
|
||||||
|
fSelectedText_checkBox->setChecked(fData->selectedText);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -46,9 +70,29 @@ PFindDialog::PFindDialog(PFindReplaceData *data, QWidget *parent, const char *na
|
|||||||
*/
|
*/
|
||||||
PFindReplaceData* PFindDialog::getData()
|
PFindReplaceData* PFindDialog::getData()
|
||||||
{
|
{
|
||||||
|
fData->findText = fFind_comboBox->currentText();
|
||||||
|
fData->caseSensitive = fCaseSensitive_checkBox->isChecked();
|
||||||
|
fData->wholeWordsOnly = fWholeWordsOnly_checkBox->isChecked();
|
||||||
|
fData->fromCursor = fFromCursor_checkBox->isChecked();
|
||||||
|
fData->findBackwards = fFindBackwards_checkBox->isChecked();
|
||||||
|
if (fSelectedText_checkBox->isEnabled())
|
||||||
|
fData->selectedText = fSelectedText_checkBox->isChecked();
|
||||||
|
|
||||||
return fData;
|
return fData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*/
|
||||||
|
void PFindDialog::onFindTextAvailable()
|
||||||
|
{
|
||||||
|
if (fFind_comboBox->currentText() != "")
|
||||||
|
fFind_button->setEnabled(true);
|
||||||
|
else
|
||||||
|
fFind_button->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// END
|
// END
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -40,12 +40,15 @@ class PFindDialog : public PFindDialogBase
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PFindDialog(PFindReplaceData *data, QWidget *parent = 0, const char *name = 0,
|
PFindDialog(PFindReplaceData *data, const bool selection, QWidget *parent = 0, const char *name = 0,
|
||||||
bool modal = TRUE, WFlags f = 0);
|
bool modal = TRUE, WFlags f = 0);
|
||||||
virtual ~PFindDialog() {}
|
virtual ~PFindDialog() {}
|
||||||
|
|
||||||
virtual PFindReplaceData *getData();
|
virtual PFindReplaceData *getData();
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
virtual void onFindTextAvailable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
PFindReplaceData *fData;
|
PFindReplaceData *fData;
|
||||||
};
|
};
|
||||||
|
@ -738,7 +738,7 @@ void PTextEdit::editFind()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PFindDialog *dlg = new PFindDialog(fFindReplaceData);
|
PFindDialog *dlg = new PFindDialog(fFindReplaceData, currentEditor()->hasSelectedText());
|
||||||
|
|
||||||
dlg->exec();
|
dlg->exec();
|
||||||
|
|
||||||
@ -751,7 +751,23 @@ void PTextEdit::editFind()
|
|||||||
|
|
||||||
delete dlg;
|
delete dlg;
|
||||||
|
|
||||||
QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok);
|
// try to find the search text
|
||||||
|
int para = 1, index = 1;
|
||||||
|
if (fFindReplaceData->fromCursor) {
|
||||||
|
currentEditor()->getCursorPosition(¶, &index);
|
||||||
|
} else {
|
||||||
|
para = 1;
|
||||||
|
index = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentEditor()->find(fFindReplaceData->findText,
|
||||||
|
fFindReplaceData->caseSensitive,
|
||||||
|
fFindReplaceData->wholeWordsOnly,
|
||||||
|
!fFindReplaceData->findBackwards,
|
||||||
|
¶, &index)) {
|
||||||
|
// set cursor to the correct position
|
||||||
|
currentEditor()->setCursorPosition(para, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -760,7 +776,17 @@ void PTextEdit::editFind()
|
|||||||
*/
|
*/
|
||||||
void PTextEdit::editFindNext()
|
void PTextEdit::editFindNext()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok);
|
int para = 1, index = 1;
|
||||||
|
currentEditor()->getCursorPosition(¶, &index);
|
||||||
|
index++;
|
||||||
|
if (currentEditor()->find(fFindReplaceData->findText,
|
||||||
|
fFindReplaceData->caseSensitive,
|
||||||
|
fFindReplaceData->wholeWordsOnly,
|
||||||
|
true,
|
||||||
|
¶, &index)) {
|
||||||
|
// set cursor to the correct position
|
||||||
|
currentEditor()->setCursorPosition(para, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
@ -769,7 +795,16 @@ void PTextEdit::editFindNext()
|
|||||||
*/
|
*/
|
||||||
void PTextEdit::editFindPrevious()
|
void PTextEdit::editFindPrevious()
|
||||||
{
|
{
|
||||||
QMessageBox::information(this, "**INFO**", "Not Yet Implemented", QMessageBox::Ok);
|
int para = 1, index = 1;
|
||||||
|
currentEditor()->getCursorPosition(¶, &index);
|
||||||
|
if (currentEditor()->find(fFindReplaceData->findText,
|
||||||
|
fFindReplaceData->caseSensitive,
|
||||||
|
fFindReplaceData->wholeWordsOnly,
|
||||||
|
false,
|
||||||
|
¶, &index)) {
|
||||||
|
// set cursor to the correct position
|
||||||
|
currentEditor()->setCursorPosition(para, index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -238,6 +238,12 @@
|
|||||||
<receiver>PFindDialogBase</receiver>
|
<receiver>PFindDialogBase</receiver>
|
||||||
<slot>accept()</slot>
|
<slot>accept()</slot>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>fFind_comboBox</sender>
|
||||||
|
<signal>textChanged(const QString&)</signal>
|
||||||
|
<receiver>PFindDialogBase</receiver>
|
||||||
|
<slot>onFindTextAvailable()</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>fFind_comboBox</tabstop>
|
<tabstop>fFind_comboBox</tabstop>
|
||||||
@ -249,5 +255,8 @@
|
|||||||
<tabstop>fFind_button</tabstop>
|
<tabstop>fFind_button</tabstop>
|
||||||
<tabstop>fClose_button</tabstop>
|
<tabstop>fClose_button</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
|
<slots>
|
||||||
|
<slot access="protected">onFindTextAvailable()</slot>
|
||||||
|
</slots>
|
||||||
<layoutdefaults spacing="6" margin="11"/>
|
<layoutdefaults spacing="6" margin="11"/>
|
||||||
</UI>
|
</UI>
|
||||||
|
Reference in New Issue
Block a user