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

List:       kde-commits
Subject:    extragear/network/konversation/src
From:       John Tapsell <john.tapsell () kdemail ! net>
Date:       2005-12-15 18:39:53
Message-ID: 1134671993.904968.20478.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 488737 by johnflux:

Ignore dialog should be working now.  It doesn't have exception support, but should \
be easy enough to add.


 M  +74 -4     ignore_preferences.cpp  
 M  +9 -3      ignore_preferences.h  
 M  +12 -19    ignorelistviewitem.cpp  
 M  +6 -7      ignorelistviewitem.h  


--- trunk/extragear/network/konversation/src/ignore_preferences.cpp #488736:488737
@@ -1,6 +1,7 @@
 #include <klocale.h>
 #include <klistview.h>
 #include <qlistview.h>
+#include <qlineedit.h>
 #include "ignore_preferences.h"
 #include "ignorelistviewitem.h"
 #include "ignore.h"
@@ -8,6 +9,8 @@
 #include <kconfig.h>
 #include <kdebug.h>
 #include <kpushbutton.h>
+#include <qcheckbox.h>
+#include "preferences.h"
 
 Ignore_Config::Ignore_Config( QWidget* parent, const char* name, WFlags fl )
     : Ignore_ConfigUI( parent, name, fl )
@@ -17,10 +20,16 @@
     connect(removeButton,SIGNAL(clicked()),
         this,SLOT(removeIgnore()));
     connect(removeAllButton,SIGNAL(clicked()),
-        ignoreListView,SLOT(removeAll()));
+        ignoreListView,SLOT(clear()));
     connect(ignoreListView,SIGNAL(selectionChanged(QListViewItem*)),
         this,SLOT(select(QListViewItem*)));
-
+    connect(chkChannel, SIGNAL(clicked()), this, SLOT(flagCheckboxChanged()));
+    connect(chkQuery, SIGNAL(clicked()), this, SLOT(flagCheckboxChanged()));
+    connect(chkNotice, SIGNAL(clicked()), this, SLOT(flagCheckboxChanged()));
+    connect(chkCTCP, SIGNAL(clicked()), this, SLOT(flagCheckboxChanged()));
+    connect(chkDCC, SIGNAL(clicked()), this, SLOT(flagCheckboxChanged()));
+    connect(txtPattern, SIGNAL(textChanged(const QString &)), this, \
SLOT(flagCheckboxChanged())); +//    connect(chkException, SIGNAL(clicked()), this, \
SLOT(flagCheckboxChanged()));  updateWidgets();
 }
 
@@ -45,13 +54,28 @@
     delete ignoreListView->selectedItem();
 }
 
+QPtrList<Ignore> Ignore_Config::getIgnoreList()
+{
+    QPtrList<Ignore> newList;
+
+    IgnoreListViewItem* \
item=static_cast<IgnoreListViewItem*>(ignoreListView->firstChild()); +    while(item)
+    {
+        Ignore* newItem=new Ignore(item->text(0),item->getFlags());
+        newList.append(newItem);
+        item=item->itemBelow();
+    }
+
+    return newList;
+}
 void Ignore_Config::saveSettings()
 {
+    Preferences::setIgnoreList(getIgnoreList());
 }
 
 void Ignore_Config::updateWidgets()
 {
-/*    QPtrList<Ignore> ignoreList=preferences->getIgnoreList();
+    QPtrList<Ignore> ignoreList=Preferences::ignoreList();
     // Insert Ignore items backwards to get them sorted properly
     Ignore* item=ignoreList.last();
     ignoreListView->clear();
@@ -59,10 +83,56 @@
     {
         new IgnoreListViewItem(ignoreListView,item->getName(),item->getFlags());
         item=ignoreList.prev();
-    }*/
+    }
 
+    select(NULL);
 }
 
+
+void Ignore_Config::select(QListViewItem* item)
+{
+    // FIXME: Cast to IgnoreListViewItem, maybe derive from KListView some day
+    IgnoreListViewItem* selectedItem=static_cast<IgnoreListViewItem*>(item);
+
+    chkChannel->setEnabled(selectedItem != NULL);
+    chkQuery->setEnabled(selectedItem != NULL);
+    chkNotice->setEnabled(selectedItem != NULL);
+    chkCTCP->setEnabled(selectedItem != NULL);
+    chkDCC->setEnabled(selectedItem != NULL);
+//	chkExceptions->setEnabled(selectedItem != NULL);
+    txtPattern->setEnabled(selectedItem != NULL);
+
+    if(selectedItem)
+    {
+	int flags = selectedItem->getFlags();
+        chkChannel->setChecked(flags & Ignore::Channel);
+        chkQuery->setChecked(flags & Ignore::Query);
+        chkNotice->setChecked(flags & Ignore::Notice);
+        chkCTCP->setChecked(flags & Ignore::CTCP);
+        chkDCC->setChecked(flags & Ignore::DCC);
+	txtPattern->setText(selectedItem->getName());
+
+//        chkExceptions->setChecked(flags & Ignore::Exception) ;
+    }
+}
+
+void Ignore_Config::flagCheckboxChanged()
+{
+    int flags = 0;
+    if(chkChannel->isChecked()) flags |= Ignore::Channel;
+    if(chkQuery->isChecked()) flags |= Ignore::Query;
+    if(chkNotice->isChecked()) flags |= Ignore::Notice;
+    if(chkCTCP->isChecked()) flags |= Ignore::CTCP;
+    if(chkDCC->isChecked()) flags |= Ignore::DCC;
+    
+//    if(chkExceptions->isChecked()) flags |= Ignore::Exceptions;
+    IgnoreListViewItem* \
selectedItem=static_cast<IgnoreListViewItem*>(ignoreListView->selectedItem()); +    \
if(selectedItem) { +        selectedItem->setFlags(flags);
+	selectedItem->setName(txtPattern->text());
+    }
+}
+
 /*
  *  Sets the strings of the subwidgets using the current
  *  language.
--- trunk/extragear/network/konversation/src/ignore_preferences.h #488736:488737
@@ -3,7 +3,9 @@
 #define IGNORE_CONFIG_H
 
 #include "ignore_preferencesui.h"
+#include <qptrlist.h>
 
+class Ignore;
 class Ignore_Config : public Ignore_ConfigUI
 {
     Q_OBJECT
@@ -12,14 +14,18 @@
     Ignore_Config( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
     ~Ignore_Config();
     QString flagNames;
-
+private:
+    QPtrList<Ignore> getIgnoreList();
+	    
 public slots:
     virtual void languageChange();
     virtual void saveSettings();
     virtual void updateWidgets();
 protected slots:
-    virtual void newIgnore();
-    virtual void removeIgnore();
+    void newIgnore();
+    void removeIgnore();
+    void flagCheckboxChanged();
+    void select(QListViewItem* item);
 signals:
     void modified();
 };
--- trunk/extragear/network/konversation/src/ignorelistviewitem.cpp #488736:488737
@@ -20,9 +20,6 @@
 IgnoreListViewItem::IgnoreListViewItem(QListView* parent,QString name,int newFlags):
 KListViewItem(parent,name)
 {
-    yes=i18n("yes");
-    no=i18n("no");
-
     setFlags(newFlags);
 }
 
@@ -32,27 +29,23 @@
 
 void IgnoreListViewItem::setFlag(int flag,bool active)
 {
-    int column=1;
-    for(int i=1;i<64;i+=i)
-    {
-        if(flag==i) setText(column,(active) ? yes : no);
-        column++;
-    }
-
-    if(active) flags+=flag;
-    else flags-=flag;
+    if(active) m_flags|=flag;
+    else m_flags &= ~flag; //any bits that are set in flag will cause those bits in \
flags to be set to 0 +    setFlags(m_flags);
 }
 
 void IgnoreListViewItem::setFlags(int newFlags)
 {
-    flags=newFlags;
+    m_flags=newFlags;
 
-    setText(1,(flags & Ignore::Channel) ? yes : no);
-    setText(2,(flags & Ignore::Query) ? yes : no);
-    setText(3,(flags & Ignore::Notice) ? yes : no);
-    setText(4,(flags & Ignore::CTCP) ? yes : no);
-    setText(5,(flags & Ignore::DCC) ? yes : no);
-    setText(6,(flags & Ignore::Exception) ? yes : no);
+    QString flagsStr;
+    if(m_flags & Ignore::Channel) flagsStr += i18n("Channel") + " ";
+    if(m_flags & Ignore::Query) flagsStr += i18n("Query") + " ";
+    if(m_flags & Ignore::Notice) flagsStr += i18n("Notice") + " ";
+    if(m_flags & Ignore::CTCP) flagsStr += i18n("CTCP") + " ";
+    if(m_flags & Ignore::DCC) flagsStr += i18n("DCC") + " ";
+    if(m_flags & Ignore::Exception) flagsStr += i18n("Exception") + " ";
+    setText(1,flagsStr);
 }
 
 IgnoreListViewItem* IgnoreListViewItem::itemBelow()
--- trunk/extragear/network/konversation/src/ignorelistviewitem.h #488736:488737
@@ -29,15 +29,14 @@
         ~IgnoreListViewItem();
 
         void setFlag(int flag,bool active);
-        bool getFlag(int flag) { return flags & flag; };
-        int getFlags() { return flags; };
+        bool getFlag(int flag) { return m_flags & flag; };
+	QString getName() { return text(0); };
+	void setName(QString name) { setText(0, name); };
+        int getFlags() { return m_flags; };
         IgnoreListViewItem* itemBelow();
 
-    protected:
         void setFlags(int flags);
-        QString yes;
-        QString no;
-
-        int flags;
+    protected:
+        int m_flags;
 };
 #endif


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

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