summaryrefslogtreecommitdiffabout
path: root/kaddressbook/filtereditdialog.cpp
Unidiff
Diffstat (limited to 'kaddressbook/filtereditdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/filtereditdialog.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/kaddressbook/filtereditdialog.cpp b/kaddressbook/filtereditdialog.cpp
index ef9b979..40698a7 100644
--- a/kaddressbook/filtereditdialog.cpp
+++ b/kaddressbook/filtereditdialog.cpp
@@ -19,104 +19,106 @@
19 As a special exception, permission is given to link this program 19 As a special exception, permission is given to link this program
20 with any edition of Qt, and distribute the resulting executable, 20 with any edition of Qt, and distribute the resulting executable,
21 without including the source code for Qt in the source distribution. 21 without including the source code for Qt in the source distribution.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qbuttongroup.h> 31#include <q3buttongroup.h>
32#include <qhbox.h> 32#include <q3hbox.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 <qcheckbox.h>
38#include <qregexp.h> 38#include <qregexp.h>
39#include <qstring.h> 39#include <qstring.h>
40#include <qtoolbutton.h> 40#include <qtoolbutton.h>
41#include <qtooltip.h> 41#include <qtooltip.h>
42#include <qwidget.h> 42#include <qwidget.h>
43//Added by qt3to4:
44#include <Q3GridLayout>
43 45
44#include <kapplication.h> 46#include <kapplication.h>
45#include <kbuttonbox.h> 47#include <kbuttonbox.h>
46#include <kdebug.h> 48#include <kdebug.h>
47#include <kiconloader.h> 49#include <kiconloader.h>
48#include <klineedit.h> 50#include <klineedit.h>
49#include <klistbox.h> 51#include <klistbox.h>
50#include <klistview.h> 52#include <klistview.h>
51#include <klocale.h> 53#include <klocale.h>
52#include <kglobal.h> 54#include <kglobal.h>
53 55
54#include "kabprefs.h" 56#include "kabprefs.h"
55#include "filtereditdialog.h" 57#include "filtereditdialog.h"
56 58
57FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name ) 59FilterEditDialog::FilterEditDialog( QWidget *parent, const char *name )
58 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ), 60 : KDialogBase( Plain, i18n( "Edit Address Book Filter" ),
59 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true ) 61 Help | Ok | Cancel, Ok, parent, name, /*US false*/ true, true )
60{ 62{
61 initGUI(); 63 initGUI();
62 64
63 QStringList cats = KABPrefs::instance()->mCustomCategories; 65 QStringList cats = KABPrefs::instance()->mCustomCategories;
64 66
65 QStringList::Iterator iter; 67 QStringList::Iterator iter;
66 for ( iter = cats.begin(); iter != cats.end(); ++iter ) 68 for ( iter = cats.begin(); iter != cats.end(); ++iter )
67 mCategoriesView->insertItem( new QCheckListItem( mCategoriesView, (*iter), QCheckListItem::CheckBox ) ); 69 mCategoriesView->insertItem( new Q3CheckListItem( mCategoriesView, (*iter), Q3CheckListItem::CheckBox ) );
68 filterNameTextChanged( mNameEdit->text() ); 70 filterNameTextChanged( mNameEdit->text() );
69} 71}
70 72
71FilterEditDialog::~FilterEditDialog() 73FilterEditDialog::~FilterEditDialog()
72{ 74{
73} 75}
74 76
75void FilterEditDialog::setFilter( const Filter &filter ) 77void FilterEditDialog::setFilter( const Filter &filter )
76{ 78{
77 mNameEdit->setText( filter.name() ); 79 mNameEdit->setText( filter.name() );
78 80
79 QStringList categories = filter.categories(); 81 QStringList categories = filter.categories();
80 QListViewItem *item = mCategoriesView->firstChild(); 82 Q3ListViewItem *item = mCategoriesView->firstChild();
81 while ( item != 0 ) { 83 while ( item != 0 ) {
82 if ( categories.contains( item->text( 0 ) ) ) { 84 if ( categories.contains( item->text( 0 ) ) ) {
83 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 85 Q3CheckListItem *checkItem = static_cast<Q3CheckListItem*>( item );
84 checkItem->setOn( true ); 86 checkItem->setOn( true );
85 } 87 }
86 88
87 item = item->nextSibling(); 89 item = item->nextSibling();
88 } 90 }
89 91
90 if ( filter.matchRule() == Filter::Matching ) 92 if ( filter.matchRule() == Filter::Matching )
91 mMatchRuleGroup->setButton( 0 ); 93 mMatchRuleGroup->setButton( 0 );
92 else 94 else
93 mMatchRuleGroup->setButton( 1 ); 95 mMatchRuleGroup->setButton( 1 );
94 96
95 int c = filter.criteria() ; 97 int c = filter.criteria() ;
96 mPublic->setChecked(c &Filter::ShowPublic); 98 mPublic->setChecked(c &Filter::ShowPublic);
97 mPrivate->setChecked(c & Filter::ShowPrivate); 99 mPrivate->setChecked(c & Filter::ShowPrivate);
98 mConfidential->setChecked(c & Filter::ShowConfidential); 100 mConfidential->setChecked(c & Filter::ShowConfidential);
99} 101}
100 102
101Filter FilterEditDialog::filter() 103Filter FilterEditDialog::filter()
102{ 104{
103 Filter filter; 105 Filter filter;
104 106
105 filter.setName( mNameEdit->text() ); 107 filter.setName( mNameEdit->text() );
106 108
107 QStringList categories; 109 QStringList categories;
108 QListViewItem *item = mCategoriesView->firstChild(); 110 Q3ListViewItem *item = mCategoriesView->firstChild();
109 while ( item != 0 ) { 111 while ( item != 0 ) {
110 QCheckListItem *checkItem = static_cast<QCheckListItem*>( item ); 112 Q3CheckListItem *checkItem = static_cast<Q3CheckListItem*>( item );
111 if ( checkItem->isOn() ) 113 if ( checkItem->isOn() )
112 categories.append( item->text( 0 ) ); 114 categories.append( item->text( 0 ) );
113 115
114 item = item->nextSibling(); 116 item = item->nextSibling();
115 } 117 }
116 filter.setCategories( categories ); 118 filter.setCategories( categories );
117 119
118 if ( mMatchRuleGroup->find( 0 )->isOn() ) 120 if ( mMatchRuleGroup->find( 0 )->isOn() )
119 filter.setMatchRule( Filter::Matching ); 121 filter.setMatchRule( Filter::Matching );
120 else 122 else
121 filter.setMatchRule( Filter::NotMatching ); 123 filter.setMatchRule( Filter::NotMatching );
122 124
@@ -132,48 +134,48 @@ Filter FilterEditDialog::filter()
132void FilterEditDialog::initGUI() 134void FilterEditDialog::initGUI()
133{ 135{
134#ifndef KAB_EMBEDDED 136#ifndef KAB_EMBEDDED
135 resize( 490, 300 ); 137 resize( 490, 300 );
136#else //KAB_EMBEDDED 138#else //KAB_EMBEDDED
137 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300)); 139 resize( KMIN(KGlobal::getDesktopWidth()-10, 490), KMIN(KGlobal::getDesktopHeight()-50, 300));
138#endif //KAB_EMBEDDED 140#endif //KAB_EMBEDDED
139 141
140 142
141 QWidget *page = plainPage(); 143 QWidget *page = plainPage();
142 QLabel *label; 144 QLabel *label;
143 145
144 QGridLayout *topLayout = new QGridLayout( page, 3, 2, 0, spacingHint() ); 146 Q3GridLayout *topLayout = new Q3GridLayout( page, 3, 2, 0, spacingHint() );
145 147
146 label = new QLabel( i18n( "Name" ), page ); 148 label = new QLabel( i18n( "Name" ), page );
147 mNameEdit = new KLineEdit( page ); 149 mNameEdit = new KLineEdit( page );
148 mNameEdit->setFocus(); 150 mNameEdit->setFocus();
149 topLayout->addWidget( label, 0, 0 ); 151 topLayout->addWidget( label, 0, 0 );
150 topLayout->addWidget( mNameEdit, 0, 1 ); 152 topLayout->addWidget( mNameEdit, 0, 1 );
151 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ), 153 connect( mNameEdit, SIGNAL( textChanged( const QString& ) ),
152 SLOT( filterNameTextChanged( const QString&) ) ); 154 SLOT( filterNameTextChanged( const QString&) ) );
153 155
154 mCategoriesView = new KListView( page ); 156 mCategoriesView = new KListView( page );
155 mCategoriesView->addColumn( i18n( "Categories" ) ); 157 mCategoriesView->addColumn( i18n( "Categories" ) );
156 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 ); 158 topLayout->addMultiCellWidget( mCategoriesView, 1, 1, 0, 1 );
157 159
158 mMatchRuleGroup = new QHButtonGroup( i18n( "Category rule" ), page ); 160 mMatchRuleGroup = new Q3HButtonGroup( i18n( "Category rule" ), page );
159 mMatchRuleGroup->setExclusive( true ); 161 mMatchRuleGroup->setExclusive( true );
160 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup ); 162 QRadioButton *radio = new QRadioButton( i18n( "Include categories" ), mMatchRuleGroup );
161 //mMatchRuleGroup->insert( radio ); 163 //mMatchRuleGroup->insert( radio );
162 radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup ); 164 radio = new QRadioButton( i18n( "Exclude categories" ), mMatchRuleGroup );
163 radio->setChecked( true ); 165 radio->setChecked( true );
164 //mMatchRuleGroup->insert( radio ); 166 //mMatchRuleGroup->insert( radio );
165 topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 ); 167 topLayout->addMultiCellWidget( mMatchRuleGroup, 2, 2, 0, 1 );
166 168
167 QHButtonGroup * mMatchPPCGroup = new QHButtonGroup(i18n( "Include contacts, that are:" ), page ); 169 Q3HButtonGroup * mMatchPPCGroup = new Q3HButtonGroup(i18n( "Include contacts, that are:" ), page );
168 mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup ); 170 mPublic = new QCheckBox( i18n( "public" ), mMatchPPCGroup );
169 mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup ); 171 mPrivate = new QCheckBox( i18n( "private" ), mMatchPPCGroup );
170 mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup ); 172 mConfidential = new QCheckBox( i18n( "confidential" ), mMatchPPCGroup );
171 mPublic->setChecked( true ); 173 mPublic->setChecked( true );
172 mPrivate->setChecked( true ); 174 mPrivate->setChecked( true );
173 mConfidential->setChecked( true ); 175 mConfidential->setChecked( true );
174 topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 ); 176 topLayout->addMultiCellWidget( mMatchPPCGroup, 3, 3, 0, 1 );
175 177
176} 178}
177 179
178void FilterEditDialog::filterNameTextChanged( const QString &text ) 180void FilterEditDialog::filterNameTextChanged( const QString &text )
179{ 181{
@@ -263,53 +265,53 @@ void FilterDialog::remove()
263 refresh(); 265 refresh();
264} 266}
265 267
266void FilterDialog::refresh() 268void FilterDialog::refresh()
267{ 269{
268 mFilterListBox->clear(); 270 mFilterListBox->clear();
269 271
270 Filter::List::Iterator iter; 272 Filter::List::Iterator iter;
271 for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter ) 273 for ( iter = mFilterList.begin(); iter != mFilterList.end(); ++iter )
272 mFilterListBox->insertItem( (*iter).name() ); 274 mFilterListBox->insertItem( (*iter).name() );
273} 275}
274 276
275void FilterDialog::selectionChanged( QListBoxItem *item ) 277void FilterDialog::selectionChanged( Q3ListBoxItem *item )
276{ 278{
277 bool state = ( item != 0 ); 279 bool state = ( item != 0 );
278 280
279 mEditButton->setEnabled( state ); 281 mEditButton->setEnabled( state );
280 mRemoveButton->setEnabled( state ); 282 mRemoveButton->setEnabled( state );
281} 283}
282 284
283void FilterDialog::initGUI() 285void FilterDialog::initGUI()
284{ 286{
285#ifndef KAB_EMBEDDED 287#ifndef KAB_EMBEDDED
286 resize( 330, 200 ); 288 resize( 330, 200 );
287#else //KAB_EMBEDDED 289#else //KAB_EMBEDDED
288 resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200)); 290 resize( KMIN(KGlobal::getDesktopWidth()-10, 330), KMIN(KGlobal::getDesktopHeight()-50, 200));
289#endif //KAB_EMBEDDED 291#endif //KAB_EMBEDDED
290 292
291 QWidget *page = plainPage(); 293 QWidget *page = plainPage();
292 294
293 QGridLayout *topLayout = new QGridLayout( page, 1, 2, 0, spacingHint() ); 295 Q3GridLayout *topLayout = new Q3GridLayout( page, 1, 2, 0, spacingHint() );
294 296
295 mFilterListBox = new KListBox( page ); 297 mFilterListBox = new KListBox( page );
296 topLayout->addWidget( mFilterListBox, 0, 0 ); 298 topLayout->addWidget( mFilterListBox, 0, 0 );
297 connect( mFilterListBox, SIGNAL( selectionChanged( QListBoxItem * ) ), 299 connect( mFilterListBox, SIGNAL( selectionChanged( Q3ListBoxItem * ) ),
298 SLOT( selectionChanged( QListBoxItem * ) ) ); 300 SLOT( selectionChanged( Q3ListBoxItem * ) ) );
299 connect( mFilterListBox, SIGNAL( doubleClicked ( QListBoxItem * ) ), 301 connect( mFilterListBox, SIGNAL( doubleClicked ( Q3ListBoxItem * ) ),
300 SLOT( edit() ) ); 302 SLOT( edit() ) );
301 303
302 KButtonBox *buttonBox = new KButtonBox( page, Vertical ); 304 KButtonBox *buttonBox = new KButtonBox( page, Qt::Vertical );
303 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) ); 305 buttonBox->addButton( i18n( "&Add..." ), this, SLOT( add() ) );
304 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) ); 306 mEditButton = buttonBox->addButton( i18n( "&Edit..." ), this, SLOT( edit() ) );
305 mEditButton->setEnabled( false ); 307 mEditButton->setEnabled( false );
306 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) ); 308 mRemoveButton = buttonBox->addButton( i18n( "&Remove" ), this, SLOT( remove() ) );
307 mRemoveButton->setEnabled( false ); 309 mRemoveButton->setEnabled( false );
308 310
309 buttonBox->layout(); 311 buttonBox->layout();
310 topLayout->addWidget( buttonBox, 0, 1 ); 312 topLayout->addWidget( buttonBox, 0, 1 );
311} 313}
312 314
313#ifndef KAB_EMBEDDED 315#ifndef KAB_EMBEDDED_
314#include "filtereditdialog.moc" 316#include "moc_filtereditdialog.cpp"
315#endif //KAB_EMBEDDED 317#endif //KAB_EMBEDDED