summaryrefslogtreecommitdiffabout
path: root/kaddressbook/incsearchwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/incsearchwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 5f8b83d..a54d1cd 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,98 +1,102 @@
1/* 1/*
2 This file is part of KAddressBook. 2 This file is part of KAddressBook.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software 16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 18
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#include <qlabel.h> 24#include <qlabel.h>
25#include <qlayout.h> 25#include <qlayout.h>
26#include <qtooltip.h> 26#include <qtooltip.h>
27#include <qapplication.h> 27#include <qapplication.h>
28#include <QDesktopWidget>
28#include <qcombobox.h> 29#include <qcombobox.h>
30//Added by qt3to4:
31#include <Q3HBoxLayout>
29 32
30#include <kdialog.h> 33#include <kdialog.h>
31#include <klineedit.h> 34#include <klineedit.h>
32#include <klocale.h> 35#include <klocale.h>
33#include <kglobal.h> 36#include <kglobal.h>
34#include <kglobal.h> 37#include <kglobal.h>
35#include "kabprefs.h" 38#include "kabprefs.h"
36 39
37#include "incsearchwidget.h" 40#include "incsearchwidget.h"
38 41
39IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 42IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
40 : QWidget( parent, name )
41{ 43{
44 setObjectName(name);
45 setParent(parent);
42#ifndef KAB_EMBEDDED 46#ifndef KAB_EMBEDDED
43//US setCaption( i18n( "Incremental Search" ) ); 47//US setCaption( i18n( "Incremental Search" ) );
44#endif //KAB_EMBEDDED 48#endif //KAB_EMBEDDED
45 49
46 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 50 Q3HBoxLayout *layout = new Q3HBoxLayout( this, 2, KDialog::spacingHint() );
47 51
48#ifdef DESKTOP_VERSION 52#ifdef DESKTOP_VERSION
49 QLabel *label = new QLabel( i18n( "Search:" ), this ); 53 QLabel *label = new QLabel( i18n( "Search:" ), this );
50 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 54 label->setAlignment( Qt::AlignVCenter | Qt::AlignRight );
51 layout->addWidget( label ); 55 layout->addWidget( label );
52#endif //KAB_EMBEDDED 56#endif //KAB_EMBEDDED
53 57
54 mSearchText = new KLineEdit( this ); 58 mSearchText = new KLineEdit( this );
55 layout->addWidget( mSearchText ); 59 layout->addWidget( mSearchText );
56// #ifdef KAB_EMBEDDED 60// #ifdef KAB_EMBEDDED
57// if (KGlobal::getOrientation() == KGlobal::Portrait) 61// if (KGlobal::getOrientation() == KGlobal::Portrait)
58// mSearchText->setMaximumWidth(30); 62// mSearchText->setMaximumWidth(30);
59// #endif //KAB_EMBEDDED 63// #endif //KAB_EMBEDDED
60 //mSearchText->setMaximumWidth(60); 64 //mSearchText->setMaximumWidth(60);
61 65
62 66
63 mFieldCombo = new QComboBox( false, this ); 67 mFieldCombo = new QComboBox( false, this );
64 layout->addWidget( mFieldCombo ); 68 layout->addWidget( mFieldCombo );
65 mFieldCombo->setMaximumHeight( 34 ); 69 mFieldCombo->setMaximumHeight( 34 );
66 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 70 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
67 71
68// #ifndef KAB_EMBEDDED 72// #ifndef KAB_EMBEDDED
69// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 73// resize( QSize(420, 50).expandedTo( sizeHint() ) );
70// #else //KAB_EMBEDDED 74// #else //KAB_EMBEDDED
71// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 75// resize( QSize(30, 10).expandedTo( sizeHint() ) );
72// #endif //KAB_EMBEDDED 76// #endif //KAB_EMBEDDED
73 77
74 78
75 // for performance reasons, we do a search on the pda only after return is pressed 79 // for performance reasons, we do a search on the pda only after return is pressed
76 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 80 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
77 SLOT( announceDoSearch2() ) ); 81 SLOT( announceDoSearch2() ) );
78 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
79 SLOT( announceDoSearch2() ) ); 83 SLOT( announceDoSearch2() ) );
80 84
81 connect( mSearchText, SIGNAL( returnPressed() ), 85 connect( mSearchText, SIGNAL( returnPressed() ),
82 SLOT( announceDoSearch() ) ); 86 SLOT( announceDoSearch() ) );
83 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 87 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
84 SLOT( announceFieldChanged() ) ); 88 SLOT( announceFieldChanged() ) );
85 89
86 90
87 91
88 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 92 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
89 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 93 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
90 94
91 95
92 setFocusProxy( mSearchText ); 96 setFocusProxy( mSearchText );
93} 97}
94 98
95IncSearchWidget::~IncSearchWidget() 99IncSearchWidget::~IncSearchWidget()
96{ 100{
97 101
98} 102}
@@ -131,51 +135,51 @@ void IncSearchWidget::setSize()
131 wid = wid * 2; 135 wid = wid * 2;
132#endif 136#endif
133 mFieldCombo->setMaximumWidth( wid+60 ); 137 mFieldCombo->setMaximumWidth( wid+60 );
134 mSearchText->setMaximumWidth( 1024 ); 138 mSearchText->setMaximumWidth( 1024 );
135 } 139 }
136} 140}
137void IncSearchWidget::setFields( const KABC::Field::List &list ) 141void IncSearchWidget::setFields( const KABC::Field::List &list )
138{ 142{
139 143
140 mFieldCombo->clear(); 144 mFieldCombo->clear();
141 mFieldCombo->insertItem( i18n( "All Fields" ) ); 145 mFieldCombo->insertItem( i18n( "All Fields" ) );
142 146
143 KABC::Field::List::ConstIterator it; 147 KABC::Field::List::ConstIterator it;
144 for ( it = list.begin(); it != list.end(); ++it ) { 148 for ( it = list.begin(); it != list.end(); ++it ) {
145 mFieldCombo->insertItem( (*it)->label() ); 149 mFieldCombo->insertItem( (*it)->label() );
146 } 150 }
147 151
148 mFieldList = list; 152 mFieldList = list;
149 153
150 announceDoSearch(); 154 announceDoSearch();
151 announceFieldChanged(); 155 announceFieldChanged();
152 setSize(); 156 setSize();
153} 157}
154 158
155KABC::Field::List IncSearchWidget::fields() const 159KABC::Field::List IncSearchWidget::fields() const
156{ 160{
157 return mFieldList; 161 return mFieldList;
158} 162}
159 163
160KABC::Field *IncSearchWidget::currentField()const 164KABC::Field *IncSearchWidget::currentField()const
161{ 165{
162 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 166 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
163 return 0; // for error or 'use all fields' 167 return 0; // for error or 'use all fields'
164 else 168 else
165 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 169 return mFieldList[ mFieldCombo->currentItem() - 1 ];
166} 170}
167 171
168void IncSearchWidget::setCurrentItem( int pos ) 172void IncSearchWidget::setCurrentItem( int pos )
169{ 173{
170 mFieldCombo->setCurrentItem( pos ); 174 mFieldCombo->setCurrentItem( pos );
171 announceFieldChanged(); 175 announceFieldChanged();
172} 176}
173 177
174int IncSearchWidget::currentItem() const 178int IncSearchWidget::currentItem() const
175{ 179{
176 180
177 return mFieldCombo->currentItem(); 181 return mFieldCombo->currentItem();
178} 182}
179#ifndef KAB_EMBEDDED 183#ifndef KAB_EMBEDDED_
180#include "incsearchwidget.moc" 184#include "moc_incsearchwidget.cpp"
181#endif //KAB_EMBEDDED 185#endif //KAB_EMBEDDED