Summary: | Allow reordering of filtering rules | ||
---|---|---|---|
Product: | [Unmaintained] knode | Reporter: | Dominique Devriese <devriese> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | wishlist | CC: | kris |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Debian testing | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Dominique Devriese
2004-02-09 18:33:28 UTC
*** Bug 100121 has been marked as a duplicate of this bug. *** SVN commit 435558 by vkrause: Allow to reorder scoring rules. FEATURE: 74731 M +24 -0 kscoring.cpp M +2 -0 kscoring.h M +55 -4 kscoringeditor.cpp M +5 -0 kscoringeditor.h --- trunk/KDE/kdepim/libkdepim/kscoring.cpp #435557:435558 @@ -984,6 +984,30 @@ delete edit; } +void KScoringManager::moveRuleAbove( KScoringRule *above, KScoringRule *below ) +{ + int aindex = allRules.findRef( above ); + int bindex = allRules.findRef( below ); + if ( aindex <= 0 || bindex < 0 ) + return; + if ( aindex < bindex ) + --bindex; + allRules.take( aindex ); + allRules.insert( bindex, above ); +} + +void KScoringManager::moveRuleBelow( KScoringRule *below, KScoringRule *above ) +{ + int bindex = allRules.findRef( below ); + int aindex = allRules.findRef( above ); + if ( bindex < 0 || bindex >= (int)allRules.count() - 1 || aindex < 0 ) + return; + if ( bindex < aindex ) + --aindex; + allRules.take( bindex ); + allRules.insert( aindex + 1, below ); +} + void KScoringManager::editorReady() { kdDebug(5100) << "emitting signal finishedEditing" << endl; --- trunk/KDE/kdepim/libkdepim/kscoring.h #435557:435558 @@ -328,6 +328,8 @@ void deleteRule(KScoringRule *); void editRule(KScoringRule *e, QWidget *w=0); KScoringRule* copyRule(KScoringRule *); + void moveRuleAbove( KScoringRule *above, KScoringRule *below ); + void moveRuleBelow( KScoringRule *below, KScoringRule *above ); void setGroup(const QString& g); // has to be called after setGroup() or initCache() bool hasRulesForCurrentGroup(); --- trunk/KDE/kdepim/libkdepim/kscoringeditor.cpp #435557:435558 @@ -593,9 +593,20 @@ connect(ruleList, SIGNAL(currentChanged(QListBoxItem*)), this, SLOT(slotRuleSelected(QListBoxItem*))); topL->addWidget(ruleList); - updateRuleList(); - QHBoxLayout *btnL = new QHBoxLayout(topL,KDialog::spacingHint()); + QHBoxLayout *btnL = new QHBoxLayout( topL, KDialog::spacingHint() ); + mRuleUp = new QPushButton( this ); + mRuleUp->setPixmap( BarIcon( "up", KIcon::SizeSmall ) ); + QToolTip::add( mRuleUp, i18n("Move rule up") ); + btnL->addWidget( mRuleUp ); + connect( mRuleUp, SIGNAL( clicked() ), SLOT( slotRuleUp() ) ); + mRuleDown = new QPushButton( this ); + mRuleDown->setPixmap( BarIcon( "down", KIcon::SizeSmall ) ); + QToolTip::add( mRuleDown, i18n("Move rule down") ); + btnL->addWidget( mRuleDown ); + connect( mRuleDown, SIGNAL( clicked() ), SLOT( slotRuleDown() ) ); + + btnL = new QHBoxLayout( topL, KDialog::spacingHint() ); editRule=0L; newRule = new QPushButton(this); newRule->setPixmap( BarIcon( "filenew", KIcon::SizeSmall ) ); @@ -639,6 +650,8 @@ this,SLOT(updateRuleList())); connect(manager,SIGNAL(changedRuleName(const QString&,const QString&)), this,SLOT(slotRuleNameChanged(const QString&,const QString&))); + + updateRuleList(); updateButton(); } @@ -648,11 +661,17 @@ void RuleListWidget::updateButton() { - bool state=ruleList->count()>0; + bool state = ruleList->count() > 0; if(editRule) editRule->setEnabled(state); delRule->setEnabled(state); copyRule->setEnabled(state); + + QListBoxItem *item = ruleList->item( ruleList->currentItem() ); + if ( item ) { + mRuleUp->setEnabled( item->prev() != 0 ); + mRuleDown->setEnabled( item->next() != 0 ); + } } void RuleListWidget::updateRuleList() @@ -731,6 +750,7 @@ if (ruleName != ruleList->currentText()) { setCurrentItem(ruleList,ruleName); } + updateButton(); emit ruleSelected(ruleName); } @@ -747,7 +767,6 @@ if (idx >= ruleList->count()) return; QString ruleName = ruleList->text(index); slotRuleSelected(ruleName); - updateButton(); } void RuleListWidget::slotNewRule() @@ -782,6 +801,38 @@ updateButton(); } +void RuleListWidget::slotRuleUp() +{ + KScoringRule *rule = 0, *below = 0; + QListBoxItem *item = ruleList->item( ruleList->currentItem() ); + if ( item ) { + rule = manager->findRule( item->text() ); + item = item->prev(); + if ( item ) + below = manager->findRule( item->text() ); + } + if ( rule && below ) + manager->moveRuleAbove( rule, below ); + updateRuleList(); + updateButton(); +} + +void RuleListWidget::slotRuleDown() +{ + KScoringRule *rule = 0, *above = 0; + QListBoxItem *item = ruleList->item( ruleList->currentItem() ); + if ( item ) { + rule = manager->findRule( item->text() ); + item = item->next(); + if ( item ) + above = manager->findRule( item->text() ); + } + if ( rule && above ) + manager->moveRuleBelow( rule, above ); + updateRuleList(); + updateButton(); +} + //============================================================================ // // class KScoringEditor (the score edit dialog) --- trunk/KDE/kdepim/libkdepim/kscoringeditor.h #435557:435558 @@ -221,6 +221,9 @@ void slotDelRule(); void slotNewRule(); void slotCopyRule(); + void slotRuleUp(); + void slotRuleDown(); + private: /** the list of rules */ KListBox *ruleList; @@ -235,6 +238,8 @@ QPushButton *newRule; QPushButton *delRule; QPushButton *copyRule; + QPushButton *mRuleUp; + QPushButton *mRuleDown; }; class KDE_EXPORT KScoringEditor : public KDialogBase |