Diffstat (limited to 'kaddressbook/views/kaddressbooktableview.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/kaddressbooktableview.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/kaddressbook/views/kaddressbooktableview.cpp b/kaddressbook/views/kaddressbooktableview.cpp index fbfddba..2412170 100644 --- a/kaddressbook/views/kaddressbooktableview.cpp +++ b/kaddressbook/views/kaddressbooktableview.cpp | |||
@@ -38,33 +38,42 @@ | |||
38 | #include "kaddressbooktableview.h" | 38 | #include "kaddressbooktableview.h" |
39 | 39 | ||
40 | 40 | ||
41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, | 41 | KAddressBookTableView::KAddressBookTableView( KABC::AddressBook *ab, |
42 | QWidget *parent, const char *name ) | 42 | QWidget *parent, const char *name ) |
43 | : KAddressBookView( ab, parent, name ) | 43 | : KAddressBookView( ab, parent, name ) |
44 | { | 44 | { |
45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); | 45 | mainLayout = new QVBoxLayout( viewWidget(), 2 ); |
46 | 46 | ||
47 | // The list view will be created when the config is read. | 47 | // The list view will be created when the config is read. |
48 | mListView = 0; | 48 | mListView = 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | KAddressBookTableView::~KAddressBookTableView() | 51 | KAddressBookTableView::~KAddressBookTableView() |
52 | { | 52 | { |
53 | } | 53 | } |
54 | 54 | void KAddressBookTableView::scrollUP() | |
55 | { | ||
56 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Up, 0,0 ); | ||
57 | QApplication::postEvent( mListView, ev ); | ||
58 | } | ||
59 | void KAddressBookTableView::scrollDOWN() | ||
60 | { | ||
61 | QKeyEvent * ev = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Down, 0,0 ); | ||
62 | QApplication::postEvent( mListView, ev ); | ||
63 | } | ||
55 | void KAddressBookTableView::reconstructListView() | 64 | void KAddressBookTableView::reconstructListView() |
56 | { | 65 | { |
57 | if (mListView) | 66 | if (mListView) |
58 | { | 67 | { |
59 | disconnect(mListView, SIGNAL(selectionChanged()), | 68 | disconnect(mListView, SIGNAL(selectionChanged()), |
60 | this, SLOT(addresseeSelected())); | 69 | this, SLOT(addresseeSelected())); |
61 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), | 70 | disconnect(mListView, SIGNAL(executed(QListViewItem*)), |
62 | this, SLOT(addresseeExecuted(QListViewItem*))); | 71 | this, SLOT(addresseeExecuted(QListViewItem*))); |
63 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), | 72 | disconnect(mListView, SIGNAL(doubleClicked(QListViewItem*)), |
64 | this, SLOT(addresseeExecuted(QListViewItem*))); | 73 | this, SLOT(addresseeExecuted(QListViewItem*))); |
65 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, | 74 | disconnect(mListView, SIGNAL(startAddresseeDrag()), this, |
66 | SIGNAL(startDrag())); | 75 | SIGNAL(startDrag())); |
67 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), | 76 | disconnect(mListView, SIGNAL(returnPressed(QListViewItem*)), |
68 | this, SLOT(addresseeExecuted(QListViewItem*))); | 77 | this, SLOT(addresseeExecuted(QListViewItem*))); |
69 | 78 | ||
70 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, | 79 | disconnect(mListView, SIGNAL(addresseeDropped(QDropEvent*)), this, |
@@ -146,33 +155,38 @@ void KAddressBookTableView::doSearch( const QString& s, KABC::Field *field ) | |||
146 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { | 155 | for ( fieldIt = fieldList.begin(); fieldIt != fieldList.end(); ++fieldIt ) { |
147 | #if QT_VERSION >= 300 | 156 | #if QT_VERSION >= 300 |
148 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) | 157 | if (re.search((*fieldIt)->value( *it ).lower()) != -1) |
149 | #else | 158 | #else |
150 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) | 159 | if (re.match((*fieldIt)->value( *it ).lower()) != -1) |
151 | #endif | 160 | #endif |
152 | { | 161 | { |
153 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); | 162 | ContactListViewItem *item = new ContactListViewItem(*it, mListView, addressBook(), fields()); |
154 | break; | 163 | break; |
155 | } | 164 | } |
156 | } | 165 | } |
157 | } | 166 | } |
158 | } | 167 | } |
159 | // Sometimes the background pixmap gets messed up when we add lots | 168 | // Sometimes the background pixmap gets messed up when we add lots |
160 | // of items. | 169 | // of items. |
161 | mListView->repaint(); | 170 | mListView->repaint(); |
162 | emit selected(QString::null); | 171 | if ( mListView->firstChild() ) { |
172 | mListView->setCurrentItem ( mListView->firstChild() ); | ||
173 | mListView->setSelected ( mListView->firstChild(), true ); | ||
174 | } | ||
175 | else | ||
176 | emit selected(QString::null); | ||
163 | 177 | ||
164 | } | 178 | } |
165 | void KAddressBookTableView::writeConfig(KConfig *config) | 179 | void KAddressBookTableView::writeConfig(KConfig *config) |
166 | { | 180 | { |
167 | KAddressBookView::writeConfig(config); | 181 | KAddressBookView::writeConfig(config); |
168 | 182 | ||
169 | mListView->saveLayout(config, config->group()); | 183 | mListView->saveLayout(config, config->group()); |
170 | } | 184 | } |
171 | 185 | ||
172 | void KAddressBookTableView::readConfig(KConfig *config) | 186 | void KAddressBookTableView::readConfig(KConfig *config) |
173 | { | 187 | { |
174 | KAddressBookView::readConfig( config ); | 188 | KAddressBookView::readConfig( config ); |
175 | // The config could have changed the fields, so we need to reconstruct | 189 | // The config could have changed the fields, so we need to reconstruct |
176 | // the listview. | 190 | // the listview. |
177 | reconstructListView(); | 191 | reconstructListView(); |
178 | 192 | ||