20#include "kexifinddialog.h"
22#include <kstdguiitem.h>
23#include <kstdaction.h>
24#include <kpushbutton.h>
30#include <kiconloader.h>
32#include <tqcheckbox.h>
34#include <tqguardedptr.h>
39class KexiFindDialog::Private
44 accels.setAutoDelete(
true);
52 void setActionAndAccel(TDEAction *action, TQWidget* parent,
const char* member)
56 TQObject::connect(parent, member, action, TQ_SLOT(activate()));
57 if (action->shortcut().isNull())
59 TQAccel *accel =
new TQAccel(parent);
60 accels.append( accel );
62 accel->insertItem( action->shortcut() ), parent, member );
65 TQStringList lookInColumnNames;
66 TQStringList lookInColumnCaptions;
68 TQGuardedPtr<TDEAction> findnextAction;
69 TQGuardedPtr<TDEAction> findprevAction;
70 TQGuardedPtr<TDEAction> replaceAction;
71 TQGuardedPtr<TDEAction> replaceallAction;
72 TQPtrList<TQAccel> accels;
79 : KexiFindDialogBase(parent,
"KexiFindDialog", false,
80 TQt::WType_Dialog|TQt::WStyle_NormalBorder|TQt::WStyle_Title
81 |TQt::WStyle_SysMenu|TQt::WStyle_Customize|TQt::WStyle_Tool)
85 layout()->setMargin( KDialog::marginHint() );
86 layout()->setSpacing( KDialog::spacingHint() );
87 TDEAction *a = KStdAction::findNext(0, 0, 0);
88 m_btnFind->setText(a->text());
89 m_btnFind->setIconSet(a->iconSet());
91 m_btnClose->setText(KStdGuiItem::close().text());
92 m_btnClose->setIconSet(KStdGuiItem::close().iconSet());
93 connect(m_btnFind, TQ_SIGNAL(clicked()),
this, TQ_SIGNAL(
findNext()));
94 connect(m_btnClose, TQ_SIGNAL(clicked()),
this, TQ_SLOT(slotCloseClicked()));
95 connect(m_btnReplace, TQ_SIGNAL(clicked()),
this, TQ_SIGNAL(
replaceNext()));
96 connect(m_btnReplaceAll, TQ_SIGNAL(clicked()),
this, TQ_SIGNAL(
replaceAll()));
98 connect(m_textToFind, TQ_SIGNAL(textChanged()),
this, TQ_SIGNAL(
updateMessage()));
99 connect(m_textToReplace, TQ_SIGNAL(textChanged()),
this, TQ_SIGNAL(
updateMessage()));
101 d->replaceMode =
true;
107KexiFindDialog::~KexiFindDialog()
113 TDEAction *replace, TDEAction *replaceall )
115 d->findnextAction = findnext;
116 d->findprevAction = findprev;
117 d->replaceAction = replace;
118 d->replaceallAction = replaceall;
120 d->setActionAndAccel(d->findnextAction,
this, TQ_SIGNAL(
findNext()));
121 d->setActionAndAccel(d->findprevAction,
this, TQ_SIGNAL(
findPrevious()));
122 d->setActionAndAccel(d->replaceAction,
this, TQ_SIGNAL(
replaceNext()));
123 d->setActionAndAccel(d->replaceallAction,
this, TQ_SIGNAL(
replaceAll()));
128 return d->lookInColumnNames;
133 return d->lookInColumnCaptions;
138 int index = m_lookIn->currentItem();
139 if (index <= 0 || index >= (
int)d->lookInColumnNames.count())
143 return d->lookInColumnNames[index - 1 - 1];
148 return m_textToFind->currentText();
153 return m_textToReplace->currentText();
157 const TQStringList& columnCaptions)
159 d->lookInColumnNames = columnNames;
160 d->lookInColumnCaptions = columnCaptions;
162 m_lookIn->insertItem(i18n(
"(All fields)"));
163 m_lookIn->insertItem(i18n(
"(Current field)"));
164 m_lookIn->insertStringList(d->lookInColumnCaptions);
170 if (columnName.isEmpty())
172 else if (columnName ==
"(field)")
175 index = d->lookInColumnNames.findIndex( columnName );
177 kdWarning() << TQString(
"KexiFindDialog::setCurrentLookInColumn(%1) column name not found on the list")
178 .arg(columnName) << endl;
181 index = index + 1 + 1;
183 m_lookIn->setCurrentItem(index);
188 if (d->replaceMode == set)
190 d->replaceMode = set;
191 if (d->replaceMode) {
192 m_promptOnReplace->show();
193 m_replaceLbl->show();
194 m_textToReplace->show();
195 m_btnReplace->show();
196 m_btnReplaceAll->show();
199 m_promptOnReplace->hide();
200 m_replaceLbl->hide();
201 m_textToReplace->hide();
202 m_btnReplace->hide();
203 m_btnReplaceAll->hide();
204 resize(width(),height()-30);
212 d->objectName = name;
213 if (d->replaceMode) {
215 setCaption(i18n(
"Replace"));
217 setCaption(i18n(
"Replace in \"%1\"").arg(name));
221 setCaption(i18n(
"Find"));
223 setCaption(i18n(
"Find in \"%1\"").arg(name));
229 m_btnFind->setEnabled(enable);
230 m_btnReplace->setEnabled(enable);
231 m_btnReplaceAll->setEnabled(enable);
238 m_messageLabel->setText(message);
246 setMessage(i18n(
"The search item was not found"));
249void KexiFindDialog::slotCloseClicked()
256 m_textToFind->setFocus();
263 if (m_lookIn->currentItem() <= 0)
265 else if (m_lookIn->currentItem() == 1)
268 options.columnNumber = m_lookIn->currentItem() - 1 - 1;
273 options.caseSensitive = m_caseSensitive->isChecked();
274 options.wholeWordsOnly = m_wholeWords->isChecked();
275 options.promptOnReplace = m_promptOnReplace->isChecked();
279#include "kexifinddialog.moc"
void setCurrentLookInColumnName(const TQString &columnName)
void setActions(TDEAction *findnext, TDEAction *findprev, TDEAction *replace, TDEAction *replaceall)
Sets actions that receive button clicks and shortcuts within the dialog. Should be called once.
void setObjectNameForCaption(const TQString &name)
void updateMessage(bool found=true)
TQVariant valueToFind() const
void replaceAll()
Emitted after clicking "Replace All" button or pressing appropriate shortcut set by setActions().
TQStringList lookInColumnCaptions() const
void replaceNext()
Emitted after clicking "Replace" button or pressing appropriate shortcut set by setActions().
TQVariant valueToReplaceWith() const
void setMessage(const TQString &message)
TQStringList lookInColumnNames() const
void findNext()
Emitted after clicking "Find next" button or pressing appropriate shortcut set by setActions().
void findPrevious()
Emitted after pressing appropriate shortcut set by setActions().
virtual void show()
Shows the dialog as a modal dialog.
void setButtonsEnabled(bool enable)
TQString currentLookInColumnName() const
KexiFindDialog(TQWidget *parent)
Creates a new find dialog. Replace mode is off by default.
void setReplaceMode(bool set)
KexiSearchAndReplaceViewInterface::Options options() const
void setLookInColumnList(const TQStringList &columnNames, const TQStringList &columnCaptions)
Specifies options for find and replace operations.
@ AllColumns
"all columns" (the default)
@ CurrentColumn
"current column"
TextMatching
Specifies possible options for text matching.
SearchDirection
Specifies search direction.
@ SearchDown
Search down (next) from the current position (the default).