Diffstat (limited to 'kaddressbook/filtereditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/filtereditdialog.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp index 1194406..ef9b979 100644 --- a/kaddressbook/filtereditdialog.cpp +++ b/kaddressbook/filtereditdialog.cpp | |||
@@ -65,195 +65,195 @@ FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) | |||
65 | QStringList::Iterator iter; | 65 | QStringList::Iterator iter; |
66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) | 66 | for ( iter = cats.begin(); iter != cats.end(); ++iter ) |
67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); | 67 | mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); |
68 | filterNameTextChanged( mNameEdit->text() ); | 68 | filterNameTextChanged( mNameEdit->text() ); |
69 | } | 69 | } |
70 | 70 | ||
71 | FilterEditDialog::~FilterEditDialog() | 71 | FilterEditDialog::~FilterEditDialog() |
72 | { | 72 | { |
73 | } | 73 | } |
74 | 74 | ||
75 | void FilterEditDialog::setFilter( const Filter &filter ) | 75 | void FilterEditDialog::setFilter( const Filter &filter ) |
76 | { | 76 | { |
77 | mNameEdit->setText( filter.name() ); | 77 | mNameEdit->setText( filter.name() ); |
78 | 78 | ||
79 | QStringList categories = filter.categories(); | 79 | QStringList categories = filter.categories(); |
80 | QListViewItem *item = mCategoriesView->firstChild(); | 80 | QListViewItem *item = mCategoriesView->firstChild(); |
81 | while ( item != 0 ) { | 81 | while ( item != 0 ) { |
82 | if ( categories.contains( item->text( 0 ) ) ) { | 82 | if ( categories.contains( item->text( 0 ) ) ) { |
83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 83 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
84 | checkItem->setOn( true ); | 84 | checkItem->setOn( true ); |
85 | } | 85 | } |
86 | 86 | ||
87 | item = item->nextSibling(); | 87 | item = item->nextSibling(); |
88 | } | 88 | } |
89 | 89 | ||
90 | if ( filter.matchRule() == Filter::Matching ) | 90 | if ( filter.matchRule() == Filter::Matching ) |
91 | mMatchRuleGroup->setButton( 0 ); | 91 | mMatchRuleGroup->setButton( 0 ); |
92 | else | 92 | else |
93 | mMatchRuleGroup->setButton( 1 ); | 93 | mMatchRuleGroup->setButton( 1 ); |
94 | 94 | ||
95 | int c = filter.criteria() ; | 95 | int c = filter.criteria() ; |
96 | mPublic->setChecked(c &Filter::ShowPublic); | 96 | mPublic->setChecked(c &Filter::ShowPublic); |
97 | mPrivate->setChecked(c & Filter::ShowPrivate); | 97 | mPrivate->setChecked(c & Filter::ShowPrivate); |
98 | mConfidential->setChecked(c & Filter::ShowConfidential); | 98 | mConfidential->setChecked(c & Filter::ShowConfidential); |
99 | } | 99 | } |
100 | 100 | ||
101 | Filter FilterEditDialog::filter() | 101 | Filter FilterEditDialog::filter() |
102 | { | 102 | { |
103 | Filter filter; | 103 | Filter filter; |
104 | 104 | ||
105 | filter.setName( mNameEdit->text() ); | 105 | filter.setName( mNameEdit->text() ); |
106 | 106 | ||
107 | QStringList categories; | 107 | QStringList categories; |
108 | QListViewItem *item = mCategoriesView->firstChild(); | 108 | QListViewItem *item = mCategoriesView->firstChild(); |
109 | while ( item != 0 ) { | 109 | while ( item != 0 ) { |
110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); | 110 | QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); |
111 | if ( checkItem->isOn() ) | 111 | if ( checkItem->isOn() ) |
112 | categories.append( item->text( 0 ) ); | 112 | categories.append( item->text( 0 ) ); |
113 | 113 | ||
114 | item = item->nextSibling(); | 114 | item = item->nextSibling(); |
115 | } | 115 | } |
116 | filter.setCategories( categories ); | 116 | filter.setCategories( categories ); |
117 | 117 | ||
118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) | 118 | if ( mMatchRuleGroup->find( 0 )->isOn() ) |
119 | filter.setMatchRule( Filter::Matching ); | 119 | filter.setMatchRule( Filter::Matching ); |
120 | else | 120 | else |
121 | filter.setMatchRule( Filter::NotMatching ); | 121 | filter.setMatchRule( Filter::NotMatching ); |
122 | 122 | ||
123 | int c = 0; | 123 | int c = 0; |
124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; | 124 | if (mPublic->isChecked()) c |= Filter::ShowPublic; |
125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; | 125 | if (mPrivate->isChecked()) c |= Filter::ShowPrivate; |
126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; | 126 | if (mConfidential->isChecked()) c |= Filter::ShowConfidential; |
127 | filter.setCriteria( c ) ; | 127 | filter.setCriteria( c ) ; |
128 | 128 | ||
129 | return filter; | 129 | return filter; |
130 | } | 130 | } |
131 | 131 | ||
132 | void FilterEditDialog::initGUI() | 132 | void FilterEditDialog::initGUI() |
133 | { | 133 | { |
134 | #ifndef KAB_EMBEDDED | 134 | #ifndef KAB_EMBEDDED |
135 | resize( 490, 300 ); | 135 | resize( 490, 300 ); |
136 | #else //KAB_EMBEDDED | 136 | #else //KAB_EMBEDDED |
137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); | 137 | resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); |
138 | #endif //KAB_EMBEDDED | 138 | #endif //KAB_EMBEDDED |
139 | 139 | ||
140 | 140 | ||
141 | QWidget *page = plainPage(); | 141 | QWidget *page = plainPage(); |
142 | QLabel *label; | 142 | QLabel *label; |
143 | 143 | ||
144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); | 144 | QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); |
145 | 145 | ||
146 | label = new QLabel( i18n( "Name" ), page ); | 146 | label = new QLabel( i18n( "Name" ), page ); |
147 | mNameEdit = new KLineEdit( page ); | 147 | mNameEdit = new KLineEdit( page ); |
148 | mNameEdit->setFocus(); | 148 | mNameEdit->setFocus(); |
149 | topLayout->addWidget( label, 0, 0 ); | 149 | topLayout->addWidget( label, 0, 0 ); |
150 | topLayout->addWidget( mNameEdit, 0, 1 ); | 150 | topLayout->addWidget( mNameEdit, 0, 1 ); |
151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), | 151 | connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), |
152 | SLOT( filterNameTextChanged( const QString&) ) ); | 152 | SLOT( filterNameTextChanged( const QString&) ) ); |
153 | 153 | ||
154 | mCategoriesView = new KListView( page ); | 154 | mCategoriesView = new KListView( page ); |
155 | mCategoriesView->addColumn( i18n( "Categories" ) ); | 155 | mCategoriesView->addColumn( i18n( "Categories" ) ); |
156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); | 156 | topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); |
157 | 157 | ||
158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); | 158 | mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); |
159 | mMatchRuleGroup->setExclusive( true ); | 159 | mMatchRuleGroup->setExclusive( true ); |
160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); | 160 | QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); |
161 | radio->setChecked( true ); | ||
162 | //mMatchRuleGroup->insert( radio ); | 161 | //mMatchRuleGroup->insert( radio ); |
163 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); | 162 | radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); |
163 | radio->setChecked( true ); | ||
164 | //mMatchRuleGroup->insert( radio ); | 164 | //mMatchRuleGroup->insert( radio ); |
165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); | 165 | topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); |
166 | 166 | ||
167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); | 167 | QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); |
168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); | 168 | mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); |
169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); | 169 | mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); |
170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); | 170 | mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); |
171 | mPublic->setChecked( true ); | 171 | mPublic->setChecked( true ); |
172 | mPrivate->setChecked( true ); | 172 | mPrivate->setChecked( true ); |
173 | mConfidential->setChecked( true ); | 173 | mConfidential->setChecked( true ); |
174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); | 174 | topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) | 178 | void FilterEditDialog::filterNameTextChanged( const QString &text ) |
179 | { | 179 | { |
180 | enableButtonOK( !text.isEmpty() ); | 180 | enableButtonOK( !text.isEmpty() ); |
181 | } | 181 | } |
182 | 182 | ||
183 | void FilterEditDialog::slotHelp() | 183 | void FilterEditDialog::slotHelp() |
184 | { | 184 | { |
185 | #ifndef KAB_EMBEDDED | 185 | #ifndef KAB_EMBEDDED |
186 | kapp->invokeHelp( "using-filters" ); | 186 | kapp->invokeHelp( "using-filters" ); |
187 | #endif //KAB_EMBEDDED | 187 | #endif //KAB_EMBEDDED |
188 | } | 188 | } |
189 | 189 | ||
190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) | 190 | FilterDialog::FilterDialog( QWidget *parent, const char *name ) |
191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), | 191 | : KDialogBase( Plain, i18n( "Edit Address Book Filters" ), |
192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) | 192 | Ok | Cancel, Ok, parent, name, /*US false*/true, true ) |
193 | { | 193 | { |
194 | initGUI(); | 194 | initGUI(); |
195 | } | 195 | } |
196 | 196 | ||
197 | FilterDialog::~FilterDialog() | 197 | FilterDialog::~FilterDialog() |
198 | { | 198 | { |
199 | } | 199 | } |
200 | 200 | ||
201 | void FilterDialog::setFilters( const Filter::List &list ) | 201 | void FilterDialog::setFilters( const Filter::List &list ) |
202 | { | 202 | { |
203 | mFilterList.clear(); | 203 | mFilterList.clear(); |
204 | mInternalFilterList.clear(); | 204 | mInternalFilterList.clear(); |
205 | 205 | ||
206 | Filter::List::ConstIterator it; | 206 | Filter::List::ConstIterator it; |
207 | for ( it = list.begin(); it != list.end(); ++it ) { | 207 | for ( it = list.begin(); it != list.end(); ++it ) { |
208 | if ( (*it).isInternal() ) | 208 | if ( (*it).isInternal() ) |
209 | mInternalFilterList.append( *it ); | 209 | mInternalFilterList.append( *it ); |
210 | else | 210 | else |
211 | mFilterList.append( *it ); | 211 | mFilterList.append( *it ); |
212 | } | 212 | } |
213 | 213 | ||
214 | refresh(); | 214 | refresh(); |
215 | } | 215 | } |
216 | 216 | ||
217 | Filter::List FilterDialog::filters() const | 217 | Filter::List FilterDialog::filters() const |
218 | { | 218 | { |
219 | Filter::List list = mFilterList + mInternalFilterList; | 219 | Filter::List list = mFilterList + mInternalFilterList; |
220 | return list; | 220 | return list; |
221 | } | 221 | } |
222 | 222 | ||
223 | void FilterDialog::add() | 223 | void FilterDialog::add() |
224 | { | 224 | { |
225 | #ifndef KAB_EMBEDDED | 225 | #ifndef KAB_EMBEDDED |
226 | FilterEditDialog dlg( this ); | 226 | FilterEditDialog dlg( this ); |
227 | #else //KAB_EMBEDDED | 227 | #else //KAB_EMBEDDED |
228 | FilterEditDialog dlg( this->parentWidget() ); | 228 | FilterEditDialog dlg( this->parentWidget() ); |
229 | #endif //KAB_EMBEDDED | 229 | #endif //KAB_EMBEDDED |
230 | 230 | ||
231 | if ( dlg.exec() ) | 231 | if ( dlg.exec() ) |
232 | mFilterList.append( dlg.filter() ); | 232 | mFilterList.append( dlg.filter() ); |
233 | 233 | ||
234 | refresh(); | 234 | refresh(); |
235 | 235 | ||
236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); | 236 | mFilterListBox->setCurrentItem( mFilterListBox->count() - 1 ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void FilterDialog::edit() | 239 | void FilterDialog::edit() |
240 | { | 240 | { |
241 | FilterEditDialog dlg( this ); | 241 | FilterEditDialog dlg( this ); |
242 | 242 | ||
243 | uint pos = mFilterListBox->currentItem(); | 243 | uint pos = mFilterListBox->currentItem(); |
244 | 244 | ||
245 | dlg.setFilter( mFilterList[ pos ] ); | 245 | dlg.setFilter( mFilterList[ pos ] ); |
246 | 246 | ||
247 | if ( dlg.exec() ) { | 247 | if ( dlg.exec() ) { |
248 | mFilterList.remove( mFilterList.at( pos ) ); | 248 | mFilterList.remove( mFilterList.at( pos ) ); |
249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); | 249 | mFilterList.insert( mFilterList.at( pos ), dlg.filter() ); |
250 | } | 250 | } |
251 | 251 | ||
252 | refresh(); | 252 | refresh(); |
253 | 253 | ||
254 | mFilterListBox->setCurrentItem( pos ); | 254 | mFilterListBox->setCurrentItem( pos ); |
255 | } | 255 | } |
256 | 256 | ||
257 | void FilterDialog::remove() | 257 | void FilterDialog::remove() |
258 | { | 258 | { |
259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); | 259 | mFilterList.remove( mFilterList.at( mFilterListBox->currentItem() ) ); |