summaryrefslogtreecommitdiffabout
path: root/kaddressbook/incsearchwidget.cpp
authorzautrix <zautrix>2005-03-29 13:52:41 (UTC)
committer zautrix <zautrix>2005-03-29 13:52:41 (UTC)
commit7046b36fb5dd14598ece00b575554eba2956ef84 (patch) (unidiff)
tree934579f9f61f09563dfcbfef207d314d510d57ea /kaddressbook/incsearchwidget.cpp
parent894717798a8d129f4b991a2fe856d2f1e8e9624a (diff)
downloadkdepimpi-7046b36fb5dd14598ece00b575554eba2956ef84.zip
kdepimpi-7046b36fb5dd14598ece00b575554eba2956ef84.tar.gz
kdepimpi-7046b36fb5dd14598ece00b575554eba2956ef84.tar.bz2
kapi fixes
Diffstat (limited to 'kaddressbook/incsearchwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index dd2121a..cd198c4 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -69,100 +69,106 @@ IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
69// #else //KAB_EMBEDDED 69// #else //KAB_EMBEDDED
70// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 70// resize( QSize(30, 10).expandedTo( sizeHint() ) );
71// #endif //KAB_EMBEDDED 71// #endif //KAB_EMBEDDED
72 72
73 73
74 // for performance reasons, we do a search on the pda only after return is pressed 74 // for performance reasons, we do a search on the pda only after return is pressed
75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 75 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
76 SLOT( announceDoSearch2() ) ); 76 SLOT( announceDoSearch2() ) );
77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 77 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
78 SLOT( announceDoSearch2() ) ); 78 SLOT( announceDoSearch2() ) );
79 79
80 connect( mSearchText, SIGNAL( returnPressed() ), 80 connect( mSearchText, SIGNAL( returnPressed() ),
81 SLOT( announceDoSearch() ) ); 81 SLOT( announceDoSearch() ) );
82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 82 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
83 SLOT( announceFieldChanged() ) ); 83 SLOT( announceFieldChanged() ) );
84 84
85 85
86 86
87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() )); 87 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() )); 88 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
89 89
90 90
91 setFocusProxy( mSearchText ); 91 setFocusProxy( mSearchText );
92} 92}
93 93
94IncSearchWidget::~IncSearchWidget() 94IncSearchWidget::~IncSearchWidget()
95{ 95{
96 96
97} 97}
98void IncSearchWidget::announceDoSearch2() 98void IncSearchWidget::announceDoSearch2()
99{ 99{
100 if ( KABPrefs::instance()->mSearchWithReturn ) 100 if ( KABPrefs::instance()->mSearchWithReturn )
101 return; 101 return;
102 emit doSearch( mSearchText->text() ); 102 emit doSearch( mSearchText->text() );
103 //qDebug("emit dosreach "); 103 //qDebug("emit dosreach ");
104} 104}
105 105
106void IncSearchWidget::announceDoSearch() 106void IncSearchWidget::announceDoSearch()
107{ 107{
108 108
109 emit doSearch( mSearchText->text() ); 109 emit doSearch( mSearchText->text() );
110 // qDebug("emit dosreach "); 110 // qDebug("emit dosreach ");
111} 111}
112 112
113void IncSearchWidget::announceFieldChanged() 113void IncSearchWidget::announceFieldChanged()
114{ 114{
115 emit fieldChanged(); 115 emit fieldChanged();
116} 116}
117 117void IncSearchWidget::setSize()
118{
119 if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
120 mFieldCombo->setMaximumWidth( 40 );
121 mSearchText->setMaximumWidth( 30 );
122 } else {
123 QFontMetrics fm ( mFieldCombo->font() );
124 int wid = fm.width(i18n( "All Fields" ) );
125 int max = wid;
126 mFieldCombo->setMaximumWidth( wid+60 );
127 mSearchText->setMaximumWidth( 1024 );
128 }
129}
118void IncSearchWidget::setFields( const KABC::Field::List &list ) 130void IncSearchWidget::setFields( const KABC::Field::List &list )
119{ 131{
120 132
121 mFieldCombo->clear(); 133 mFieldCombo->clear();
122 mFieldCombo->insertItem( i18n( "All Fields" ) ); 134 mFieldCombo->insertItem( i18n( "All Fields" ) );
123 QFontMetrics fm ( mFieldCombo->font() ); 135
124 int wid = fm.width(i18n( "All Fields" ) );
125 int max = wid;
126
127 KABC::Field::List::ConstIterator it; 136 KABC::Field::List::ConstIterator it;
128 for ( it = list.begin(); it != list.end(); ++it ) { 137 for ( it = list.begin(); it != list.end(); ++it ) {
129 mFieldCombo->insertItem( (*it)->label() ); 138 mFieldCombo->insertItem( (*it)->label() );
130 // wid = fm.width((*it)->label() );
131 //if ( wid > max )
132 // max = wid;
133 } 139 }
134 140
135 mFieldList = list; 141 mFieldList = list;
136 142
137 announceDoSearch(); 143 announceDoSearch();
138 announceFieldChanged(); 144 announceFieldChanged();
139 mFieldCombo->setMaximumWidth( wid+60 ); 145 setSize();
140} 146}
141 147
142KABC::Field::List IncSearchWidget::fields() const 148KABC::Field::List IncSearchWidget::fields() const
143{ 149{
144 return mFieldList; 150 return mFieldList;
145} 151}
146 152
147KABC::Field *IncSearchWidget::currentField()const 153KABC::Field *IncSearchWidget::currentField()const
148{ 154{
149 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 155 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
150 return 0; // for error or 'use all fields' 156 return 0; // for error or 'use all fields'
151 else 157 else
152 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 158 return mFieldList[ mFieldCombo->currentItem() - 1 ];
153} 159}
154 160
155void IncSearchWidget::setCurrentItem( int pos ) 161void IncSearchWidget::setCurrentItem( int pos )
156{ 162{
157 mFieldCombo->setCurrentItem( pos ); 163 mFieldCombo->setCurrentItem( pos );
158 announceFieldChanged(); 164 announceFieldChanged();
159} 165}
160 166
161int IncSearchWidget::currentItem() const 167int IncSearchWidget::currentItem() const
162{ 168{
163 169
164 return mFieldCombo->currentItem(); 170 return mFieldCombo->currentItem();
165} 171}
166#ifndef KAB_EMBEDDED 172#ifndef KAB_EMBEDDED
167#include "incsearchwidget.moc" 173#include "incsearchwidget.moc"
168#endif //KAB_EMBEDDED 174#endif //KAB_EMBEDDED