summaryrefslogtreecommitdiffabout
path: root/kaddressbook/incsearchwidget.cpp
Unidiff
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
@@ -109,39 +109,45 @@ void IncSearchWidget::announceDoSearch()
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