[prev in list] [next in list] [prev in thread] [next in thread]
List: kmail-devel
Subject: [PATCH] Disposition of action widgets on filterWindow
From: Mario Teijeiro Otero <emeteo () escomposlinux ! org>
Date: 2005-04-06 15:59:43
Message-ID: 200504061759.47972.emeteo () escomposlinux ! org
[Download RAW message or body]
[Attachment #2 (multipart/signed)]
[Attachment #4 (multipart/mixed)]
Hi,
I found a 'hack' to get that the comboxes have the proper vertical size.
(see identify_filter1.png ).
I notice all widgets that were created directly with her parent as
QWidgetStack don't respec the setSizePolicy, posible bug of QWidgetStack?
P.e. with:
QWidget* KMFilterActionWithString::createParamWidget( QWidget* parent )
{
QLineEdit *le = new KLineEdit(parent);
le->setText( mParameter );
return le;
}
this KlineEdits get the same height that the parent, but with:
QWidget* KMFilterActionWithString::createParamWidget( QWidget* parent ) const
{
QWidget *w = new QWidget( parent );
QHBoxLayout *hbl = new QHBoxLayout( w );
hbl->setSpacing( 4 );
QLineEdit *le = new KLineEdit(w, "edit");
le->setText( mParameter );
hbl->addWidget ( le, 1 );
return w;
}
work Ok.
Other think, on bug:103340, I notice that the field of Rewrite Header Action
are a RegExp and the input is a KLineEdit. I replaced it with a
RegExpLineEdit. I put into two rows (as shown on rewrite_filter.png
attached), because with a QHBoxLayout all fields was too tight. But the
result is too ugly. Some solution ?
Regards
["filter_dialog.patch" (text/x-diff)]
Index: kmfilteraction.cpp
===================================================================
RCS file: /home/kde/kdepim/kmail/kmfilteraction.cpp,v
retrieving revision 1.131
diff -u -p -r1.131 kmfilteraction.cpp
--- kmfilteraction.cpp 20 Feb 2005 20:25:11 -0000 1.131
+++ kmfilteraction.cpp 6 Apr 2005 15:43:16 -0000
@@ -16,6 +16,8 @@
#include "kmfoldermgr.h"
#include "kmsender.h"
#include "kmmainwidget.h"
+#include "regexplineedit.h"
+using KMail::RegExpLineEdit;
#include <libkpimidentities/identity.h>
#include <libkpimidentities/identitymanager.h>
#include <libkpimidentities/identitycombo.h>
@@ -178,24 +180,38 @@ KMFilterActionWithString::KMFilterAction
QWidget* KMFilterActionWithString::createParamWidget( QWidget* parent ) const
{
- QLineEdit *le = new KLineEdit(parent);
+ QWidget *w = new QWidget( parent );
+
+ QHBoxLayout *hbl = new QHBoxLayout( w );
+ hbl->setSpacing( 4 );
+
+ QLineEdit *le = new KLineEdit(w, "edit");
le->setText( mParameter );
- return le;
+
+ hbl->addWidget ( le, 1 );
+ return w;
}
void KMFilterActionWithString::applyParamWidgetValue( QWidget* paramWidget )
{
- mParameter = ((QLineEdit*)paramWidget)->text();
+ QLineEdit *le = ( QLineEdit* ) paramWidget->child("edit" );
+ Q_ASSERT( le );
+ mParameter = le->text();
}
void KMFilterActionWithString::setParamWidgetValue( QWidget* paramWidget ) const
{
- ((QLineEdit*)paramWidget)->setText( mParameter );
+ QLineEdit *le = ( QLineEdit* ) paramWidget->child("edit" );
+ Q_ASSERT( le );
+ le->setText( mParameter );
}
void KMFilterActionWithString::clearParamWidget( QWidget* paramWidget ) const
{
- ((QLineEdit*)paramWidget)->clear();
+ QLineEdit *le = ( QLineEdit* ) paramWidget->child("edit" );
+ Q_ASSERT( le );
+
+ le->clear();
}
void KMFilterActionWithString::argsFromString( const QString argsStr )
@@ -228,26 +244,39 @@ KMFilterActionWithStringList::KMFilterAc
QWidget* KMFilterActionWithStringList::createParamWidget( QWidget* parent ) const
{
- QComboBox *cb = new QComboBox( FALSE, parent );
+ QWidget *w = new QWidget( parent );
+ QHBoxLayout *hbl = new QHBoxLayout( w );
+ hbl->setSpacing( 4 );
+
+ QComboBox *cb = new QComboBox( FALSE, w, "combo" );
cb->insertStringList( mParameterList );
- setParamWidgetValue( cb );
- return cb;
+
+ hbl->addWidget( cb, 1 );
+ setParamWidgetValue( w );
+ return w;
}
void KMFilterActionWithStringList::applyParamWidgetValue( QWidget* paramWidget )
{
- mParameter = ((QComboBox*)paramWidget)->currentText();
+ QComboBox *cb = (QComboBox*)paramWidget->child("combo");
+ Q_ASSERT( cb );
+ mParameter = cb->currentText();
}
void KMFilterActionWithStringList::setParamWidgetValue( QWidget* paramWidget ) const
{
int idx = mParameterList.findIndex( mParameter );
- ((QComboBox*)paramWidget)->setCurrentItem( idx >= 0 ? idx : 0 );
+ QComboBox *cb = (QComboBox*)paramWidget->child("combo");
+ Q_ASSERT( cb );
+
+ cb->setCurrentItem( idx >= 0 ? idx : 0 );
}
void KMFilterActionWithStringList::clearParamWidget( QWidget* paramWidget ) const
{
- ((QComboBox*)paramWidget)->setCurrentItem(0);
+ QComboBox *cb = (QComboBox*)paramWidget->child("combo");
+ Q_ASSERT( cb );
+ cb->setCurrentItem(0);
}
void KMFilterActionWithStringList::argsFromString( const QString argsStr )
@@ -697,21 +726,28 @@ KMFilterAction::ReturnCode KMFilterActio
QWidget * KMFilterActionIdentity::createParamWidget( QWidget * parent ) const
{
- KPIM::IdentityCombo * ic = new KPIM::IdentityCombo( kmkernel->identityManager(), parent );
+ QWidget *w = new QWidget ( parent );
+ QHBoxLayout *hbl = new QHBoxLayout( w );
+ hbl->setSpacing( 4 );
+
+ KPIM::IdentityCombo * ic = new KPIM::IdentityCombo( kmkernel->identityManager(), w, "identify");
ic->setCurrentIdentity( mParameter );
- return ic;
+
+ hbl->addWidget( ic, 1 );
+
+ return w;
}
void KMFilterActionIdentity::applyParamWidgetValue( QWidget * paramWidget )
{
- KPIM::IdentityCombo * ic = dynamic_cast<KPIM::IdentityCombo*>( paramWidget );
+ KPIM::IdentityCombo* ic = (KPIM::IdentityCombo*)paramWidget->child("identify");
assert( ic );
mParameter = ic->currentIdentity();
}
void KMFilterActionIdentity::clearParamWidget( QWidget * paramWidget ) const
{
- KPIM::IdentityCombo * ic = dynamic_cast<KPIM::IdentityCombo*>( paramWidget );
+ KPIM::IdentityCombo* ic = (KPIM::IdentityCombo*)paramWidget->child("identify");
assert( ic );
ic->setCurrentItem( 0 );
//ic->setCurrentIdentity( kmkernel->identityManager()->defaultIdentity() );
@@ -719,7 +755,7 @@ void KMFilterActionIdentity::clearParamW
void KMFilterActionIdentity::setParamWidgetValue( QWidget * paramWidget ) const
{
- KPIM::IdentityCombo * ic = dynamic_cast<KPIM::IdentityCombo*>( paramWidget );
+ KPIM::IdentityCombo* ic = (KPIM::IdentityCombo*)paramWidget->child("identify");
assert( ic );
ic->setCurrentIdentity( mParameter );
}
@@ -936,7 +972,7 @@ public:
virtual ReturnCode process(KMMessage* msg) const;
virtual QWidget* createParamWidget( QWidget* parent ) const;
virtual void setParamWidgetValue( QWidget* paramWidget ) const;
-
+ virtual void clearParamWidget(QWidget* paramWidget) const;
static KMFilterAction* newAction();
};
@@ -959,10 +995,16 @@ KMFilterActionRemoveHeader::KMFilterActi
QWidget* KMFilterActionRemoveHeader::createParamWidget( QWidget* parent ) const
{
- QComboBox *cb = new QComboBox( TRUE/*editable*/, parent );
+ QWidget *w = new QWidget( parent );
+ QHBoxLayout *hbl = new QHBoxLayout( w );
+ hbl->setSpacing( 4 );
+ QComboBox *cb = new QComboBox( TRUE/*editable*/, w, "combo" );
cb->setInsertionPolicy( QComboBox::AtBottom );
- setParamWidgetValue( cb );
- return cb;
+
+ hbl->addWidget( cb, 1);
+
+ setParamWidgetValue( w );
+ return w;
}
KMFilterAction::ReturnCode KMFilterActionRemoveHeader::process(KMMessage* msg) const
@@ -974,12 +1016,19 @@ KMFilterAction::ReturnCode KMFilterActio
return GoOn;
}
-void KMFilterActionRemoveHeader::setParamWidgetValue( QWidget* paramWidget ) const
+void KMFilterActionRemoveHeader::clearParamWidget(QWidget* paramWidget) const
{
- QComboBox * cb = dynamic_cast<QComboBox*>(paramWidget);
+ QComboBox *cb = (QComboBox*)paramWidget->child("combo");
Q_ASSERT( cb );
+ cb->setCurrentItem(0);
+}
+void KMFilterActionRemoveHeader::setParamWidgetValue( QWidget* paramWidget ) const
+{
int idx = mParameterList.findIndex( mParameter );
+ QComboBox *cb = (QComboBox*)paramWidget->child("combo");
+ Q_ASSERT( cb );
+
cb->clear();
cb->insertStringList( mParameterList );
if ( idx < 0 ) {
@@ -1189,26 +1238,40 @@ KMFilterAction::ReturnCode KMFilterActio
QWidget* KMFilterActionRewriteHeader::createParamWidget( QWidget* parent ) const
{
QWidget *w = new QWidget( parent );
- QHBoxLayout *hbl = new QHBoxLayout( w );
- hbl->setSpacing( 4 );
+
+
+ QHBoxLayout * hbl = new QHBoxLayout( w );
+ hbl->setSpacing( 4 );
+
+ QVBoxLayout * vbl = new QVBoxLayout( );
QComboBox *cb = new QComboBox( TRUE, w, "combo" );
cb->setInsertionPolicy( QComboBox::AtBottom );
- hbl->addWidget( cb, 0 /* stretch */ );
+ vbl->addWidget( cb, 0);
+
+ vbl->addItem( new QSpacerItem( 0, 0 ) );
+ hbl->addLayout( vbl);
+
+ QGridLayout *grid = new QGridLayout( 2, 2 );
QLabel *l = new QLabel( i18n("Replace:"), w );
l->setFixedWidth( l->sizeHint().width() );
- hbl->addWidget( l, 0 );
+ grid->addWidget( l, 0 , 0);
- QLineEdit *le = new KLineEdit( w, "search" );
- hbl->addWidget( le, 1 );
+ RegExpLineEdit *lere = new RegExpLineEdit( w, "search" );
+ grid->addWidget( lere, 0 , 1 );
l = new QLabel( i18n("With:"), w );
l->setFixedWidth( l->sizeHint().width() );
- hbl->addWidget( l, 0 );
+ grid->addWidget( l, 1, 0 );
- le = new KLineEdit( w, "replace" );
- hbl->addWidget( le, 1 );
+ QLineEdit *le = new QLineEdit( w, "replace" );
+ grid->addWidget( le, 1, 1 );
+
+ grid->setColStretch( 0 , 0 );
+ grid->setColStretch( 1 , 1 );
+
+ hbl->addLayout( grid );
setParamWidgetValue( w );
return w;
@@ -1229,11 +1292,11 @@ void KMFilterActionRewriteHeader::setPar
cb->setCurrentItem( idx );
}
- QLineEdit *le = (QLineEdit*)paramWidget->child("search");
- Q_ASSERT( le );
- le->setText( mRegExp.pattern() );
+ RegExpLineEdit *rele = (RegExpLineEdit*)paramWidget->child("search");
+ Q_ASSERT( rele );
+ rele->setText( mRegExp.pattern() );
- le = (QLineEdit*)paramWidget->child("replace");
+ QLineEdit *le = (QLineEdit*)paramWidget->child("replace");
Q_ASSERT( le );
le->setText( mReplacementString );
}
@@ -1244,11 +1307,11 @@ void KMFilterActionRewriteHeader::applyP
Q_ASSERT( cb );
mParameter = cb->currentText();
- QLineEdit *le = (QLineEdit*)paramWidget->child("search");
- Q_ASSERT( le );
- mRegExp.setPattern( le->text() );
+ RegExpLineEdit *rele = (RegExpLineEdit*)paramWidget->child("search");
+ Q_ASSERT( rele );
+ mRegExp.setPattern( rele->text() );
- le = (QLineEdit*)paramWidget->child("replace");
+ QLineEdit *le = (QLineEdit*)paramWidget->child("replace");
Q_ASSERT( le );
mReplacementString = le->text();
}
@@ -1259,11 +1322,11 @@ void KMFilterActionRewriteHeader::clearP
Q_ASSERT( cb );
cb->setCurrentItem(0);
- QLineEdit *le = (QLineEdit*)paramWidget->child("search");
- Q_ASSERT( le );
- le->clear();
+ RegExpLineEdit *rele = (RegExpLineEdit*)paramWidget->child("search");
+ Q_ASSERT( rele );
+ rele->clear();
- le = (QLineEdit*)paramWidget->child("replace");
+ QLineEdit *le = (QLineEdit*)paramWidget->child("replace");
Q_ASSERT( le );
le->clear();
}
["rewrite_filter.png" (image/png)]
["identity_filter1.png" (image/png)]
[Attachment #10 (application/pgp-signature)]
_______________________________________________
KMail developers mailing list
KMail-devel@kde.org
https://mail.kde.org/mailman/listinfo/kmail-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic