[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kmail-devel
Subject:    Re: A patch for libkdenetwork
From:       Michael =?iso-8859-15?q?H=E4ckel?= <Michael () Haeckel ! Net>
Date:       2001-07-21 12:53:40
[Download RAW message or body]

On Saturday, 21. July 2001 11:19, you wrote:
> Hi,
>
> I write a patch for kscoringeditor.cpp
> Now edit/add/delete/copy rule were enable/disable when there is rules or
> not. It's not a big patch but I send you this patch because you are kmail
> developer.
>
> Could you say me if it's a good patch, and if I can apply it.

Thanks, the patch looks good to me.

BTW: Please post patches to our mailing list, that all developers can see it.

Regards,
Michael Häckel
["kscoring_editor.diff" (text/x-diff)]

cvs server: Diffing .
Index: kscoringeditor.cpp
===================================================================
RCS file: /home/kde/kdenetwork/libkdenetwork/kscoringeditor.cpp,v
retrieving revision 1.22
diff -u -u -p -r1.22 kscoringeditor.cpp
--- kscoringeditor.cpp	2001/07/19 08:46:42	1.22
+++ kscoringeditor.cpp	2001/07/21 09:15:33
@@ -549,25 +549,27 @@ RuleListWidget::RuleListWidget(KScoringM
   topL->addWidget(ruleList);
   updateRuleList();
   QHBoxLayout *btnL = new QHBoxLayout(topL,KDialog::spacingHint());
+
+  editRule=0L;
   // if we're standalone, we need an additional edit button
   if (standalone) {
-    QPushButton *editRule = new QPushButton(this);
+    editRule = new QPushButton(this);
     editRule->setPixmap( BarIcon("edit", KIcon::SizeSmall) );
     QToolTip::add(editRule,i18n("Edit rule"));
     btnL->addWidget(editRule);
     connect(editRule,SIGNAL(clicked()),this,SLOT(slotEditRule()));
   }
-  QPushButton *newRule = new QPushButton(this);
+  newRule = new QPushButton(this);
   newRule->setPixmap( BarIcon( "filenew", KIcon::SizeSmall ) );
   QToolTip::add(newRule,i18n("New rule")),
   btnL->addWidget(newRule);
   connect(newRule, SIGNAL(clicked()), this, SLOT(slotNewRule()));
-  QPushButton *delRule = new QPushButton(this);
+  delRule = new QPushButton(this);
   delRule->setPixmap( BarIcon( "editdelete", KIcon::SizeSmall ) );
   QToolTip::add(delRule,i18n("Remove rule"));
   btnL->addWidget(delRule);
   connect(delRule, SIGNAL(clicked()), this, SLOT(slotDelRule()));
-  QPushButton *copyRule = new QPushButton(this);
+  copyRule = new QPushButton(this);
   copyRule->setPixmap(BarIcon("editcopy", KIcon::SizeSmall));
   QToolTip::add(copyRule,i18n("Copy rule"));
   btnL->addWidget(copyRule);
@@ -591,12 +593,22 @@ RuleListWidget::RuleListWidget(KScoringM
           this,SLOT(updateRuleList()));
   connect(manager,SIGNAL(changedRuleName(const QString&,const QString&)),
           this,SLOT(slotRuleNameChanged(const QString&,const QString&)));
+  updateButton();
 }
 
 RuleListWidget::~RuleListWidget()
 {
 }
 
+void RuleListWidget::updateButton()
+{
+    bool state=ruleList->count()>0;
+    if(editRule)
+        editRule->setEnabled(state);
+    delRule->setEnabled(state);
+    copyRule->setEnabled(state);
+}
+
 void RuleListWidget::updateRuleList()
 {
   kdDebug(5100) << "RuleListWidget::updateRuleList()" << endl;
@@ -679,11 +691,13 @@ void RuleListWidget::slotRuleSelected(in
   if (idx >= ruleList->count()) return;
   QString ruleName = ruleList->text(index);
   slotRuleSelected(ruleName);
+  updateButton();
 }
 
 void RuleListWidget::slotNewRule()
 {
   updateRuleList(manager->addRule());
+  updateButton();
 }
 
 void RuleListWidget::slotDelRule()
@@ -693,6 +707,7 @@ void RuleListWidget::slotDelRule()
     manager->deleteRule(rule);
   // goto the next rule
   slotEditRule();
+  updateButton();
 }
 
 void RuleListWidget::slotCopyRule()
@@ -701,6 +716,7 @@ void RuleListWidget::slotCopyRule()
   if (rule) {
     manager->copyRule(rule);
   }
+  updateButton();
 }
 
 //============================================================================
Index: kscoringeditor.h
===================================================================
RCS file: /home/kde/kdenetwork/libkdenetwork/kscoringeditor.h,v
retrieving revision 1.15
diff -u -u -p -r1.15 kscoringeditor.h
--- kscoringeditor.h	2001/07/19 08:46:42	1.15
+++ kscoringeditor.h	2001/07/21 09:15:33
@@ -190,6 +190,9 @@ public:
   RuleListWidget(KScoringManager *m, bool =false, QWidget *p =0, const char *n =0);
   ~RuleListWidget();
   QString currentRule() const { return ruleList->currentText(); }
+protected:
+  void updateButton();
+
 signals:
   void ruleSelected(const QString&);
   void ruleEdited(const QString&);
@@ -212,7 +215,10 @@ private:
   KListBox *ruleList;
   /** the current group */
   QString group;
-
+  QPushButton *editRule;
+  QPushButton *newRule;
+  QPushButton *delRule;
+  QPushButton *copyRule;
   KScoringManager *manager;
 };
 

_______________________________________________
Kmail Developers mailing list
Kmail@master.kde.org
http://master.kde.org/mailman/listinfo/kmail


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic