summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2005-01-16 14:10:42 (UTC)
committer zautrix <zautrix>2005-01-16 14:10:42 (UTC)
commitde5f08d69c716f85cc92f20700cd24fb1ad41295 (patch) (side-by-side diff)
tree0a4f5dbbdb4fc24215ab85fa4b5e073d0e8104ef
parent3f61f5a339e9c0c67c17b16214abded0d123f246 (diff)
downloadkdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.zip
kdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.tar.gz
kdepimpi-de5f08d69c716f85cc92f20700cd24fb1ad41295.tar.bz2
added AB filter settings
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--bin/kdepim/WhatsNew.txt5
-rw-r--r--kaddressbook/filter.cpp22
-rw-r--r--kaddressbook/filter.h6
-rw-r--r--kaddressbook/filtereditdialog.cpp40
-rw-r--r--kaddressbook/filtereditdialog.h7
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
@@ -1,71 +1,76 @@
Info about the changes in new versions of KDE-Pim/Pi
********** VERSION 1.9.18 ************
FYI: The VERSION 1.9.17 was a testing release only.
Please read the changelog of VERSION 1.9.17 as well.
Cleaned up the syncing config dialog.
Added sync config options for date range for events.
Added sync config options for filters on incoming data.
Added sync config options for filters on outgoing data.
Please read the updated SyncHowTo about the new filter settings.
These filter settings make it now possible to sync with shared
calendars without writing back private or confidential data
(via the outgoing filters).
To sync only with particular parts of a shared calendar,
the incoming filter settings can be used.
An example can be found in the SyncHowTo.
KO/Pi:
The timeedit input has a pulldown list for times.
If opened, this pulldown list should now has the right time highlighted.
+Added the possibility to exclude events/todos/journals in a filter.
+You should exclude journals, if you do not want them to sync with a public calendar.
+KA/Pi:
+Added the possibility to in/exclude public/private/confidential contacts to a filter.
+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 ...
********** VERSION 1.9.17 ************
KO/Pi:
Fixed that tooltips were not updated after moving an item in agenda view.
Fixed a bug in sorting start date for recurring events in list view.
Changed the left button in todo viewer from "Agenda" to "Set completed".
This makes it possible to change a todo in the What's Next View quickly to the completed state without leaving the What's Next View.
Added more info in the todo viewer: Startdate, parent/sub todos.
KA/Pi:
All fields search does now actually search all the (possible) fields,
not only those listed in the contact list.
Made is possible to inline a picture in a vcard on the Z.
This was only possible on the desktop, now is it possible on the Z as well.
Fixed of missing save settings after filter configuration.
Made saving of addressbook much faster.
Fixed extension widget layout problem.
Fixed saving of default formatted name settings.
Fixed formatted name handling in edit dialog.
Added an option for changing formatted names of many contacts
(menu: File - Change - Set formatted name).
QWhatsThis was not working on the Z ( only black rectangle was shown).
This is Fixed.
KDE-Sync:
Now readonly KDE resources are synced as well.
(They are not changed in KDE itself, of course).
********** VERSION 1.9.16 ************
KO/Pi:
Fixed search dialog size on Z 6000 (480x640 display).
Added setting to hide/show time in agenda items.
Added setting to hide not running todos in todo view.
Added columns for start date/time in todo view.
Replaced the solid half-hour lines in agenda view by dot lines.
Added possibility of printing the What's Next View on the desktop
(i.e. Windows and Linux).
Fixed a crash in KO/Pi when starting KO/Pi with What's Next view.
Added tooltips in month view.(Tooltips only available on desktop)
Fixed a strange problem in KO/Pi alarm applet.
diff --git a/kaddressbook/filter.cpp b/kaddressbook/filter.cpp
index 39d2ae4..9cb4c2d 100644
--- a/kaddressbook/filter.cpp
+++ b/kaddressbook/filter.cpp
@@ -1,178 +1,200 @@
/*
This file is part of KAddressBook.
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#include <kconfig.h>
#include <kconfigbase.h>
#include <kdebug.h>
#include "kabprefs.h"
#include "filter.h"
+#include <secrecy.h>
Filter::Filter()
: mName( QString::null ), mMatchRule( Matching ), mEnabled( true ),
mInternal( false )
{
+ mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
}
Filter::Filter( const QString &name )
: mName( name ), mMatchRule( Matching ), mEnabled( true ),
mInternal( false )
{
+ mCriteria = ShowPublic | ShowPrivate| ShowConfidential ;
}
Filter::~Filter()
{
}
void Filter::setName( const QString &name )
{
mName = name;
}
const QString &Filter::name() const
{
return mName;
}
bool Filter::isInternal() const
{
return mInternal;
}
void Filter::apply( KABC::Addressee::List &addresseeList )
{
KABC::Addressee::List::Iterator iter;
for ( iter = addresseeList.begin(); iter != addresseeList.end(); ) {
if ( filterAddressee( *iter ) )
++iter;
else
{
#ifndef KAB_EMBEDDED
iter = addresseeList.erase( iter );
#else //KAB_EMBEDDED
iter = addresseeList.remove( iter );
#endif //KAB_EMBEDDED
}
}
}
bool Filter::filterAddressee( const KABC::Addressee &a )
{
+ switch ( a.secrecy().type()) {
+ case KABC::Secrecy::Public:
+ if (! (mCriteria & ShowPublic ))
+ return false;
+ break;
+ case KABC::Secrecy::Private:
+ if (! (mCriteria & ShowPrivate ))
+ return false;
+ break;
+ case KABC::Secrecy::Confidential:
+ if (! (mCriteria & ShowConfidential ))
+ return false;
+ break;
+ default:
+ return false;
+ break;
+ }
QStringList::Iterator iter;
iter = mCategoryList.begin();
// empty filter always matches
if ( iter == mCategoryList.end() )
return true;
for ( ; iter != mCategoryList.end(); ++iter ) {
if ( a.hasCategory( *iter ) )
return ( mMatchRule == Matching );
}
return !( mMatchRule == Matching );
}
void Filter::setEnabled( bool on )
{
mEnabled = on;
}
bool Filter::isEnabled() const
{
return mEnabled;
}
void Filter::setCategories( const QStringList &list )
{
mCategoryList = list;
}
const QStringList &Filter::categories() const
{
return mCategoryList;
}
void Filter::save( KConfig *config )
{
config->writeEntry( "Name", mName );
config->writeEntry( "Enabled", mEnabled );
config->writeEntry( "Categories", mCategoryList );
config->writeEntry( "MatchRule", (int)mMatchRule );
+ config->writeEntry( "Criteria", (int)mCriteria );
}
void Filter::restore( KConfig *config )
{
mName = config->readEntry( "Name", "<internal error>" );
mEnabled = config->readBoolEntry( "Enabled", true );
mCategoryList = config->readListEntry( "Categories" );
mMatchRule = (MatchRule)config->readNumEntry( "MatchRule", Matching );
+ mCriteria = config->readNumEntry( "Criteria", (ShowPublic | ShowPrivate| ShowConfidential) );
}
void Filter::save( KConfig *config, QString baseGroup, Filter::List &list )
{
{
KConfigGroupSaver s( config, baseGroup );
// remove the old filters
uint count = config->readNumEntry( "Count" );
/* // memory access violation here
for ( uint i = 0; i < count; ++i )
config->deleteGroup( QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
*/
}
int index = 0;
Filter::List::Iterator iter;
for ( iter = list.begin(); iter != list.end(); ++iter ) {
if ( !(*iter).mInternal ) {
KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( index ) );
(*iter).save( config );
index++;
}
}
KConfigGroupSaver s( config, baseGroup );
config->writeEntry( "Count", index );
}
Filter::List Filter::restore( KConfig *config, QString baseGroup )
{
Filter::List list;
int count = 0;
Filter f;
{
KConfigGroupSaver s( config, baseGroup );
count = config->readNumEntry( "Count", 0 );
}
for ( int i = 0; i < count; i++ ) {
{
KConfigGroupSaver s( config, QString( "%1_%2" ).arg( baseGroup ).arg( i ) );
f.restore( config );
}
diff --git a/kaddressbook/filter.h b/kaddressbook/filter.h
index cf2c0a1..26870d7 100644
--- a/kaddressbook/filter.h
+++ b/kaddressbook/filter.h
@@ -1,89 +1,92 @@
/*
This file is part of KAddressBook.
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
#ifndef FILTER_H
#define FILTER_H
#include <qstring.h>
#include <qstringlist.h>
#include <qvaluelist.h>
#include <kabc/addressee.h>
#include <kconfig.h>
/**
Filter for AddressBook related objects (Addressees)
@todo This class should be switched to use shared data.
*/
class Filter
{
- public:
+ public:
+ enum { ShowPublic = 1, ShowPrivate = 2, ShowConfidential = 4};
+ void setCriteria(int c) { mCriteria = c ;}
+ int criteria() const { return mCriteria;}
typedef QValueList<Filter> List;
enum MatchRule { Matching = 0, NotMatching = 1 };
Filter();
Filter( const QString& name );
~Filter();
/**
Set the name of the filter.
*/
void setName( const QString &name );
/**
@return The name of the filter.
*/
const QString &name() const;
/**
@return Whether the filter is an internal one.
*/
bool isInternal() const;
/**
Apply the filter to the addressee list. All addressees not passing
the filter criterias will be removed from the list.
If the MatchRule is NotMatch, then all the addressees matching the
filter will be removed from the list.
*/
void apply( KABC::Addressee::List &addresseeList );
/**
Apply the filter to the addressee.
@return True if the addressee passes the criteria, false otherwise.
The return values are opposite if the MatchRule is NotMatch.
*/
bool filterAddressee( const KABC::Addressee &a );
/**
Enable or disable the filter
*/
void setEnabled( bool on );
/**
@return True if this filter is enabled, false otherwise.
*/
@@ -98,56 +101,57 @@ class Filter
@return The list of categories.
*/
const QStringList &categories() const;
/**
Saves the filter to the config file. The group should already be set.
*/
void save( KConfig *config );
/**
Loads the filter from the config file. The group should already be set.
*/
void restore( KConfig *config );
/**
Saves a list of filters to the config file.
@param config The config file to use
@param baseGroup The base groupname to use. The number of filters
will be written to this group, then a _1, _2, etc
will be append for each filter saved.
@param list The list of filters to be saved.
*/
static void save( KConfig *config, QString baseGroup, Filter::List &list );
/**
Restores a list of filters from a config file.
@param config The config file to read from.
@param baseGroup The base group name to be used to find the filters
@return The list of filters.
*/
static Filter::List restore( KConfig *config, QString baseGroup );
/**
Sets the filter rule. If the rule is Filter::Matching (default),
then the filter will return true on items that match the filter.
If the rule is Filter::NotMatching, then the filter will return
true on items that do not match the filter.
*/
void setMatchRule( MatchRule rule );
/** @return The current match rule.
*/
MatchRule matchRule() const;
private:
+ int mCriteria;
QString mName;
QStringList mCategoryList;
MatchRule mMatchRule;
bool mEnabled;
bool mInternal;
};
#endif
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
index 063585a..987f234 100644
--- a/kaddressbook/filtereditdialog.cpp
+++ b/kaddressbook/filtereditdialog.cpp
@@ -1,210 +1,224 @@
/*
This file is part of KAddressBook.
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#include <qbuttongroup.h>
#include <qhbox.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qradiobutton.h>
+#include <qcheckbox.h>
#include <qregexp.h>
#include <qstring.h>
#include <qtoolbutton.h>
#include <qtooltip.h>
#include <qwidget.h>
#include <kapplication.h>
#include <kbuttonbox.h>
#include <kdebug.h>
#include <kiconloader.h>
#include <klineedit.h>
#include <klistbox.h>
#include <klistview.h>
#include <klocale.h>
#include <kglobal.h>
#include "kabprefs.h"
#include "filtereditdialog.h"
FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Edit Address Book Filter" ),
Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true )
{
initGUI();
QStringList cats = KABPrefs::instance()->mCustomCategories;
QStringList::Iterator iter;
for ( iter = cats.begin(); iter != cats.end(); ++iter )
mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) );
filterNameTextChanged( mNameEdit->text() );
}
FilterEditDialog::~FilterEditDialog()
{
}
void FilterEditDialog::setFilter( const Filter &filter )
{
mNameEdit->setText( filter.name() );
QStringList categories = filter.categories();
QListViewItem *item = mCategoriesView->firstChild();
while ( item != 0 ) {
if ( categories.contains( item->text( 0 ) ) ) {
QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
checkItem->setOn( true );
}
item = item->nextSibling();
}
if ( filter.matchRule() == Filter::Matching )
mMatchRuleGroup->setButton( 0 );
else
mMatchRuleGroup->setButton( 1 );
+
+ int c = filter.criteria() ;
+ mPublic->setChecked(c &Filter::ShowPublic);
+ mPrivate->setChecked(c & Filter::ShowPrivate);
+ mConfidential->setChecked(c & Filter::ShowConfidential);
+
}
Filter FilterEditDialog::filter()
{
Filter filter;
filter.setName( mNameEdit->text() );
QStringList categories;
QListViewItem *item = mCategoriesView->firstChild();
while ( item != 0 ) {
QCheckListItem *checkItem = static_cast<QCheckListItem*>( item );
if ( checkItem->isOn() )
categories.append( item->text( 0 ) );
item = item->nextSibling();
}
filter.setCategories( categories );
if ( mMatchRuleGroup->find( 0 )->isOn() )
filter.setMatchRule( Filter::Matching );
else
filter.setMatchRule( Filter::NotMatching );
+ int c = 0;
+ if (mPublic->isChecked()) c |= Filter::ShowPublic;
+ if (mPrivate->isChecked()) c |= Filter::ShowPrivate;
+ if (mConfidential->isChecked()) c |= Filter::ShowConfidential;
+ filter.setCriteria( c ) ;
+
return filter;
}
void FilterEditDialog::initGUI()
{
#ifndef KAB_EMBEDDED
resize( 490, 300 );
#else //KAB_EMBEDDED
resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
#endif //KAB_EMBEDDED
QWidget *page = plainPage();
QLabel *label;
QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() );
label = new QLabel( i18n( "Name" ), page );
mNameEdit = new KLineEdit( page );
mNameEdit->setFocus();
topLayout->addWidget( label, 0, 0 );
topLayout->addWidget( mNameEdit, 0, 1 );
connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
SLOT( filterNameTextChanged( const QString&) ) );
mCategoriesView = new KListView( page );
mCategoriesView->addColumn( i18n( "Categories" ) );
topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
- mMatchRuleGroup = new QButtonGroup( page );
+ mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page );
mMatchRuleGroup->setExclusive( true );
-
- QBoxLayout *gbLayout = new QVBoxLayout( mMatchRuleGroup );
- gbLayout->setSpacing( KDialog::spacingHint() );
- gbLayout->setMargin( KDialog::marginHint() );
-
- QRadioButton *radio = new QRadioButton( i18n( "Show only contacts matching\n the selected categories" ), mMatchRuleGroup );
+ QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup );
radio->setChecked( true );
- mMatchRuleGroup->insert( radio );
- gbLayout->addWidget( radio );
+ //mMatchRuleGroup->insert( radio );
+ radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup );
+ //mMatchRuleGroup->insert( radio );
+ topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
- radio = new QRadioButton( i18n( "Show all contacts except those\n matching the selected categories" ), mMatchRuleGroup );
- mMatchRuleGroup->insert( radio );
- gbLayout->addWidget( radio );
+ QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page );
+ mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup );
+ mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup );
+ mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup );
+ mPublic->setChecked( true );
+ mPrivate->setChecked( true );
+ mConfidential->setChecked( true );
+ topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 );
- topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
}
void FilterEditDialog::filterNameTextChanged( const QString &text )
{
enableButtonOK( !text.isEmpty() );
}
void FilterEditDialog::slotHelp()
{
#ifndef KAB_EMBEDDED
kapp->invokeHelp( "using-filters" );
#endif //KAB_EMBEDDED
}
FilterDialog::FilterDialog( QWidget *parent, const char *name )
: KDialogBase( Plain, i18n( "Edit Address Book Filters" ),
Ok | Cancel, Ok, parent, name, /*US false*/true, true )
{
initGUI();
}
FilterDialog::~FilterDialog()
{
}
void FilterDialog::setFilters( const Filter::List &list )
{
mFilterList.clear();
mInternalFilterList.clear();
Filter::List::ConstIterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
if ( (*it).isInternal() )
mInternalFilterList.append( *it );
else
mFilterList.append( *it );
}
refresh();
}
Filter::List FilterDialog::filters() const
{
Filter::List list = mFilterList + mInternalFilterList;
return list;
}
void FilterDialog::add()
diff --git a/kaddressbook/filtereditdialog.h b/kaddressbook/filtereditdialog.h
index 4dd75e4..5a8bad1 100644
--- a/kaddressbook/filtereditdialog.h
+++ b/kaddressbook/filtereditdialog.h
@@ -1,104 +1,109 @@
/*
This file is part of KAddressBook.
Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
As a special exception, permission is given to link this program
with any edition of Qt, and distribute the resulting executable,
without including the source code for Qt in the source distribution.
*/
/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk
$Id$
*/
#ifndef FILTEREDITDIALOG_H
#define FILTEREDITDIALOG_H
class QButtonGroup;
class QString;
class QToolButton;
class QWidget;
class QListBoxItem;
+class QCheckBox;
class KLineEdit;
class KListBox;
class KListView;
#include <kdialogbase.h>
+#include <qhbuttongroup.h>
#include "filter.h"
class FilterDialog : public KDialogBase
{
Q_OBJECT
public:
FilterDialog( QWidget *parent, const char *name = 0 );
~FilterDialog();
void setFilters( const Filter::List &list );
Filter::List filters() const;
protected slots:
void add();
void edit();
void remove();
void selectionChanged( QListBoxItem* );
private:
void initGUI();
void refresh();
Filter::List mFilterList;
Filter::List mInternalFilterList;
KListBox *mFilterListBox;
QPushButton *mAddButton;
QPushButton *mEditButton;
QPushButton *mRemoveButton;
};
class FilterEditDialog : public KDialogBase
{
Q_OBJECT
public:
FilterEditDialog( QWidget *parent, const char *name = 0 );
~FilterEditDialog();
void setFilter( const Filter &filter );
Filter filter();
protected slots:
void filterNameTextChanged( const QString& );
void slotHelp();
private:
void initGUI();
Filter mFilter;
KLineEdit *mNameEdit;
KListView *mCategoriesView;
- QButtonGroup *mMatchRuleGroup;
+ QHButtonGroup *mMatchRuleGroup;
+ QCheckBox *mPrivate;
+ QCheckBox *mPublic;
+ QCheckBox *mConfidential;
QPushButton *mEditButton;
QPushButton *mRemoveButton;
};
#endif