diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /khotkeys/shared/khlistview.cpp | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'khotkeys/shared/khlistview.cpp')
-rw-r--r-- | khotkeys/shared/khlistview.cpp | 122 |
1 files changed, 122 insertions, 0 deletions
diff --git a/khotkeys/shared/khlistview.cpp b/khotkeys/shared/khlistview.cpp new file mode 100644 index 000000000..45a1d04f9 --- /dev/null +++ b/khotkeys/shared/khlistview.cpp @@ -0,0 +1,122 @@ +/**************************************************************************** + + KHotKeys + + Copyright (C) 1999-2002 Lubos Lunak <[email protected]> + + Distributed under the terms of the GNU General Public License version 2. + +****************************************************************************/ + +#define _KHLISTVIEW_CPP_ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include "khlistview.h" + +#include <kdebug.h> + +namespace KHotKeys +{ + +KHListView::KHListView( QWidget* parent_P, const char* name_P ) + : KListView( parent_P, name_P ), saved_current_item( NULL ), + in_clear( false ), ignore( false ), force_select( false ) + { + connect( this, SIGNAL( selectionChanged( QListViewItem* )), + SLOT( slot_selection_changed( QListViewItem* ))); + connect( this, SIGNAL( currentChanged( QListViewItem* )), + SLOT( slot_current_changed( QListViewItem* ))); + // CHECKME grrr + connect( this, SIGNAL( selectionChanged()), + SLOT( slot_selection_changed())); + connect( &insert_select_timer, SIGNAL( timeout()), + SLOT( slot_insert_select())); + } + +void KHListView::slot_selection_changed() + { + if( ignore ) + return; + if( saved_current_item == NULL ) + slot_selection_changed( NULL ); + else if( !saved_current_item->isSelected()) // no way + setSelected( saved_current_item, true ); + } + +void KHListView::slot_selection_changed( QListViewItem* item_P ) + { + if( ignore ) + return; + if( item_P == saved_current_item ) + return; + saved_current_item = item_P; + setCurrentItem( saved_current_item ); + emit current_changed( saved_current_item ); + } + +void KHListView::slot_current_changed( QListViewItem* item_P ) + { + if( ignore ) + return; + insert_select_timer.stop(); + if( item_P == saved_current_item ) + return; + saved_current_item = item_P; + setSelected( saved_current_item, true ); + emit current_changed( saved_current_item ); + } + +void KHListView::clear() + { + in_clear = true; + KListView::clear(); + in_clear = false; + slot_selection_changed( NULL ); + } + +void KHListView::insertItem( QListViewItem* item_P ) + { + bool set = false; + if( !in_clear ) + set = childCount() == 0; + KListView::insertItem( item_P ); + if( set && force_select ) + { + bool block = signalsBlocked(); + blockSignals( true ); +// SELI tohle spis jen blokovat sebe? + setCurrentItem( item_P ); + blockSignals( block ); + insert_select_timer.start( 0, true ); + } + } + +void KHListView::clearSelection() + { + KListView::clearSelection(); + slot_current_changed( currentItem()); + } + +// items are often inserted using the QListViewItem constructor, +// which means that a derived class are not yet fully created +void KHListView::slot_insert_select() + { + if( ignore ) + return; + slot_current_changed( currentItem()); + } + +void KHListView::contentsDropEvent( QDropEvent* e ) + { + bool save_ignore = ignore; + ignore = true; + KListView::contentsDropEvent( e ); + ignore = save_ignore; + } + +} // namespace KHotKeys + +#include "khlistview.moc" |