added edit button for regular expressions

svn path=/trunk/kdenetwork/kmail/; revision=138266
wilder-work
Jesper Pedersen 24 years ago
parent 77f2dc529d
commit 3e06824d57
  1. 29
      kmsearchpatternedit.cpp
  2. 6
      kmsearchpatternedit.h

@ -14,6 +14,10 @@
#include <qstringlist.h>
#include <assert.h>
#include <kparts/componentfactory.h>
#include <kregexpeditorinterface.h>
#include <qpushbutton.h>
#include <qdialog.h>
static QStringList sFilterFieldList, sFilterFuncList;
@ -43,6 +47,15 @@ void KMSearchRuleWidget::initWidget()
mRuleFunc = new QComboBox( false, this, "mRuleFunc" );
mRuleValue = new QLineEdit( this, "mRuleValue" );
mRegExpEditDialog = KParts::ComponentFactory::createInstanceFromQuery<QDialog>("KRegExpEditor/KRegExpEditor", QString::null, this );
if( mRegExpEditDialog )
{
mRuleEditBut = new QPushButton( i18n("Edit"), this, "mRuleEditBut" );
connect( mRuleEditBut, SIGNAL( clicked() ), this, SLOT( editRegExp()));
connect( mRuleFunc, SIGNAL( activated(int) ), this, SLOT( functionChanged(int) ) );
functionChanged( mRuleFunc->currentItem() );
}
mRuleFunc->insertStringList(sFilterFuncList);
mRuleFunc->adjustSize();
@ -57,6 +70,22 @@ void KMSearchRuleWidget::initWidget()
this, SIGNAL(contentsChanged(const QString &)) );
}
void KMSearchRuleWidget::editRegExp()
{
KRegExpEditorInterface *iface = dynamic_cast<KRegExpEditorInterface *>( mRegExpEditDialog );
if( iface ) {
iface->setRegExp( mRuleValue->text() );
if( mRegExpEditDialog->exec() == QDialog::Accepted )
mRuleValue->setText( iface->regExp() );
}
}
void KMSearchRuleWidget::functionChanged( int which )
{
mRuleEditBut->setEnabled( which == 4 || which == 5 );
}
void KMSearchRuleWidget::setRule(KMSearchRule *aRule)
{
assert ( aRule );

@ -75,6 +75,10 @@ protected:
ComboBox. Returns the index if found or -1 if the search failed, */
int indexOfRuleField(const QString aName) const;
protected slots:
void editRegExp();
void functionChanged( int which );
private:
void initWidget();
void initLists(bool headersOnly) const;
@ -82,6 +86,8 @@ private:
QComboBox* mRuleField;
QComboBox* mRuleFunc;
QLineEdit* mRuleValue;
QPushButton* mRuleEditBut;
QDialog* mRegExpEditDialog;
};

Loading…
Cancel
Save