Diffstat (limited to 'kaddressbook/filtereditdialog.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 063585a..987f234 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -25,24 +25,25 @@ | |||
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <qbuttongroup.h> | 31 | #include <qbuttongroup.h> |
32 | #include <qhbox.h> | 32 | #include <qhbox.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qlayout.h> | 34 | #include <qlayout.h> |
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> |
39 | #include <qtoolbutton.h> | 40 | #include <qtoolbutton.h> |
40 | #include <qtooltip.h> | 41 | #include <qtooltip.h> |
41 | #include <qwidget.h> | 42 | #include <qwidget.h> |
42 | 43 | ||
43 | #include <kapplication.h> | 44 | #include <kapplication.h> |
44 | #include <kbuttonbox.h> | 45 | #include <kbuttonbox.h> |
45 | #include <kdebug.h> | 46 | #include <kdebug.h> |
46 | #include <kiconloader.h> | 47 | #include <kiconloader.h> |
47 | #include <klineedit.h> | 48 | #include <klineedit.h> |
48 | #include <klistbox.h> | 49 | #include <klistbox.h> |
@@ -81,48 +82,60 @@ void FilterEditDialog::setFilter( const Filter &filter ) | |||
81 | if ( categories.contains( item->text( 0 ) ) ) { | 82 | if ( categories.contains( item->text( 0 ) ) ) { |
82 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
83 | checkItem->setOn( true ); | 84 | checkItem->setOn( true ); |
84 | } | 85 | } |
85 | 86 | ||
86 | item = item->nextSibling(); | 87 | item = item->nextSibling(); |
87 | } | 88 | } |
88 | 89 | ||
89 | if ( filter.matchRule() == Filter::Matching ) | 90 | if ( filter.matchRule() == Filter::Matching ) |
90 | mMatchRuleGroup->setButton( 0 ); | 91 | mMatchRuleGroup->setButton( 0 ); |
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 | ||
95 | Filter FilterEditDialog::filter() | 102 | Filter FilterEditDialog::filter() |
96 | { | 103 | { |
97 | Filter filter; | 104 | Filter filter; |
98 | 105 | ||
99 | filter.setName( mNameEdit->text() ); | 106 | filter.setName( mNameEdit->text() ); |
100 | 107 | ||
101 | QStringList categories; | 108 | QStringList categories; |
102 | QListViewItem *item = mCategoriesView->firstChild(); | 109 | QListViewItem *item = mCategoriesView->firstChild(); |
103 | while ( item != 0 ) { | 110 | while ( item != 0 ) { |
104 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 111 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
105 | if ( checkItem->isOn() ) | 112 | if ( checkItem->isOn() ) |
106 | categories.append( item->text( 0 ) ); | 113 | categories.append( item->text( 0 ) ); |
107 | 114 | ||
108 | item = item->nextSibling(); | 115 | item = item->nextSibling(); |
109 | } | 116 | } |
110 | filter.setCategories( categories ); | 117 | filter.setCategories( categories ); |
111 | 118 | ||
112 | if ( mMatchRuleGroup->find( 0 )->isOn() ) | 119 | if ( mMatchRuleGroup->find( 0 )->isOn() ) |
113 | filter.setMatchRule( Filter::Matching ); | 120 | filter.setMatchRule( Filter::Matching ); |
114 | else | 121 | else |
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 | } |
119 | 132 | ||
120 | void FilterEditDialog::initGUI() | 133 | void FilterEditDialog::initGUI() |
121 | { | 134 | { |
122 | #ifndef KAB_EMBEDDED | 135 | #ifndef KAB_EMBEDDED |
123 | resize( 490, 300 ); | 136 | resize( 490, 300 ); |
124 | #else //KAB_EMBEDDED | 137 | #else //KAB_EMBEDDED |
125 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | 138 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); |
126 | #endif //KAB_EMBEDDED | 139 | #endif //KAB_EMBEDDED |
127 | 140 | ||
128 | 141 | ||
@@ -134,41 +147,42 @@ void FilterEditDialog::initGUI() | |||
134 | label = new QLabel( i18n( "Name" ), page ); | 147 | label = new QLabel( i18n( "Name" ), page ); |
135 | mNameEdit = new KLineEdit( page ); | 148 | mNameEdit = new KLineEdit( page ); |
136 | mNameEdit->setFocus(); | 149 | mNameEdit->setFocus(); |
137 | topLayout->addWidget( label, 0, 0 ); | 150 | topLayout->addWidget( label, 0, 0 ); |
138 | topLayout->addWidget( mNameEdit, 0, 1 ); | 151 | topLayout->addWidget( mNameEdit, 0, 1 ); |
139 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 152 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
140 | SLOT( filterNameTextChanged( const QString&) ) ); | 153 | SLOT( filterNameTextChanged( const QString&) ) ); |
141 | 154 | ||
142 | mCategoriesView = new KListView( page ); | 155 | mCategoriesView = new KListView( page ); |
143 | mCategoriesView->addColumn( i18n( "Categories" ) ); | 156 | mCategoriesView->addColumn( i18n( "Categories" ) ); |
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 | ||
165 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 179 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
166 | { | 180 | { |
167 | enableButtonOK( !text.isEmpty() ); | 181 | enableButtonOK( !text.isEmpty() ); |
168 | } | 182 | } |
169 | 183 | ||
170 | void FilterEditDialog::slotHelp() | 184 | void FilterEditDialog::slotHelp() |
171 | { | 185 | { |
172 | #ifndef KAB_EMBEDDED | 186 | #ifndef KAB_EMBEDDED |
173 | kapp->invokeHelp( "using-filters" ); | 187 | kapp->invokeHelp( "using-filters" ); |
174 | #endif //KAB_EMBEDDED | 188 | #endif //KAB_EMBEDDED |