Don't limit the naming for filters

CCMAIL: 77111-done@bugs.kde.org

svn path=/trunk/kdepim/; revision=347720
wilder-work
Andreas Gungl 22 years ago
parent d574542ad7
commit 9c930099f6
  1. 3
      kmfilter.cpp
  2. 14
      kmfilter.h
  3. 22
      kmfilterdlg.cpp

@ -37,6 +37,7 @@ KMFilter::KMFilter( KConfig* aConfig, bool popFilter )
bStopProcessingHere = true;
bConfigureShortcut = false;
bConfigureToolbar = false;
bAutoNaming = true;
}
}
@ -185,6 +186,7 @@ void KMFilter::readConfig(KConfig* config)
bConfigureToolbar = config->readBoolEntry("ConfigureToolbar", false);
bConfigureToolbar = bConfigureToolbar && bConfigureShortcut;
mIcon = config->readEntry( "Icon", "gear" );
bAutoNaming = config->readBoolEntry("AutomaticName", true);
int i, numActions;
QString actName, argsName;
@ -257,6 +259,7 @@ void KMFilter::writeConfig(KConfig* config) const
config->writeEntry( "ConfigureShortcut", bConfigureShortcut );
config->writeEntry( "ConfigureToolbar", bConfigureToolbar );
config->writeEntry( "Icon", mIcon );
config->writeEntry( "AutomaticName", bAutoNaming );
QString key;
int i;

@ -207,11 +207,24 @@ public:
#ifndef NDEBUG
const QString asString() const;
#endif
/** No descriptions */
bool isPopFilter() const {
return bPopFilter;
}
/** Set the mode for using automatic naming for the filter.
If the feature is enabled, the name is derived from the
first filter rule.
*/
void setAutoNaming( bool useAutomaticNames ) {
bAutoNaming = useAutomaticNames;
}
/** @return Tells, if an automatic name is used for the filter
*/
bool isAutoNaming() const { return bAutoNaming; }
private:
KMSearchPattern mPattern;
QPtrList<KMFilterAction> mActions;
@ -224,6 +237,7 @@ private:
bool bStopProcessingHere : 1;
bool bConfigureShortcut : 1;
bool bConfigureToolbar : 1;
bool bAutoNaming : 1;
};
#endif /*kmfilter_h*/

@ -32,6 +32,7 @@
#include <qcheckbox.h>
#include <qpushbutton.h>
#include <qhbox.h>
#include <qvalidator.h>
// other headers:
#include <assert.h>
@ -502,7 +503,11 @@ void KMFilterListBox::slotUpdateFilterName()
QString shouldBeName = p->name();
QString displayedName = mListBox->text( mIdxSelItem );
if ( shouldBeName.stripWhiteSpace().isEmpty() || shouldBeName[0] == '<' ) {
if ( shouldBeName.stripWhiteSpace().isEmpty() ) {
mFilterList.at(mIdxSelItem)->setAutoNaming( true );
}
if ( mFilterList.at(mIdxSelItem)->isAutoNaming() ) {
// auto-naming of patterns
if ( p->first() && !p->first()->field().stripWhiteSpace().isEmpty() )
shouldBeName = QString( "<%1>: %2" ).arg( p->first()->field() ).arg( p->first()->contents() );
@ -702,22 +707,29 @@ void KMFilterListBox::slotRename()
// never called when no filter is selected.
assert( filter );
// allow empty names - those will turn auto-naming on again
QValidator *validator = new QRegExpValidator( QRegExp( ".*" ), 0 );
QString newName = KInputDialog::getText
(
i18n("Rename Filter"),
i18n("Rename filter \"%1\" to:").arg( filter->pattern()->name() ) /*label*/,
i18n("Rename filter \"%1\" to:\n(leave the field empty for automatic naming)")
.arg( filter->pattern()->name() ) /*label*/,
filter->pattern()->name() /* initial value */,
&okPressed, topLevelWidget()
&okPressed, topLevelWidget(), 0, validator
);
delete validator;
if ( !okPressed ) return;
if ( newName.isEmpty() )
if ( newName.isEmpty() ) {
// bait for slotUpdateFilterName to
// use automatic naming again.
filter->pattern()->setName( "<>" );
else
filter->setAutoNaming( true );
} else {
filter->pattern()->setName( newName );
filter->setAutoNaming( false );
}
slotUpdateFilterName();
}

Loading…
Cancel
Save