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) (side-by-side diff)
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 )
// #else //KAB_EMBEDDED
// resize( QSize(30, 10).expandedTo( sizeHint() ) );
// #endif //KAB_EMBEDDED
// for performance reasons, we do a search on the pda only after return is pressed
connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
SLOT( announceDoSearch2() ) );
connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
SLOT( announceDoSearch2() ) );
connect( mSearchText, SIGNAL( returnPressed() ),
SLOT( announceDoSearch() ) );
connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
SLOT( announceFieldChanged() ) );
connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
setFocusProxy( mSearchText );
}
IncSearchWidget::~IncSearchWidget()
{
}
void IncSearchWidget::announceDoSearch2()
{
if ( KABPrefs::instance()->mSearchWithReturn )
return;
emit doSearch( mSearchText->text() );
//qDebug("emit dosreach ");
}
void IncSearchWidget::announceDoSearch()
{
emit doSearch( mSearchText->text() );
// qDebug("emit dosreach ");
}
void IncSearchWidget::announceFieldChanged()
{
emit fieldChanged();
}
-
+void IncSearchWidget::setSize()
+{
+ if ( KABPrefs::instance()->mHideSearchOnSwitch && QApplication::desktop()->width() == 480) {
+ mFieldCombo->setMaximumWidth( 40 );
+ mSearchText->setMaximumWidth( 30 );
+ } else {
+ QFontMetrics fm ( mFieldCombo->font() );
+ int wid = fm.width(i18n( "All Fields" ) );
+ int max = wid;
+ mFieldCombo->setMaximumWidth( wid+60 );
+ mSearchText->setMaximumWidth( 1024 );
+ }
+}
void IncSearchWidget::setFields( const KABC::Field::List &list )
{
mFieldCombo->clear();
mFieldCombo->insertItem( i18n( "All Fields" ) );
- QFontMetrics fm ( mFieldCombo->font() );
- int wid = fm.width(i18n( "All Fields" ) );
- int max = wid;
-
+
KABC::Field::List::ConstIterator it;
for ( it = list.begin(); it != list.end(); ++it ) {
mFieldCombo->insertItem( (*it)->label() );
- // wid = fm.width((*it)->label() );
- //if ( wid > max )
- // max = wid;
}
mFieldList = list;
announceDoSearch();
announceFieldChanged();
- mFieldCombo->setMaximumWidth( wid+60 );
+ setSize();
}
KABC::Field::List IncSearchWidget::fields() const
{
return mFieldList;
}
KABC::Field *IncSearchWidget::currentField()const
{
if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
return 0; // for error or 'use all fields'
else
return mFieldList[ mFieldCombo->currentItem() - 1 ];
}
void IncSearchWidget::setCurrentItem( int pos )
{
mFieldCombo->setCurrentItem( pos );
announceFieldChanged();
}
int IncSearchWidget::currentItem() const
{
return mFieldCombo->currentItem();
}
#ifndef KAB_EMBEDDED
#include "incsearchwidget.moc"
#endif //KAB_EMBEDDED