summaryrefslogtreecommitdiffabout
path: root/kaddressbook/incsearchwidget.cpp
Unidiff
Diffstat (limited to 'kaddressbook/incsearchwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kaddressbook/incsearchwidget.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/kaddressbook/incsearchwidget.cpp b/kaddressbook/incsearchwidget.cpp
index 3533427..78eaf65 100644
--- a/kaddressbook/incsearchwidget.cpp
+++ b/kaddressbook/incsearchwidget.cpp
@@ -36,112 +36,118 @@
36#include "incsearchwidget.h" 36#include "incsearchwidget.h"
37 37
38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name ) 38IncSearchWidget::IncSearchWidget( QWidget *parent, const char *name )
39 : QWidget( parent, name ) 39 : QWidget( parent, name )
40{ 40{
41#ifndef KAB_EMBEDDED 41#ifndef KAB_EMBEDDED
42//US setCaption( i18n( "Incremental Search" ) ); 42//US setCaption( i18n( "Incremental Search" ) );
43#endif //KAB_EMBEDDED 43#endif //KAB_EMBEDDED
44 44
45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() ); 45 QHBoxLayout *layout = new QHBoxLayout( this, 2, KDialog::spacingHint() );
46 46
47#ifdef DESKTOP_VERSION 47#ifdef DESKTOP_VERSION
48 QLabel *label = new QLabel( i18n( "Search:" ), this ); 48 QLabel *label = new QLabel( i18n( "Search:" ), this );
49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight ); 49 label->setAlignment( QLabel::AlignVCenter | QLabel::AlignRight );
50 layout->addWidget( label ); 50 layout->addWidget( label );
51#endif //KAB_EMBEDDED 51#endif //KAB_EMBEDDED
52 52
53 mSearchText = new KLineEdit( this ); 53 mSearchText = new KLineEdit( this );
54 layout->addWidget( mSearchText ); 54 layout->addWidget( mSearchText );
55// #ifdef KAB_EMBEDDED 55// #ifdef KAB_EMBEDDED
56// if (KGlobal::getOrientation() == KGlobal::Portrait) 56// if (KGlobal::getOrientation() == KGlobal::Portrait)
57// mSearchText->setMaximumWidth(30); 57// mSearchText->setMaximumWidth(30);
58// #endif //KAB_EMBEDDED 58// #endif //KAB_EMBEDDED
59 59
60 60
61 mFieldCombo = new QComboBox( false, this ); 61 mFieldCombo = new QComboBox( false, this );
62 layout->addWidget( mFieldCombo ); 62 layout->addWidget( mFieldCombo );
63 mFieldCombo->setMaximumHeight( 34 ); 63 mFieldCombo->setMaximumHeight( 34 );
64 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) ); 64 QToolTip::add( mFieldCombo, i18n( "Select Incremental Search Field" ) );
65 65
66// #ifndef KAB_EMBEDDED 66// #ifndef KAB_EMBEDDED
67// resize( QSize(420, 50).expandedTo( sizeHint() ) ); 67// resize( QSize(420, 50).expandedTo( sizeHint() ) );
68// #else //KAB_EMBEDDED 68// #else //KAB_EMBEDDED
69// resize( QSize(30, 10).expandedTo( sizeHint() ) ); 69// resize( QSize(30, 10).expandedTo( sizeHint() ) );
70// #endif //KAB_EMBEDDED 70// #endif //KAB_EMBEDDED
71 71
72 72
73 // for performance reasons, we do a search on the pda only after return is pressed 73 // for performance reasons, we do a search on the pda only after return is pressed
74 connect( mSearchText, SIGNAL( textChanged( const QString& ) ), 74 connect( mSearchText, SIGNAL( textChanged( const QString& ) ),
75 SLOT( announceDoSearch2() ) ); 75 SLOT( announceDoSearch2() ) );
76 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 76 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
77 SLOT( announceDoSearch2() ) ); 77 SLOT( announceDoSearch2() ) );
78 78
79 connect( mSearchText, SIGNAL( returnPressed() ), 79 connect( mSearchText, SIGNAL( returnPressed() ),
80 SLOT( announceDoSearch() ) ); 80 SLOT( announceDoSearch() ) );
81 connect( mFieldCombo, SIGNAL( activated( const QString& ) ), 81 connect( mFieldCombo, SIGNAL( activated( const QString& ) ),
82 SLOT( announceFieldChanged() ) ); 82 SLOT( announceFieldChanged() ) );
83 83
84
85
86 connect( mSearchText, SIGNAL( scrollUP() ), this, SIGNAL( scrollUP() ));
87 connect( mSearchText, SIGNAL( scrollDOWN() ), this, SIGNAL( scrollDOWN() ));
88
89
84 setFocusProxy( mSearchText ); 90 setFocusProxy( mSearchText );
85} 91}
86 92
87IncSearchWidget::~IncSearchWidget() 93IncSearchWidget::~IncSearchWidget()
88{ 94{
89 95
90} 96}
91void IncSearchWidget::announceDoSearch2() 97void IncSearchWidget::announceDoSearch2()
92{ 98{
93 if ( KABPrefs::instance()->mSearchWithReturn ) 99 if ( KABPrefs::instance()->mSearchWithReturn )
94 return; 100 return;
95 emit doSearch( mSearchText->text() ); 101 emit doSearch( mSearchText->text() );
96 //qDebug("emit dosreach "); 102 //qDebug("emit dosreach ");
97} 103}
98 104
99void IncSearchWidget::announceDoSearch() 105void IncSearchWidget::announceDoSearch()
100{ 106{
101 107
102 emit doSearch( mSearchText->text() ); 108 emit doSearch( mSearchText->text() );
103 // qDebug("emit dosreach "); 109 // qDebug("emit dosreach ");
104} 110}
105 111
106void IncSearchWidget::announceFieldChanged() 112void IncSearchWidget::announceFieldChanged()
107{ 113{
108 emit fieldChanged(); 114 emit fieldChanged();
109} 115}
110 116
111void IncSearchWidget::setFields( const KABC::Field::List &list ) 117void IncSearchWidget::setFields( const KABC::Field::List &list )
112{ 118{
113 119
114 mFieldCombo->clear(); 120 mFieldCombo->clear();
115 mFieldCombo->insertItem( i18n( "All Fields" ) ); 121 mFieldCombo->insertItem( i18n( "All Fields" ) );
116 QFontMetrics fm ( mFieldCombo->font() ); 122 QFontMetrics fm ( mFieldCombo->font() );
117 int wid = fm.width(i18n( "All Fields" ) ); 123 int wid = fm.width(i18n( "All Fields" ) );
118 int max = wid; 124 int max = wid;
119 125
120 KABC::Field::List::ConstIterator it; 126 KABC::Field::List::ConstIterator it;
121 for ( it = list.begin(); it != list.end(); ++it ) { 127 for ( it = list.begin(); it != list.end(); ++it ) {
122 mFieldCombo->insertItem( (*it)->label() ); 128 mFieldCombo->insertItem( (*it)->label() );
123 // wid = fm.width((*it)->label() ); 129 // wid = fm.width((*it)->label() );
124 //if ( wid > max ) 130 //if ( wid > max )
125 // max = wid; 131 // max = wid;
126 } 132 }
127 133
128 mFieldList = list; 134 mFieldList = list;
129 135
130 announceDoSearch(); 136 announceDoSearch();
131 announceFieldChanged(); 137 announceFieldChanged();
132 mFieldCombo->setMaximumWidth( wid+60 ); 138 mFieldCombo->setMaximumWidth( wid+60 );
133} 139}
134 140
135KABC::Field::List IncSearchWidget::fields() const 141KABC::Field::List IncSearchWidget::fields() const
136{ 142{
137 return mFieldList; 143 return mFieldList;
138} 144}
139 145
140KABC::Field *IncSearchWidget::currentField()const 146KABC::Field *IncSearchWidget::currentField()const
141{ 147{
142 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 ) 148 if ( mFieldCombo->currentItem() == -1 || mFieldCombo->currentItem() == 0 )
143 return 0; // for error or 'use all fields' 149 return 0; // for error or 'use all fields'
144 else 150 else
145 return mFieldList[ mFieldCombo->currentItem() - 1 ]; 151 return mFieldList[ mFieldCombo->currentItem() - 1 ];
146} 152}
147 153