fix errors found while translating
[kdepim.git] / kmail / rulewidgethandlermanager.cpp
blob1094db7807a53b6b2fbc8bff85a0d69faa624fa7
1 /* -*- mode: C++; c-file-style: "gnu" -*-
2 rulewidgethandlermanager.cpp
4 This file is part of KMail, the KDE mail client.
5 Copyright (c) 2004 Ingo Kloecker <kloecker@kde.org>
7 KMail is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 KMail is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 In addition, as a special exception, the copyright holders give
22 permission to link the code of this program with any edition of
23 the Qt library by Trolltech AS, Norway (or with modified versions
24 of Qt that use the same license as Qt), and distribute linked
25 combinations including the two. You must obey the GNU General
26 Public License in all respects for all of the code used other than
27 Qt. If you modify this file, you may extend this exception to
28 your version of the file, but you are not obligated to do so. If
29 you do not wish to do so, delete this exception statement from
30 your version.
34 #include "rulewidgethandlermanager.h"
36 #include "interfaces/rulewidgethandler.h"
37 #include "stl_util.h"
39 #include <kdebug.h>
40 #include <kiconloader.h>
42 #include <QStackedWidget>
43 #include <QString>
44 #include <QObject>
46 #include <assert.h>
48 #include <algorithm>
49 using std::for_each;
50 using std::remove;
52 KMail::RuleWidgetHandlerManager * KMail::RuleWidgetHandlerManager::self = 0;
54 namespace {
55 class TextRuleWidgetHandler : public KMail::RuleWidgetHandler {
56 public:
57 TextRuleWidgetHandler() : KMail::RuleWidgetHandler() {}
58 ~TextRuleWidgetHandler() {}
60 QWidget * createFunctionWidget( int number,
61 QStackedWidget *functionStack,
62 const QObject *receiver ) const;
63 QWidget * createValueWidget( int number,
64 QStackedWidget *valueStack,
65 const QObject *receiver ) const;
66 KMSearchRule::Function function( const QByteArray & field,
67 const QStackedWidget *functionStack ) const;
68 QString value( const QByteArray & field,
69 const QStackedWidget *functionStack,
70 const QStackedWidget *valueStack ) const;
71 QString prettyValue( const QByteArray & field,
72 const QStackedWidget *functionStack,
73 const QStackedWidget *valueStack ) const;
74 bool handlesField( const QByteArray & field ) const;
75 void reset( QStackedWidget *functionStack,
76 QStackedWidget *valueStack ) const;
77 bool setRule( QStackedWidget *functionStack,
78 QStackedWidget *valueStack,
79 const KMSearchRule *rule ) const;
80 bool update( const QByteArray & field,
81 QStackedWidget *functionStack,
82 QStackedWidget *valueStack ) const;
84 private:
85 KMSearchRule::Function currentFunction( const QStackedWidget *functionStack ) const;
86 QString currentValue( const QStackedWidget *valueStack,
87 KMSearchRule::Function func ) const;
90 class MessageRuleWidgetHandler : public KMail::RuleWidgetHandler {
91 public:
92 MessageRuleWidgetHandler() : KMail::RuleWidgetHandler() {}
93 ~MessageRuleWidgetHandler() {}
95 QWidget * createFunctionWidget( int number,
96 QStackedWidget *functionStack,
97 const QObject *receiver ) const;
98 QWidget * createValueWidget( int number,
99 QStackedWidget *valueStack,
100 const QObject *receiver ) const;
101 KMSearchRule::Function function( const QByteArray & field,
102 const QStackedWidget *functionStack ) const;
103 QString value( const QByteArray & field,
104 const QStackedWidget *functionStack,
105 const QStackedWidget *valueStack ) const;
106 QString prettyValue( const QByteArray & field,
107 const QStackedWidget *functionStack,
108 const QStackedWidget *valueStack ) const;
109 bool handlesField( const QByteArray & field ) const;
110 void reset( QStackedWidget *functionStack,
111 QStackedWidget *valueStack ) const;
112 bool setRule( QStackedWidget *functionStack,
113 QStackedWidget *valueStack,
114 const KMSearchRule *rule ) const;
115 bool update( const QByteArray & field,
116 QStackedWidget *functionStack,
117 QStackedWidget *valueStack ) const;
119 private:
120 KMSearchRule::Function currentFunction( const QStackedWidget *functionStack ) const;
121 QString currentValue( const QStackedWidget *valueStack,
122 KMSearchRule::Function func ) const;
126 class StatusRuleWidgetHandler : public KMail::RuleWidgetHandler {
127 public:
128 StatusRuleWidgetHandler() : KMail::RuleWidgetHandler() {}
129 ~StatusRuleWidgetHandler() {}
131 QWidget * createFunctionWidget( int number,
132 QStackedWidget *functionStack,
133 const QObject *receiver ) const;
134 QWidget * createValueWidget( int number,
135 QStackedWidget *valueStack,
136 const QObject *receiver ) const;
137 KMSearchRule::Function function( const QByteArray & field,
138 const QStackedWidget *functionStack ) const;
139 QString value( const QByteArray & field,
140 const QStackedWidget *functionStack,
141 const QStackedWidget *valueStack ) const;
142 QString prettyValue( const QByteArray & field,
143 const QStackedWidget *functionStack,
144 const QStackedWidget *valueStack ) const;
145 bool handlesField( const QByteArray & field ) const;
146 void reset( QStackedWidget *functionStack,
147 QStackedWidget *valueStack ) const;
148 bool setRule( QStackedWidget *functionStack,
149 QStackedWidget *valueStack,
150 const KMSearchRule *rule ) const;
151 bool update( const QByteArray & field,
152 QStackedWidget *functionStack,
153 QStackedWidget *valueStack ) const;
155 private:
156 KMSearchRule::Function currentFunction( const QStackedWidget *functionStack ) const;
157 int currentStatusValue( const QStackedWidget *valueStack ) const;
160 class NumericRuleWidgetHandler : public KMail::RuleWidgetHandler {
161 public:
162 NumericRuleWidgetHandler() : KMail::RuleWidgetHandler() {}
163 ~NumericRuleWidgetHandler() {}
165 QWidget * createFunctionWidget( int number,
166 QStackedWidget *functionStack,
167 const QObject *receiver ) const;
168 QWidget * createValueWidget( int number,
169 QStackedWidget *valueStack,
170 const QObject *receiver ) const;
171 KMSearchRule::Function function( const QByteArray & field,
172 const QStackedWidget *functionStack ) const;
173 QString value( const QByteArray & field,
174 const QStackedWidget *functionStack,
175 const QStackedWidget *valueStack ) const;
176 QString prettyValue( const QByteArray & field,
177 const QStackedWidget *functionStack,
178 const QStackedWidget *valueStack ) const;
179 bool handlesField( const QByteArray & field ) const;
180 void reset( QStackedWidget *functionStack,
181 QStackedWidget *valueStack ) const;
182 bool setRule( QStackedWidget *functionStack,
183 QStackedWidget *valueStack,
184 const KMSearchRule *rule ) const;
185 bool update( const QByteArray & field,
186 QStackedWidget *functionStack,
187 QStackedWidget *valueStack ) const;
189 private:
190 KMSearchRule::Function currentFunction( const QStackedWidget *functionStack ) const;
191 QString currentValue( const QStackedWidget *valueStack ) const;
195 KMail::RuleWidgetHandlerManager::RuleWidgetHandlerManager()
197 registerHandler( new NumericRuleWidgetHandler() );
198 registerHandler( new StatusRuleWidgetHandler() );
199 registerHandler( new MessageRuleWidgetHandler() );
200 // the TextRuleWidgetHandler is the fallback handler, so it has to be added
201 // as last handler
202 registerHandler( new TextRuleWidgetHandler() );
205 KMail::RuleWidgetHandlerManager::~RuleWidgetHandlerManager()
207 for_each( mHandlers.begin(), mHandlers.end(),
208 DeleteAndSetToZero<RuleWidgetHandler>() );
211 void KMail::RuleWidgetHandlerManager::registerHandler( const RuleWidgetHandler * handler )
213 if ( !handler )
214 return;
215 unregisterHandler( handler ); // don't produce duplicates
216 mHandlers.push_back( handler );
219 void KMail::RuleWidgetHandlerManager::unregisterHandler( const RuleWidgetHandler * handler )
221 // don't delete them, only remove them from the list!
222 mHandlers.erase( remove( mHandlers.begin(), mHandlers.end(), handler ), mHandlers.end() );
225 namespace {
226 /** Returns the number of immediate children of parent with the given object
227 name. Used by RuleWidgetHandlerManager::createWidgets().
229 int childCount( const QObject *parent, const QString &objName )
231 QObjectList list = parent->children();
232 QObject *item;
233 int count = 0;
234 foreach( item, list ) {
235 if ( item->objectName() == objName )
236 count++;
238 return count;
242 void KMail::RuleWidgetHandlerManager::createWidgets( QStackedWidget *functionStack,
243 QStackedWidget *valueStack,
244 const QObject *receiver ) const
246 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
247 QWidget *w = 0;
248 for ( int i = 0;
249 ( w = (*it)->createFunctionWidget( i, functionStack, receiver ) );
250 ++i ) {
251 if ( childCount( functionStack, w->objectName() ) < 2 ) {
252 // there wasn't already a widget with this name, so add this widget
253 functionStack->addWidget( w );
255 else {
256 // there was already a widget with this name, so discard this widget
257 kDebug(5006) << w->objectName() << "already exists in functionStack";
258 delete w; w = 0;
261 for ( int i = 0;
262 ( w = (*it)->createValueWidget( i, valueStack, receiver ) );
263 ++i ) {
264 if ( childCount( valueStack, w->objectName() ) < 2 ) {
265 // there wasn't already a widget with this name, so add this widget
266 valueStack->addWidget( w );
268 else {
269 // there was already a widget with this name, so discard this widget
270 kDebug(5006) << w->objectName() << "already exists in valueStack";
271 delete w; w = 0;
277 KMSearchRule::Function KMail::RuleWidgetHandlerManager::function( const QByteArray& field,
278 const QStackedWidget *functionStack ) const
280 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
281 const KMSearchRule::Function func = (*it)->function( field,
282 functionStack );
283 if ( func != KMSearchRule::FuncNone )
284 return func;
286 return KMSearchRule::FuncNone;
289 QString KMail::RuleWidgetHandlerManager::value( const QByteArray& field,
290 const QStackedWidget *functionStack,
291 const QStackedWidget *valueStack ) const
293 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
294 const QString val = (*it)->value( field, functionStack, valueStack );
295 if ( !val.isEmpty() )
296 return val;
298 return QString();
301 QString KMail::RuleWidgetHandlerManager::prettyValue( const QByteArray& field,
302 const QStackedWidget *functionStack,
303 const QStackedWidget *valueStack ) const
305 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
306 const QString val = (*it)->prettyValue( field, functionStack, valueStack );
307 if ( !val.isEmpty() )
308 return val;
310 return QString();
313 void KMail::RuleWidgetHandlerManager::reset( QStackedWidget *functionStack,
314 QStackedWidget *valueStack ) const
316 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
317 (*it)->reset( functionStack, valueStack );
319 update( "", functionStack, valueStack );
322 void KMail::RuleWidgetHandlerManager::setRule( QStackedWidget *functionStack,
323 QStackedWidget *valueStack,
324 const KMSearchRule *rule ) const
326 assert( rule );
327 reset( functionStack, valueStack );
328 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
329 if ( (*it)->setRule( functionStack, valueStack, rule ) )
330 return;
334 void KMail::RuleWidgetHandlerManager::update( const QByteArray &field,
335 QStackedWidget *functionStack,
336 QStackedWidget *valueStack ) const
338 //kDebug(5006) << "( \"" << field
339 // << "\", ... )";
340 for ( const_iterator it = mHandlers.begin(); it != mHandlers.end(); ++it ) {
341 if ( (*it)->update( field, functionStack, valueStack ) )
342 return;
346 //-----------------------------------------------------------------------------
348 // these includes are temporary and should not be needed for the code
349 // above this line, so they appear only here:
350 #include "kmaddrbook.h"
351 #include "kmsearchpattern.h"
352 #include "regexplineedit.h"
353 using KMail::RegExpLineEdit;
355 #include <kcombobox.h>
356 #include <klocale.h>
357 #include <knuminput.h>
359 #include <QLabel>
361 //=============================================================================
363 // class TextRuleWidgetHandler
365 //=============================================================================
367 namespace {
368 // also see KMSearchRule::matches() and KMSearchRule::Function
369 // if you change the following strings!
370 static const struct {
371 const KMSearchRule::Function id;
372 const char *displayName;
373 } TextFunctions[] = {
374 { KMSearchRule::FuncContains, I18N_NOOP( "contains" ) },
375 { KMSearchRule::FuncContainsNot, I18N_NOOP( "does not contain" ) },
376 { KMSearchRule::FuncEquals, I18N_NOOP( "equals" ) },
377 { KMSearchRule::FuncNotEqual, I18N_NOOP( "does not equal" ) },
378 { KMSearchRule::FuncRegExp, I18N_NOOP( "matches regular expr." ) },
379 { KMSearchRule::FuncNotRegExp, I18N_NOOP( "does not match reg. expr." ) },
380 { KMSearchRule::FuncIsInAddressbook, I18N_NOOP( "is in address book" ) },
381 { KMSearchRule::FuncIsNotInAddressbook, I18N_NOOP( "is not in address book" ) },
382 { KMSearchRule::FuncIsInCategory, I18N_NOOP( "is in category" ) },
383 { KMSearchRule::FuncIsNotInCategory, I18N_NOOP( "is not in category" ) }
385 static const int TextFunctionCount =
386 sizeof( TextFunctions ) / sizeof( *TextFunctions );
388 //---------------------------------------------------------------------------
390 QWidget * TextRuleWidgetHandler::createFunctionWidget( int number,
391 QStackedWidget *functionStack,
392 const QObject *receiver ) const
394 if ( number != 0 )
395 return 0;
397 KComboBox *funcCombo = new KComboBox( functionStack );
398 funcCombo->setObjectName( "textRuleFuncCombo" );
399 for ( int i = 0; i < TextFunctionCount; ++i ) {
400 funcCombo->addItem( i18n( TextFunctions[i].displayName ) );
402 funcCombo->adjustSize();
403 QObject::connect( funcCombo, SIGNAL( activated( int ) ),
404 receiver, SLOT( slotFunctionChanged() ) );
405 return funcCombo;
408 //---------------------------------------------------------------------------
410 QWidget * TextRuleWidgetHandler::createValueWidget( int number,
411 QStackedWidget *valueStack,
412 const QObject *receiver ) const
414 if ( number == 0 ) {
415 RegExpLineEdit *lineEdit =
416 new RegExpLineEdit( valueStack );
417 lineEdit->setObjectName( "regExpLineEdit" );
418 QObject::connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
419 receiver, SLOT( slotValueChanged() ) );
420 return lineEdit;
423 // blank QLabel to hide value widget for in-address-book rule
424 if ( number == 1 ) {
425 QLabel *label = new QLabel( valueStack );
426 label->setObjectName( "textRuleValueHider" );
427 label->setBuddy( valueStack );
428 return label;
431 if ( number == 2 ) {
432 KComboBox *combo = new KComboBox( valueStack );
433 combo->setObjectName( "categoryCombo" );
434 QStringList categories = KabcBridge::categories();
435 combo->addItems( categories );
436 QObject::connect( combo, SIGNAL( activated( int ) ),
437 receiver, SLOT( slotValueChanged() ) );
438 return combo;
441 return 0;
444 //---------------------------------------------------------------------------
446 KMSearchRule::Function TextRuleWidgetHandler::currentFunction( const QStackedWidget *functionStack ) const
448 const KComboBox *funcCombo =
449 functionStack->findChild<KComboBox*>( QString( "textRuleFuncCombo" ) );
451 if ( funcCombo && funcCombo->currentIndex() >= 0) {
452 return TextFunctions[funcCombo->currentIndex()].id;
454 else
455 kDebug(5006) << "textRuleFuncCombo not found.";
456 return KMSearchRule::FuncNone;
459 //---------------------------------------------------------------------------
461 KMSearchRule::Function TextRuleWidgetHandler::function( const QByteArray &,
462 const QStackedWidget *functionStack ) const
464 return currentFunction( functionStack );
467 //---------------------------------------------------------------------------
469 QString TextRuleWidgetHandler::currentValue( const QStackedWidget *valueStack,
470 KMSearchRule::Function func ) const
472 // here we gotta check the combobox which contains the categories
473 if ( func == KMSearchRule::FuncIsInCategory ||
474 func == KMSearchRule::FuncIsNotInCategory ) {
475 const KComboBox *combo = valueStack->findChild<KComboBox*>( "categoryCombo" );
477 if ( combo ) {
478 return combo->currentText();
480 else {
481 kDebug(5006) << "categoryCombo not found.";
482 return QString();
486 //in other cases of func it is a lineedit
487 const RegExpLineEdit *lineEdit = valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
489 if ( lineEdit ) {
490 return lineEdit->text();
492 else
493 kDebug(5006) << "regExpLineEdit not found.";
495 // or anything else, like addressbook
496 return QString();
499 //---------------------------------------------------------------------------
501 QString TextRuleWidgetHandler::value( const QByteArray &,
502 const QStackedWidget *functionStack,
503 const QStackedWidget *valueStack ) const
505 KMSearchRule::Function func = currentFunction( functionStack );
506 if ( func == KMSearchRule::FuncIsInAddressbook )
507 return "is in address book"; // just a non-empty dummy value
508 else if ( func == KMSearchRule::FuncIsNotInAddressbook )
509 return "is not in address book"; // just a non-empty dummy value
510 else
511 return currentValue( valueStack, func );
514 //---------------------------------------------------------------------------
516 QString TextRuleWidgetHandler::prettyValue( const QByteArray &,
517 const QStackedWidget *functionStack,
518 const QStackedWidget *valueStack ) const
520 KMSearchRule::Function func = currentFunction( functionStack );
521 if ( func == KMSearchRule::FuncIsInAddressbook )
522 return i18n( "is in address book" );
523 else if ( func == KMSearchRule::FuncIsNotInAddressbook )
524 return i18n( "is not in address book" );
525 else
526 return currentValue( valueStack, func );
529 //---------------------------------------------------------------------------
531 bool TextRuleWidgetHandler::handlesField( const QByteArray & ) const
533 return true; // we handle all fields (as fallback)
536 //---------------------------------------------------------------------------
538 void TextRuleWidgetHandler::reset( QStackedWidget *functionStack,
539 QStackedWidget *valueStack ) const
542 // reset the function combo box
543 KComboBox *funcCombo =
544 functionStack->findChild<KComboBox*>( "textRuleFuncCombo" );
546 if ( funcCombo ) {
547 funcCombo->blockSignals( true );
548 funcCombo->setCurrentIndex( 0 );
549 funcCombo->blockSignals( false );
552 // reset the value widget
553 RegExpLineEdit *lineEdit =
554 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit");
555 if ( lineEdit ) {
556 lineEdit->blockSignals( true );
557 lineEdit->clear();
558 lineEdit->blockSignals( false );
559 lineEdit->showEditButton( false );
560 valueStack->setCurrentWidget( lineEdit );
563 KComboBox *combo =
564 valueStack->findChild<KComboBox*>( "categoryCombo" );
566 if (combo) {
567 combo->blockSignals( true );
568 combo->setCurrentIndex( 0 );
569 combo->blockSignals( false );
573 //---------------------------------------------------------------------------
575 bool TextRuleWidgetHandler::setRule( QStackedWidget *functionStack,
576 QStackedWidget *valueStack,
577 const KMSearchRule *rule ) const
580 if ( !rule ) {
581 reset( functionStack, valueStack );
582 return false;
585 const KMSearchRule::Function func = rule->function();
586 int i = 0;
587 for ( ; i < TextFunctionCount; ++i )
588 if ( func == TextFunctions[i].id )
589 break;
590 KComboBox *funcCombo =
591 functionStack->findChild<KComboBox*>( "textRuleFuncCombo" );
593 if ( funcCombo ) {
594 funcCombo->blockSignals( true );
595 if ( i < TextFunctionCount )
596 funcCombo->setCurrentIndex( i );
597 else {
598 kDebug(5006) << "(" << rule->asString() << "): unhandled function";
599 funcCombo->setCurrentIndex( 0 );
601 funcCombo->blockSignals( false );
602 functionStack->setCurrentWidget( funcCombo );
605 if ( func == KMSearchRule::FuncIsInAddressbook ||
606 func == KMSearchRule::FuncIsNotInAddressbook ) {
607 QWidget *w =
608 valueStack->findChild<QWidget*>( "textRuleValueHider");
609 valueStack->setCurrentWidget( w );
611 else if ( func == KMSearchRule::FuncIsInCategory ||
612 func == KMSearchRule::FuncIsNotInCategory) {
613 KComboBox *combo =
614 valueStack->findChild<KComboBox*>( "categoryCombo" );
616 combo->blockSignals( true );
617 for ( i = 0; i < combo->count(); ++i )
618 if ( rule->contents() == combo->itemText( i ) ) {
619 combo->setCurrentIndex( i );
620 break;
622 if ( i == combo->count() )
623 combo->setCurrentIndex( 0 );
625 combo->blockSignals( false );
626 valueStack->setCurrentWidget( combo );
628 else {
629 RegExpLineEdit *lineEdit =
630 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
632 if ( lineEdit ) {
633 lineEdit->blockSignals( true );
634 lineEdit->setText( rule->contents() );
635 lineEdit->blockSignals( false );
636 lineEdit->showEditButton( func == KMSearchRule::FuncRegExp ||
637 func == KMSearchRule::FuncNotRegExp );
638 valueStack->setCurrentWidget( lineEdit );
641 return true;
645 //---------------------------------------------------------------------------
647 bool TextRuleWidgetHandler::update( const QByteArray &,
648 QStackedWidget *functionStack,
649 QStackedWidget *valueStack ) const
651 // raise the correct function widget
652 functionStack->setCurrentWidget(
653 functionStack->findChild<QWidget*>( "textRuleFuncCombo" ));
655 // raise the correct value widget
656 KMSearchRule::Function func = currentFunction( functionStack );
657 if ( func == KMSearchRule::FuncIsInAddressbook ||
658 func == KMSearchRule::FuncIsNotInAddressbook ) {
659 valueStack->setCurrentWidget(
660 valueStack->findChild<QWidget*>( "textRuleValueHider" ));
662 else if ( func == KMSearchRule::FuncIsInCategory ||
663 func == KMSearchRule::FuncIsNotInCategory) {
664 valueStack->setCurrentWidget(
665 valueStack->findChild<QWidget*>( "categoryCombo" ));
667 else {
668 RegExpLineEdit *lineEdit =
669 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
671 if ( lineEdit ) {
672 lineEdit->showEditButton( func == KMSearchRule::FuncRegExp ||
673 func == KMSearchRule::FuncNotRegExp );
674 valueStack->setCurrentWidget( lineEdit );
677 return true;
680 } // anonymous namespace for TextRuleWidgetHandler
683 //=============================================================================
685 // class MessageRuleWidgetHandler
687 //=============================================================================
689 namespace {
690 // also see KMSearchRule::matches() and KMSearchRule::Function
691 // if you change the following strings!
692 static const struct {
693 const KMSearchRule::Function id;
694 const char *displayName;
695 } MessageFunctions[] = {
696 { KMSearchRule::FuncContains, I18N_NOOP( "contains" ) },
697 { KMSearchRule::FuncContainsNot, I18N_NOOP( "does not contain" ) },
698 { KMSearchRule::FuncRegExp, I18N_NOOP( "matches regular expr." ) },
699 { KMSearchRule::FuncNotRegExp, I18N_NOOP( "does not match reg. expr." ) },
700 { KMSearchRule::FuncHasAttachment, I18N_NOOP( "has an attachment" ) },
701 { KMSearchRule::FuncHasNoAttachment, I18N_NOOP( "has no attachment" ) },
703 static const int MessageFunctionCount =
704 sizeof( MessageFunctions ) / sizeof( *MessageFunctions );
706 //---------------------------------------------------------------------------
708 QWidget * MessageRuleWidgetHandler::createFunctionWidget( int number,
709 QStackedWidget *functionStack,
710 const QObject *receiver ) const
712 if ( number != 0 )
713 return 0;
715 KComboBox *funcCombo = new KComboBox( functionStack );
716 funcCombo->setObjectName( "messageRuleFuncCombo" );
717 for ( int i = 0; i < MessageFunctionCount; ++i ) {
718 funcCombo->addItem( i18n( MessageFunctions[i].displayName ) );
720 funcCombo->adjustSize();
721 QObject::connect( funcCombo, SIGNAL( activated( int ) ),
722 receiver, SLOT( slotFunctionChanged() ) );
723 return funcCombo;
726 //---------------------------------------------------------------------------
728 QWidget * MessageRuleWidgetHandler::createValueWidget( int number,
729 QStackedWidget *valueStack,
730 const QObject *receiver ) const
732 if ( number == 0 ) {
733 RegExpLineEdit *lineEdit =
734 new RegExpLineEdit( valueStack );
735 lineEdit->setObjectName( "regExpLineEdit" );
736 QObject::connect( lineEdit, SIGNAL( textChanged( const QString & ) ),
737 receiver, SLOT( slotValueChanged() ) );
738 return lineEdit;
741 // blank QLabel to hide value widget for has-attachment rule
742 if ( number == 1 ) {
743 QLabel *label = new QLabel( valueStack );
744 label->setObjectName( "textRuleValueHider" );
745 label->setBuddy( valueStack );
746 return label;
749 return 0;
752 //---------------------------------------------------------------------------
754 KMSearchRule::Function MessageRuleWidgetHandler::currentFunction( const QStackedWidget *functionStack ) const
756 const KComboBox *funcCombo = functionStack->findChild<KComboBox*>( "messageRuleFuncCombo" );
758 if ( funcCombo && funcCombo->currentIndex() >= 0) {
759 return MessageFunctions[funcCombo->currentIndex()].id;
761 else
762 kDebug(5006) << "messageRuleFuncCombo not found.";
763 return KMSearchRule::FuncNone;
766 //---------------------------------------------------------------------------
768 KMSearchRule::Function MessageRuleWidgetHandler::function( const QByteArray & field,
769 const QStackedWidget *functionStack ) const
771 if ( !handlesField( field ) )
772 return KMSearchRule::FuncNone;
774 return currentFunction( functionStack );
777 //---------------------------------------------------------------------------
779 QString MessageRuleWidgetHandler::currentValue( const QStackedWidget *valueStack,
780 KMSearchRule::Function ) const
782 const RegExpLineEdit *lineEdit
783 = valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
785 if ( lineEdit ) {
786 return lineEdit->text();
788 else
789 kDebug(5006) << "regExpLineEdit not found.";
791 return QString();
794 //---------------------------------------------------------------------------
796 QString MessageRuleWidgetHandler::value( const QByteArray & field,
797 const QStackedWidget *functionStack,
798 const QStackedWidget *valueStack ) const
800 if ( !handlesField( field ) )
801 return QString();
803 KMSearchRule::Function func = currentFunction( functionStack );
804 if ( func == KMSearchRule::FuncHasAttachment )
805 return "has an attachment"; // just a non-empty dummy value
806 else if ( func == KMSearchRule::FuncHasNoAttachment )
807 return "has no attachment"; // just a non-empty dummy value
808 else
809 return currentValue( valueStack, func );
812 //---------------------------------------------------------------------------
814 QString MessageRuleWidgetHandler::prettyValue( const QByteArray & field,
815 const QStackedWidget *functionStack,
816 const QStackedWidget *valueStack ) const
818 if ( !handlesField( field ) )
819 return QString();
821 KMSearchRule::Function func = currentFunction( functionStack );
822 if ( func == KMSearchRule::FuncHasAttachment )
823 return i18n( "has an attachment" );
824 else if ( func == KMSearchRule::FuncHasNoAttachment )
825 return i18n( "has no attachment" );
826 else
827 return currentValue( valueStack, func );
830 //---------------------------------------------------------------------------
832 bool MessageRuleWidgetHandler::handlesField( const QByteArray & field ) const
834 return ( field == "<message>" );
837 //---------------------------------------------------------------------------
839 void MessageRuleWidgetHandler::reset( QStackedWidget *functionStack,
840 QStackedWidget *valueStack ) const
842 // reset the function combo box
843 KComboBox *funcCombo =
844 functionStack->findChild<KComboBox*>( "messageRuleFuncCombo" );
846 if ( funcCombo ) {
847 funcCombo->blockSignals( true );
848 funcCombo->setCurrentIndex( 0 );
849 funcCombo->blockSignals( false );
852 // reset the value widget
853 RegExpLineEdit *lineEdit =
854 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
856 if ( lineEdit ) {
857 lineEdit->blockSignals( true );
858 lineEdit->clear();
859 lineEdit->blockSignals( false );
860 lineEdit->showEditButton( false );
861 valueStack->setCurrentWidget( lineEdit );
865 //---------------------------------------------------------------------------
867 bool MessageRuleWidgetHandler::setRule( QStackedWidget *functionStack,
868 QStackedWidget *valueStack,
869 const KMSearchRule *rule ) const
871 if ( !rule || !handlesField( rule->field() ) ) {
872 reset( functionStack, valueStack );
873 return false;
876 const KMSearchRule::Function func = rule->function();
877 int i = 0;
878 for ( ; i < MessageFunctionCount; ++i )
879 if ( func == MessageFunctions[i].id )
880 break;
881 KComboBox *funcCombo =
882 functionStack->findChild<KComboBox*>( "messageRuleFuncCombo" );
884 if ( funcCombo ) {
885 funcCombo->blockSignals( true );
886 if ( i < MessageFunctionCount )
887 funcCombo->setCurrentIndex( i );
888 else {
889 kDebug(5006) << "(" << rule->asString() << "): unhandled function";
890 funcCombo->setCurrentIndex( 0 );
892 funcCombo->blockSignals( false );
893 functionStack->setCurrentWidget( funcCombo );
896 if ( func == KMSearchRule::FuncHasAttachment ||
897 func == KMSearchRule::FuncHasNoAttachment ) {
898 QWidget *w =
899 valueStack->findChild<QWidget*>( "textRuleValueHider" );
901 valueStack->setCurrentWidget( w );
903 else {
904 RegExpLineEdit *lineEdit =
905 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
907 if ( lineEdit ) {
908 lineEdit->blockSignals( true );
909 lineEdit->setText( rule->contents() );
910 lineEdit->blockSignals( false );
911 lineEdit->showEditButton( func == KMSearchRule::FuncRegExp ||
912 func == KMSearchRule::FuncNotRegExp );
913 valueStack->setCurrentWidget( lineEdit );
916 return true;
920 //---------------------------------------------------------------------------
922 bool MessageRuleWidgetHandler::update( const QByteArray & field,
923 QStackedWidget *functionStack,
924 QStackedWidget *valueStack ) const
926 if ( !handlesField( field ) )
927 return false;
928 // raise the correct function widget
929 functionStack->setCurrentWidget(
930 functionStack->findChild<QWidget*>( "messageRuleFuncCombo" ));
932 // raise the correct value widget
933 KMSearchRule::Function func = currentFunction( functionStack );
934 if ( func == KMSearchRule::FuncHasAttachment ||
935 func == KMSearchRule::FuncHasNoAttachment ) {
936 QWidget *w = valueStack->findChild<QWidget*>( "textRuleValueHider" );
938 valueStack->setCurrentWidget( w );
940 else {
941 RegExpLineEdit *lineEdit =
942 valueStack->findChild<RegExpLineEdit*>( "regExpLineEdit" );
944 if ( lineEdit ) {
945 lineEdit->showEditButton( func == KMSearchRule::FuncRegExp ||
946 func == KMSearchRule::FuncNotRegExp );
947 valueStack->setCurrentWidget( lineEdit );
950 return true;
953 } // anonymous namespace for MessageRuleWidgetHandler
956 //=============================================================================
958 // class StatusRuleWidgetHandler
960 //=============================================================================
962 namespace {
963 static const struct {
964 const KMSearchRule::Function id;
965 const char *displayName;
966 } StatusFunctions[] = {
967 { KMSearchRule::FuncContains, I18N_NOOP( "is" ) },
968 { KMSearchRule::FuncContainsNot, I18N_NOOP( "is not" ) }
970 static const int StatusFunctionCount =
971 sizeof( StatusFunctions ) / sizeof( *StatusFunctions );
973 //---------------------------------------------------------------------------
975 QWidget * StatusRuleWidgetHandler::createFunctionWidget( int number,
976 QStackedWidget *functionStack,
977 const QObject *receiver ) const
979 if ( number != 0 )
980 return 0;
982 KComboBox *funcCombo = new KComboBox( functionStack );
983 funcCombo->setObjectName( "statusRuleFuncCombo" );
984 for ( int i = 0; i < StatusFunctionCount; ++i ) {
985 funcCombo->addItem( i18n( StatusFunctions[i].displayName ) );
987 funcCombo->adjustSize();
988 QObject::connect( funcCombo, SIGNAL( activated( int ) ),
989 receiver, SLOT( slotFunctionChanged() ) );
990 return funcCombo;
993 //---------------------------------------------------------------------------
995 QWidget * StatusRuleWidgetHandler::createValueWidget( int number,
996 QStackedWidget *valueStack,
997 const QObject *receiver ) const
999 if ( number != 0 )
1000 return 0;
1002 KComboBox *statusCombo = new KComboBox( valueStack );
1003 statusCombo->setObjectName( "statusRuleValueCombo" );
1004 for ( int i = 0; i < KMail::StatusValueCountWithoutHidden; ++i ) {
1005 if ( KMail::StatusValues[ i ].icon != 0 )
1006 statusCombo->addItem( SmallIcon( KMail::StatusValues[ i ].icon ),
1007 i18nc("message status", KMail::StatusValues[ i ].text ) );
1008 else
1009 statusCombo->addItem( i18nc("message status", KMail::StatusValues[ i ].text ) );
1011 statusCombo->adjustSize();
1012 QObject::connect( statusCombo, SIGNAL( activated( int ) ),
1013 receiver, SLOT( slotValueChanged() ) );
1014 return statusCombo;
1017 //---------------------------------------------------------------------------
1019 KMSearchRule::Function StatusRuleWidgetHandler::currentFunction( const QStackedWidget *functionStack ) const
1021 const KComboBox *funcCombo = functionStack->findChild<KComboBox*>( "statusRuleFuncCombo" );
1023 if ( funcCombo && funcCombo->currentIndex() >= 0) {
1024 return StatusFunctions[funcCombo->currentIndex()].id;
1026 else
1027 kDebug(5006) << "statusRuleFuncCombo not found.";
1028 return KMSearchRule::FuncNone;
1031 //---------------------------------------------------------------------------
1033 KMSearchRule::Function StatusRuleWidgetHandler::function( const QByteArray & field,
1034 const QStackedWidget *functionStack ) const
1036 if ( !handlesField( field ) )
1037 return KMSearchRule::FuncNone;
1039 return currentFunction( functionStack );
1042 //---------------------------------------------------------------------------
1044 int StatusRuleWidgetHandler::currentStatusValue( const QStackedWidget *valueStack ) const
1046 const KComboBox *statusCombo = valueStack->findChild<KComboBox*>( "statusRuleValueCombo" );
1048 if ( statusCombo ) {
1049 return statusCombo->currentIndex();
1051 else
1052 kDebug(5006) << "statusRuleValueCombo not found.";
1053 return -1;
1056 //---------------------------------------------------------------------------
1058 QString StatusRuleWidgetHandler::value( const QByteArray & field,
1059 const QStackedWidget *,
1060 const QStackedWidget *valueStack ) const
1062 if ( !handlesField( field ) )
1063 return QString();
1065 const int status = currentStatusValue( valueStack );
1066 if ( status != -1 )
1067 return QString::fromLatin1( KMail::StatusValues[ status ].text );
1068 else
1069 return QString();
1072 //---------------------------------------------------------------------------
1074 QString StatusRuleWidgetHandler::prettyValue( const QByteArray & field,
1075 const QStackedWidget *,
1076 const QStackedWidget *valueStack ) const
1078 if ( !handlesField( field ) )
1079 return QString();
1081 const int status = currentStatusValue( valueStack );
1082 if ( status != -1 )
1083 return i18nc( "message status", KMail::StatusValues[ status ].text );
1084 else
1085 return QString();
1088 //---------------------------------------------------------------------------
1090 bool StatusRuleWidgetHandler::handlesField( const QByteArray & field ) const
1092 return ( field == "<status>" );
1095 //---------------------------------------------------------------------------
1097 void StatusRuleWidgetHandler::reset( QStackedWidget *functionStack,
1098 QStackedWidget *valueStack ) const
1100 // reset the function combo box
1101 KComboBox *funcCombo =
1102 functionStack->findChild<KComboBox*>( "statusRuleFuncCombo" );
1104 if ( funcCombo ) {
1105 funcCombo->blockSignals( true );
1106 funcCombo->setCurrentIndex( 0 );
1107 funcCombo->blockSignals( false );
1110 // reset the status value combo box
1111 KComboBox *statusCombo =
1112 valueStack->findChild<KComboBox*>( "statusRuleValueCombo" );
1114 if ( statusCombo ) {
1115 statusCombo->blockSignals( true );
1116 statusCombo->setCurrentIndex( 0 );
1117 statusCombo->blockSignals( false );
1121 //---------------------------------------------------------------------------
1123 bool StatusRuleWidgetHandler::setRule( QStackedWidget *functionStack,
1124 QStackedWidget *valueStack,
1125 const KMSearchRule *rule ) const
1127 if ( !rule || !handlesField( rule->field() ) ) {
1128 reset( functionStack, valueStack );
1129 return false;
1132 // set the function
1133 const KMSearchRule::Function func = rule->function();
1134 int funcIndex = 0;
1135 for ( ; funcIndex < StatusFunctionCount; ++funcIndex )
1136 if ( func == StatusFunctions[funcIndex].id )
1137 break;
1138 KComboBox *funcCombo =
1139 functionStack->findChild<KComboBox*>( "statusRuleFuncCombo" );
1141 if ( funcCombo ) {
1142 funcCombo->blockSignals( true );
1143 if ( funcIndex < StatusFunctionCount )
1144 funcCombo->setCurrentIndex( funcIndex );
1145 else {
1146 kDebug(5006) << "(" << rule->asString() << "): unhandled function";
1147 funcCombo->setCurrentIndex( 0 );
1149 funcCombo->blockSignals( false );
1150 functionStack->setCurrentWidget( funcCombo );
1153 // set the value
1154 const QString value = rule->contents();
1155 int valueIndex = 0;
1156 for ( ; valueIndex < KMail::StatusValueCountWithoutHidden; ++valueIndex )
1157 if ( value == QString::fromLatin1(
1158 KMail::StatusValues[ valueIndex ].text ) )
1159 break;
1160 KComboBox *statusCombo =
1161 valueStack->findChild<KComboBox*>( "statusRuleValueCombo" );
1163 if ( statusCombo ) {
1164 statusCombo->blockSignals( true );
1165 if ( valueIndex < KMail::StatusValueCountWithoutHidden )
1166 statusCombo->setCurrentIndex( valueIndex );
1167 else {
1168 kDebug(5006) << "(" << rule->asString() << "): unhandled value";
1169 statusCombo->setCurrentIndex( 0 );
1171 statusCombo->blockSignals( false );
1172 valueStack->setCurrentWidget( statusCombo );
1174 return true;
1178 //---------------------------------------------------------------------------
1180 bool StatusRuleWidgetHandler::update( const QByteArray &field,
1181 QStackedWidget *functionStack,
1182 QStackedWidget *valueStack ) const
1184 if ( !handlesField( field ) )
1185 return false;
1187 // raise the correct function widget
1188 functionStack->setCurrentWidget(
1189 functionStack->findChild<QWidget*>( "statusRuleFuncCombo" ));
1191 // raise the correct value widget
1192 valueStack->setCurrentWidget(
1193 valueStack->findChild<QWidget*>( "statusRuleValueCombo" ));
1195 return true;
1198 } // anonymous namespace for StatusRuleWidgetHandler
1201 //=============================================================================
1203 // class NumericRuleWidgetHandler
1205 //=============================================================================
1207 namespace {
1208 static const struct {
1209 const KMSearchRule::Function id;
1210 const char *displayName;
1211 } NumericFunctions[] = {
1212 { KMSearchRule::FuncEquals, I18N_NOOP( "is equal to" ) },
1213 { KMSearchRule::FuncNotEqual, I18N_NOOP( "is not equal to" ) },
1214 { KMSearchRule::FuncIsGreater, I18N_NOOP( "is greater than" ) },
1215 { KMSearchRule::FuncIsLessOrEqual, I18N_NOOP( "is less than or equal to" ) },
1216 { KMSearchRule::FuncIsLess, I18N_NOOP( "is less than" ) },
1217 { KMSearchRule::FuncIsGreaterOrEqual, I18N_NOOP( "is greater than or equal to" ) }
1219 static const int NumericFunctionCount =
1220 sizeof( NumericFunctions ) / sizeof( *NumericFunctions );
1222 //---------------------------------------------------------------------------
1224 QWidget * NumericRuleWidgetHandler::createFunctionWidget( int number,
1225 QStackedWidget *functionStack,
1226 const QObject *receiver ) const
1228 if ( number != 0 )
1229 return 0;
1231 KComboBox *funcCombo = new KComboBox( functionStack );
1232 funcCombo->setObjectName( "numericRuleFuncCombo" );
1233 for ( int i = 0; i < NumericFunctionCount; ++i ) {
1234 funcCombo->addItem( i18n( NumericFunctions[i].displayName ) );
1236 funcCombo->adjustSize();
1237 QObject::connect( funcCombo, SIGNAL( activated( int ) ),
1238 receiver, SLOT( slotFunctionChanged() ) );
1239 return funcCombo;
1242 //---------------------------------------------------------------------------
1244 QWidget * NumericRuleWidgetHandler::createValueWidget( int number,
1245 QStackedWidget *valueStack,
1246 const QObject *receiver ) const
1248 if ( number != 0 )
1249 return 0;
1251 KIntNumInput *numInput = new KIntNumInput( valueStack );
1252 numInput->setSliderEnabled( false );
1253 numInput->setObjectName( "KIntNumInput" );
1254 QObject::connect( numInput, SIGNAL( valueChanged( int ) ),
1255 receiver, SLOT( slotValueChanged() ) );
1256 return numInput;
1259 //---------------------------------------------------------------------------
1261 KMSearchRule::Function NumericRuleWidgetHandler::currentFunction( const QStackedWidget *functionStack ) const
1263 const KComboBox *funcCombo = functionStack->findChild<KComboBox*>( "numericRuleFuncCombo" );
1265 if ( funcCombo && funcCombo->currentIndex() >= 0 ) {
1266 return NumericFunctions[funcCombo->currentIndex()].id;
1268 else
1269 kDebug(5006) << "numericRuleFuncCombo not found.";
1270 return KMSearchRule::FuncNone;
1273 //---------------------------------------------------------------------------
1275 KMSearchRule::Function NumericRuleWidgetHandler::function( const QByteArray & field,
1276 const QStackedWidget *functionStack ) const
1278 if ( !handlesField( field ) )
1279 return KMSearchRule::FuncNone;
1281 return currentFunction( functionStack );
1284 //---------------------------------------------------------------------------
1286 QString NumericRuleWidgetHandler::currentValue( const QStackedWidget *valueStack ) const
1288 const KIntNumInput *numInput = valueStack->findChild<KIntNumInput*>( "KIntNumInput" );
1290 if ( numInput ) {
1291 return QString::number( numInput->value() );
1293 else
1294 kDebug(5006) << "KIntNumInput not found.";
1295 return QString();
1298 //---------------------------------------------------------------------------
1300 QString NumericRuleWidgetHandler::value( const QByteArray & field,
1301 const QStackedWidget *,
1302 const QStackedWidget *valueStack ) const
1304 if ( !handlesField( field ) )
1305 return QString();
1307 return currentValue( valueStack );
1310 //---------------------------------------------------------------------------
1312 QString NumericRuleWidgetHandler::prettyValue( const QByteArray & field,
1313 const QStackedWidget *,
1314 const QStackedWidget *valueStack ) const
1316 if ( !handlesField( field ) )
1317 return QString();
1319 return currentValue( valueStack );
1322 //---------------------------------------------------------------------------
1324 bool NumericRuleWidgetHandler::handlesField( const QByteArray & field ) const
1326 return ( field == "<size>" || field == "<age in days>" );
1329 //---------------------------------------------------------------------------
1331 void NumericRuleWidgetHandler::reset( QStackedWidget *functionStack,
1332 QStackedWidget *valueStack ) const
1334 // reset the function combo box
1335 KComboBox *funcCombo =
1336 functionStack->findChild<KComboBox*>( "numericRuleFuncCombo" );
1338 if ( funcCombo ) {
1339 funcCombo->blockSignals( true );
1340 funcCombo->setCurrentIndex( 0 );
1341 funcCombo->blockSignals( false );
1344 // reset the value widget
1345 KIntNumInput *numInput =
1346 valueStack->findChild<KIntNumInput*>( "KIntNumInput" );
1348 if ( numInput ) {
1349 numInput->blockSignals( true );
1350 numInput->setValue( 0 );
1351 numInput->blockSignals( false );
1355 //---------------------------------------------------------------------------
1357 void initNumInput( KIntNumInput *numInput, const QByteArray &field )
1359 if ( field == "<size>" ) {
1360 numInput->setMinimum( 0 );
1361 numInput->setSuffix( i18n( " bytes" ) );
1362 numInput->setSliderEnabled( false );
1364 else {
1365 numInput->setMinimum( -10000 );
1366 numInput->setSuffix( i18nc( "Unit suffix where units are days.", " days" ) );
1367 numInput->setSliderEnabled( false );
1371 //---------------------------------------------------------------------------
1373 bool NumericRuleWidgetHandler::setRule( QStackedWidget *functionStack,
1374 QStackedWidget *valueStack,
1375 const KMSearchRule *rule ) const
1377 if ( !rule || !handlesField( rule->field() ) ) {
1378 reset( functionStack, valueStack );
1379 return false;
1382 // set the function
1383 const KMSearchRule::Function func = rule->function();
1384 int funcIndex = 0;
1385 for ( ; funcIndex < NumericFunctionCount; ++funcIndex )
1386 if ( func == NumericFunctions[funcIndex].id )
1387 break;
1388 KComboBox *funcCombo =
1389 functionStack->findChild<KComboBox*>( "numericRuleFuncCombo" );
1391 if ( funcCombo ) {
1392 funcCombo->blockSignals( true );
1393 if ( funcIndex < NumericFunctionCount )
1394 funcCombo->setCurrentIndex( funcIndex );
1395 else {
1396 kDebug(5006) << "(" << rule->asString() << "): unhandled function";
1397 funcCombo->setCurrentIndex( 0 );
1399 funcCombo->blockSignals( false );
1400 functionStack->setCurrentWidget( funcCombo );
1403 // set the value
1404 bool ok;
1405 int value = rule->contents().toInt( &ok );
1406 if ( !ok )
1407 value = 0;
1408 KIntNumInput *numInput =
1409 valueStack->findChild<KIntNumInput*>( "KIntNumInput" );
1411 if ( numInput ) {
1412 initNumInput( numInput, rule->field() );
1413 numInput->blockSignals( true );
1414 numInput->setValue( value );
1415 numInput->blockSignals( false );
1416 valueStack->setCurrentWidget( numInput );
1418 return true;
1422 //---------------------------------------------------------------------------
1424 bool NumericRuleWidgetHandler::update( const QByteArray &field,
1425 QStackedWidget *functionStack,
1426 QStackedWidget *valueStack ) const
1428 if ( !handlesField( field ) )
1429 return false;
1431 // raise the correct function widget
1432 functionStack->setCurrentWidget(
1433 functionStack->findChild<QWidget*>( "numericRuleFuncCombo" ));
1435 // raise the correct value widget
1436 KIntNumInput *numInput =
1437 valueStack->findChild<KIntNumInput*>( "KIntNumInput" );
1439 if ( numInput ) {
1440 initNumInput( numInput, field );
1441 valueStack->setCurrentWidget( numInput );
1443 return true;
1446 } // anonymous namespace for NumericRuleWidgetHandler