Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit dec1a852 authored by Scott Wheeler's avatar Scott Wheeler

Make it so that the up arrow moves back into the search line as well.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=425073
parent 994b1006
......@@ -1086,7 +1086,6 @@ bool Playlist::eventFilter(QObject *watched, QEvent *e)
QTimer::singleShot(0, this, SLOT(slotUpdateColumnWidths()));
break;
}
default:
break;
}
......@@ -1095,6 +1094,24 @@ bool Playlist::eventFilter(QObject *watched, QEvent *e)
return KListView::eventFilter(watched, e);
}
void Playlist::keyPressEvent(QKeyEvent *event)
{
if(event->key() == Key_Up) {
QListViewItemIterator selected(this, QListViewItemIterator::IteratorFlag(
QListViewItemIterator::Selected |
QListViewItemIterator::Visible));
if(selected.current()) {
QListViewItemIterator visible(this, QListViewItemIterator::IteratorFlag(
QListViewItemIterator::Visible));
if(selected.current() == visible.current())
KApplication::postEvent(parent(), new FocusUpEvent);
}
}
KListView::keyPressEvent(event);
}
void Playlist::contentsDropEvent(QDropEvent *e)
{
QPoint vp = contentsToViewport(e->pos());
......
......@@ -415,6 +415,7 @@ protected:
// the following are all reimplemented from base classes
virtual bool eventFilter(QObject *watched, QEvent *e);
virtual void keyPressEvent(QKeyEvent *e);
virtual QDragObject *dragObject(QWidget *parent);
virtual QDragObject *dragObject() { return dragObject(this); }
virtual bool canDecode(QMimeSource *s);
......@@ -688,6 +689,13 @@ private:
bool processEvents();
class FocusUpEvent : public QCustomEvent
{
public:
FocusUpEvent() : QCustomEvent(id) {}
static const int id = 999;
};
QDataStream &operator<<(QDataStream &s, const Playlist &p);
QDataStream &operator>>(QDataStream &s, Playlist &p);
......
......@@ -61,6 +61,15 @@ PlaylistSplitter::~PlaylistSplitter()
delete m_playlistBox;
}
bool PlaylistSplitter::eventFilter(QObject *, QEvent *event)
{
if(event->type() == FocusUpEvent::id) {
m_searchWidget->setFocus();
return true;
}
return false;
}
////////////////////////////////////////////////////////////////////////////////
// public slots
////////////////////////////////////////////////////////////////////////////////
......@@ -75,25 +84,25 @@ void PlaylistSplitter::slotFocusCurrentPlaylist()
Playlist *playlist = m_playlistBox->visiblePlaylist();
if(playlist) {
playlist->setFocus();
playlist->KListView::selectAll(false);
playlist->setFocus();
playlist->KListView::selectAll(false);
// Select the top visible (and matching) item.
// Select the top visible (and matching) item.
PlaylistItem *item = static_cast<PlaylistItem *>(playlist->itemAt(QPoint(0, 0)));
PlaylistItem *item = static_cast<PlaylistItem *>(playlist->itemAt(QPoint(0, 0)));
if(!item)
return;
if(!item)
return;
// A little bit of a hack to make QListView repaint things properly. Switch
// to single selection mode, set the selection and then switch back.
// A little bit of a hack to make QListView repaint things properly. Switch
// to single selection mode, set the selection and then switch back.
playlist->setSelectionMode(QListView::Single);
playlist->setSelectionMode(QListView::Single);
playlist->markItemSelected(item, true);
playlist->setCurrentItem(item);
playlist->markItemSelected(item, true);
playlist->setCurrentItem(item);
playlist->setSelectionMode(QListView::Extended);
playlist->setSelectionMode(QListView::Extended);
}
}
......@@ -129,6 +138,7 @@ void PlaylistSplitter::setupLayout()
QVBoxLayout *topLayout = new QVBoxLayout(top);
m_playlistStack = new QWidgetStack(top, "playlistStack");
m_playlistStack->installEventFilter(this);
connect(m_playlistStack, SIGNAL(aboutToShow(QWidget *)), this, SLOT(slotPlaylistChanged(QWidget *)));
......@@ -217,7 +227,7 @@ void PlaylistSplitter::slotPlaylistChanged(QWidget *w)
Playlist *p = dynamic_cast<Playlist *>(w);
if(!p)
return;
return;
m_newVisible = p;
m_searchWidget->setSearch(p->search());
......
......@@ -48,6 +48,8 @@ public:
PlaylistInterface *playlist() const { return m_playlistBox; }
virtual bool eventFilter(QObject *watched, QEvent *event);
public slots:
virtual void setFocus();
virtual void slotFocusCurrentPlaylist();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment