summaryrefslogtreecommitdiffabout
path: root/kaddressbook
authorzautrix <zautrix>2005-03-29 23:22:24 (UTC)
committer zautrix <zautrix>2005-03-29 23:22:24 (UTC)
commit99324133d35ba588b688bc5b22788fd8fb9e752d (patch) (unidiff)
tree8a18635a5a21b27bffa6b00f945e949ed49908f0 /kaddressbook
parent3262285c2fd6739c518880deb4d37153875069b5 (diff)
downloadkdepimpi-99324133d35ba588b688bc5b22788fd8fb9e752d.zip
kdepimpi-99324133d35ba588b688bc5b22788fd8fb9e752d.tar.gz
kdepimpi-99324133d35ba588b688bc5b22788fd8fb9e752d.tar.bz2
test
Diffstat (limited to 'kaddressbook') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index cd198c4..314de10 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -1,174 +1,175 @@
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 <qcombobox.h> 28#include <qcombobox.h>
28 29
29#include <kdialog.h> 30#include <kdialog.h>
30#include <klineedit.h> 31#include <klineedit.h>
31#include <klocale.h> 32#include <klocale.h>
32#include <kglobal.h> 33#include <kglobal.h>
33#include <kglobal.h> 34#include <kglobal.h>
34#include "kabprefs.h" 35#include "kabprefs.h"
35 36
36#include "incsearchwidget.h" 37#include "incsearchwidget.h"
37 38
38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 39IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
39 : QWidget( parent, name ) 40 : QWidget( parent, name )
40{ 41{
41#ifndef KAB_EMBEDDED 42#ifndef KAB_EMBEDDED
42//US setCaption( i18n( "Incremental Search" ) ); 43//US setCaption( i18n( "Incremental Search" ) );
43#endif //KAB_EMBEDDED 44#endif //KAB_EMBEDDED
44 45
45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 46 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
46 47
47#ifdef DESKTOP_VERSION 48#ifdef DESKTOP_VERSION
48 QLabel *label = new QLabel( i18n( "Search:" ), this ); 49 QLabel *label = new QLabel( i18n( "Search:" ), this );
49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 50 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
50 layout->addWidget( label ); 51 layout->addWidget( label );
51#endif //KAB_EMBEDDED 52#endif //KAB_EMBEDDED
52 53
53 mSearchText = new KLineEdit( this ); 54 mSearchText = new KLineEdit( this );
54 layout->addWidget( mSearchText ); 55 layout->addWidget( mSearchText );
55// #ifdef KAB_EMBEDDED 56// #ifdef KAB_EMBEDDED
56// if (KGlobal::getOrientation() == KGlobal::Portrait) 57// if (KGlobal::getOrientation() == KGlobal::Portrait)
57// mSearchText->setMaximumWidth(30); 58// mSearchText->setMaximumWidth(30);
58// #endif //KAB_EMBEDDED 59// #endif //KAB_EMBEDDED
59 //mSearchText->setMaximumWidth(60); 60 //mSearchText->setMaximumWidth(60);
60 61
61 62
62 mFieldCombo = new QComboBox( false, this ); 63 mFieldCombo = new QComboBox( false, this );
63 layout->addWidget( mFieldCombo ); 64 layout->addWidget( mFieldCombo );
64 mFieldCombo->setMaximumHeight( 34 ); 65 mFieldCombo->setMaximumHeight( 34 );
65 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 66 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
66 67
67// #ifndef KAB_EMBEDDED 68// #ifndef KAB_EMBEDDED
68// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 69// resize( QSize(420, 50).expandedTo( sizeHint() ) );
69// #else //KAB_EMBEDDED 70// #else //KAB_EMBEDDED
70// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 71// resize( QSize(30, 10).expandedTo( sizeHint() ) );
71// #endif //KAB_EMBEDDED 72// #endif //KAB_EMBEDDED
72 73
73 74
74 // for performance reasons, we do a search on the pda only after return is pressed 75 // for performance reasons, we do a search on the pda only after return is pressed
75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 76 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
76 SLOT( announceDoSearch2() ) ); 77 SLOT( announceDoSearch2() ) );
77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 78 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
78 SLOT( announceDoSearch2() ) ); 79 SLOT( announceDoSearch2() ) );
79 80
80 connect( mSearchText, SIGNAL( returnPressed() ), 81 connect( mSearchText, SIGNAL( returnPressed() ),
81 SLOT( announceDoSearch() ) ); 82 SLOT( announceDoSearch() ) );
82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 83 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
83 SLOT( announceFieldChanged() ) ); 84 SLOT( announceFieldChanged() ) );
84 85
85 86
86 87
87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 88 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 89 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
89 90
90 91
91 setFocusProxy( mSearchText ); 92 setFocusProxy( mSearchText );
92} 93}
93 94
94IncSearchWidget::~IncSearchWidget() 95IncSearchWidget::~IncSearchWidget()
95{ 96{
96 97
97} 98}
98void IncSearchWidget::announceDoSearch2() 99void IncSearchWidget::announceDoSearch2()
99{ 100{
100 if ( KABPrefs::instance()->mSearchWithReturn ) 101 if ( KABPrefs::instance()->mSearchWithReturn )
101 return; 102 return;
102 emit doSearch( mSearchText->text() ); 103 emit doSearch( mSearchText->text() );
103 //qDebug("emit dosreach "); 104 //qDebug("emit dosreach ");
104} 105}
105 106
106void IncSearchWidget::announceDoSearch() 107void IncSearchWidget::announceDoSearch()
107{ 108{
108 109
109 emit doSearch( mSearchText->text() ); 110 emit doSearch( mSearchText->text() );
110 // qDebug("emit dosreach "); 111 // qDebug("emit dosreach ");
111} 112}
112 113
113void IncSearchWidget::announceFieldChanged() 114void IncSearchWidget::announceFieldChanged()
114{ 115{
115 emit fieldChanged(); 116 emit fieldChanged();
116} 117}
117void IncSearchWidget::setSize() 118void IncSearchWidget::setSize()
118{ 119{
119 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) { 120 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
120 mFieldCombo->setMaximumWidth( 40 ); 121 mFieldCombo->setMaximumWidth( 40 );
121 mSearchText->setMaximumWidth( 30 ); 122 mSearchText->setMaximumWidth( 30 );
122 } else { 123 } else {
123 QFontMetrics fm ( mFieldCombo->font() ); 124 QFontMetrics fm ( mFieldCombo->font() );
124 int wid = fm.width(i18n( "All Fields" ) ); 125 int wid = fm.width(i18n( "All Fields" ) );
125 int max = wid; 126 int max = wid;
126 mFieldCombo->setMaximumWidth( wid+60 ); 127 mFieldCombo->setMaximumWidth( wid+60 );
127 mSearchText->setMaximumWidth( 1024 ); 128 mSearchText->setMaximumWidth( 1024 );
128 } 129 }
129} 130}
130void IncSearchWidget::setFields( const KABC::Field::List &list ) 131void IncSearchWidget::setFields( const KABC::Field::List &list )
131{ 132{
132 133
133 mFieldCombo->clear(); 134 mFieldCombo->clear();
134 mFieldCombo->insertItem( i18n( "All Fields" ) ); 135 mFieldCombo->insertItem( i18n( "All Fields" ) );
135 136
136 KABC::Field::List::ConstIterator it; 137 KABC::Field::List::ConstIterator it;
137 for ( it = list.begin(); it != list.end(); ++it ) { 138 for ( it = list.begin(); it != list.end(); ++it ) {
138 mFieldCombo->insertItem( (*it)->label() ); 139 mFieldCombo->insertItem( (*it)->label() );
139 } 140 }
140 141
141 mFieldList = list; 142 mFieldList = list;
142 143
143 announceDoSearch(); 144 announceDoSearch();
144 announceFieldChanged(); 145 announceFieldChanged();
145 setSize(); 146 setSize();
146} 147}
147 148
148KABC::Field::List IncSearchWidget::fields() const 149KABC::Field::List IncSearchWidget::fields() const
149{ 150{
150 return mFieldList; 151 return mFieldList;
151} 152}
152 153
153KABC::Field *IncSearchWidget::currentField()const 154KABC::Field *IncSearchWidget::currentField()const
154{ 155{
155 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 156 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
156 return 0; // for error or 'use all fields' 157 return 0; // for error or 'use all fields'
157 else 158 else
158 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 159 return mFieldList[ mFieldCombo->currentItem() - 1 ];
159} 160}
160 161
161void IncSearchWidget::setCurrentItem( int pos ) 162void IncSearchWidget::setCurrentItem( int pos )
162{ 163{
163 mFieldCombo->setCurrentItem( pos ); 164 mFieldCombo->setCurrentItem( pos );
164 announceFieldChanged(); 165 announceFieldChanged();
165} 166}
166 167
167int IncSearchWidget::currentItem() const 168int IncSearchWidget::currentItem() const
168{ 169{
169 170
170 return mFieldCombo->currentItem(); 171 return mFieldCombo->currentItem();
171} 172}
172#ifndef KAB_EMBEDDED 173#ifndef KAB_EMBEDDED
173#include "incsearchwidget.moc" 174#include "incsearchwidget.moc"
174#endif //KAB_EMBEDDED 175#endif //KAB_EMBEDDED