-rw-r--r-- | bin/kdepim/WhatsNew.txt | 5 | ||||
-rw-r--r-- | kaddressbook/filter.cpp | 22 | ||||
-rw-r--r-- | kaddressbook/filter.h | 6 | ||||
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 40 | ||||
-rw-r--r-- | kaddressbook/filtereditdialog.h | 7 |
5 files changed, 65 insertions, 15 deletions
diff --git a/bin/kdepim/WhatsNew.txt b/bin/kdepim/WhatsNew.txt index 5d8ef41..d8f8323 100644 --- a/bin/kdepim/WhatsNew.txt +++ b/bin/kdepim/WhatsNew.txt | |||
@@ -21,5 +21,10 @@ KO/Pi: | |||
21 | The timeedit input has a pulldown list for times. | 21 | The timeedit input has a pulldown list for times. |
22 | If opened, this pulldown list should now has the right time highlighted. | 22 | If opened, this pulldown list should now has the right time highlighted. |
23 | Added the possibility to exclude events/todos/journals in a filter. | ||
24 | You should exclude journals, if you do not want them to sync with a public calendar. | ||
23 | 25 | ||
26 | KA/Pi: | ||
27 | Added the possibility to in/exclude public/private/confidential contacts to a filter. | ||
28 | If you have already defined filterrules in KA/Pi you have to adjust them all by setting the "include public/private/confidential" property manually. Sorry for that ... | ||
24 | 29 | ||
25 | 30 | ||
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp index 39d2ae4..9cb4c2d 100644 --- a/kaddressbook/filter.cpp +++ b/kaddressbook/filter.cpp | |||
@@ -29,4 +29,5 @@ | |||
29 | 29 | ||
30 | #include "filter.h" | 30 | #include "filter.h" |
31 | #include <secrecy.h> | ||
31 | 32 | ||
32 | Filter::Filter() | 33 | Filter::Filter() |
@@ -34,4 +35,5 @@ Filter::Filter() | |||
34 | mInternal( false ) | 35 | mInternal( false ) |
35 | { | 36 | { |
37 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | ||
36 | } | 38 | } |
37 | 39 | ||
@@ -40,4 +42,5 @@ Filter::Filter( const QString &name ) | |||
40 | mInternal( false ) | 42 | mInternal( false ) |
41 | { | 43 | { |
44 | mCriteria = ShowPublic | ShowPrivate| ShowConfidential ; | ||
42 | } | 45 | } |
43 | 46 | ||
@@ -80,4 +83,21 @@ void Filter::apply( KABC::Addressee::List &addresseeList ) | |||
80 | bool Filter::filterAddressee( const KABC::Addressee &a ) | 83 | bool Filter::filterAddressee( const KABC::Addressee &a ) |
81 | { | 84 | { |
85 | switch ( a.secrecy().type()) { | ||
86 | case KABC::Secrecy::Public: | ||
87 | if (! (mCriteria & ShowPublic )) | ||
88 | return false; | ||
89 | break; | ||
90 | case KABC::Secrecy::Private: | ||
91 | if (! (mCriteria & ShowPrivate )) | ||
92 | return false; | ||
93 | break; | ||
94 | case KABC::Secrecy::Confidential: | ||
95 | if (! (mCriteria & ShowConfidential )) | ||
96 | return false; | ||
97 | break; | ||
98 | default: | ||
99 | return false; | ||
100 | break; | ||
101 | } | ||
82 | QStringList::Iterator iter; | 102 | QStringList::Iterator iter; |
83 | iter = mCategoryList.begin(); | 103 | iter = mCategoryList.begin(); |
@@ -121,4 +141,5 @@ void Filter::save( KConfig *config ) | |||
121 | config->writeEntry( "Categories", mCategoryList ); | 141 | config->writeEntry( "Categories", mCategoryList ); |
122 | config->writeEntry( "MatchRule", (int)mMatchRule ); | 142 | config->writeEntry( "MatchRule", (int)mMatchRule ); |
143 | config->writeEntry( "Criteria", (int)mCriteria ); | ||
123 | } | 144 | } |
124 | 145 | ||
@@ -129,4 +150,5 @@ void Filter::restore( KConfig *config ) | |||
129 | mCategoryList = config->readListEntry( "Categories" ); | 150 | mCategoryList = config->readListEntry( "Categories" ); |
130 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); | 151 | mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching ); |
152 | mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) ); | ||
131 | } | 153 | } |
132 | 154 | ||
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h index cf2c0a1..26870d7 100644 --- a/kaddressbook/filter.h +++ b/kaddressbook/filter.h | |||
@@ -39,5 +39,8 @@ | |||
39 | class Filter | 39 | class Filter |
40 | { | 40 | { |
41 | public: | 41 | public: |
42 | enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4}; | ||
43 | void setCriteria(int c) { mCriteria = c ;} | ||
44 | int criteria() const { return mCriteria;} | ||
42 | typedef QValueList<Filter> List; | 45 | typedef QValueList<Filter> List; |
43 | 46 | ||
@@ -144,4 +147,5 @@ class Filter | |||
144 | 147 | ||
145 | private: | 148 | private: |
149 | int mCriteria; | ||
146 | QString mName; | 150 | QString mName; |
147 | QStringList mCategoryList; | 151 | QStringList mCategoryList; |
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 063585a..987f234 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -35,4 +35,5 @@ $Id$ | |||
35 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
36 | #include <qradiobutton.h> | 36 | #include <qradiobutton.h> |
37 | #include <qcheckbox.h> | ||
37 | #include <qregexp.h> | 38 | #include <qregexp.h> |
38 | #include <qstring.h> | 39 | #include <qstring.h> |
@@ -91,4 +92,10 @@ void FilterEditDialog::setFilter( const Filter &filter ) | |||
91 | else | 92 | else |
92 | mMatchRuleGroup->setButton( 1 ); | 93 | mMatchRuleGroup->setButton( 1 ); |
94 | |||
95 | int c = filter.criteria() ; | ||
96 | mPublic->setChecked(c &Filter::ShowPublic); | ||
97 | mPrivate->setChecked(c & Filter::ShowPrivate); | ||
98 | mConfidential->setChecked(c & Filter::ShowConfidential); | ||
99 | |||
93 | } | 100 | } |
94 | 101 | ||
@@ -115,4 +122,10 @@ Filter FilterEditDialog::filter() | |||
115 | filter.setMatchRule( Filter::NotMatching ); | 122 | filter.setMatchRule( Filter::NotMatching ); |
116 | 123 | ||
124 | int c = 0; | ||
125 | if (mPublic->isChecked()) c |= Filter::ShowPublic; | ||
126 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; | ||
127 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; | ||
128 | filter.setCriteria( c ) ; | ||
129 | |||
117 | return filter; | 130 | return filter; |
118 | } | 131 | } |
@@ -144,21 +157,22 @@ void FilterEditDialog::initGUI() | |||
144 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); | 157 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); |
145 | 158 | ||
146 | mMatchRuleGroup = new QButtonGroup( page ); | 159 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); |
147 | mMatchRuleGroup->setExclusive( true ); | 160 | mMatchRuleGroup->setExclusive( true ); |
148 | 161 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); | |
149 | QBoxLayout *gbLayout = new QVBoxLayout( mMatchRuleGroup ); | ||
150 | gbLayout->setSpacing( KDialog::spacingHint() ); | ||
151 | gbLayout->setMargin( KDialog::marginHint() ); | ||
152 | |||
153 | QRadioButton *radio = new QRadioButton( i18n( "Show only contacts matching\n the selected categories" ), mMatchRuleGroup ); | ||
154 | radio->setChecked( true ); | 162 | radio->setChecked( true ); |
155 | mMatchRuleGroup->insert( radio ); | 163 | //mMatchRuleGroup->insert( radio ); |
156 | gbLayout->addWidget( radio ); | 164 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); |
165 | //mMatchRuleGroup->insert( radio ); | ||
166 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | ||
157 | 167 | ||
158 | radio = new QRadioButton( i18n( "Show all contacts except those\n matching the selected categories" ), mMatchRuleGroup ); | 168 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); |
159 | mMatchRuleGroup->insert( radio ); | 169 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); |
160 | gbLayout->addWidget( radio ); | 170 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); |
171 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); | ||
172 | mPublic->setChecked( true ); | ||
173 | mPrivate->setChecked( true ); | ||
174 | mConfidential->setChecked( true ); | ||
175 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); | ||
161 | 176 | ||
162 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | ||
163 | } | 177 | } |
164 | 178 | ||
diff --git a/kaddressbook/filtereditdialog.h b/kaddressbook/filtereditdialog.h index 4dd75e4..5a8bad1 100644 --- a/kaddressbook/filtereditdialog.h +++ b/kaddressbook/filtereditdialog.h | |||
@@ -37,4 +37,5 @@ class QToolButton; | |||
37 | class QWidget; | 37 | class QWidget; |
38 | class QListBoxItem; | 38 | class QListBoxItem; |
39 | class QCheckBox; | ||
39 | 40 | ||
40 | class KLineEdit; | 41 | class KLineEdit; |
@@ -43,4 +44,5 @@ class KListView; | |||
43 | 44 | ||
44 | #include <kdialogbase.h> | 45 | #include <kdialogbase.h> |
46 | #include <qhbuttongroup.h> | ||
45 | 47 | ||
46 | #include "filter.h" | 48 | #include "filter.h" |
@@ -97,5 +99,8 @@ class FilterEditDialog : public KDialogBase | |||
97 | KLineEdit *mNameEdit; | 99 | KLineEdit *mNameEdit; |
98 | KListView *mCategoriesView; | 100 | KListView *mCategoriesView; |
99 | QButtonGroup *mMatchRuleGroup; | 101 | QHButtonGroup *mMatchRuleGroup; |
102 | QCheckBox *mPrivate; | ||
103 | QCheckBox *mPublic; | ||
104 | QCheckBox *mConfidential; | ||
100 | QPushButton *mEditButton; | 105 | QPushButton *mEditButton; |
101 | QPushButton *mRemoveButton; | 106 | QPushButton *mRemoveButton; |