OTHER: scroll playlist to current entry
This commit is contained in:
parent
633de5b5ee
commit
c682233749
6 changed files with 40 additions and 5 deletions
|
@ -121,6 +121,7 @@ PlaylistModel::handle_update_pos (const Xmms::Dict &posdict)
|
|||
if (changed_pl == m_name) {
|
||||
uint32_t pos = posdict.get<uint32_t> ("position");
|
||||
m_current_pos = pos;
|
||||
emit currentPosChanged (index (pos, 0));
|
||||
emit dataChanged(index (pos, 0), index (pos, m_columns.size ()));
|
||||
}
|
||||
return true;
|
||||
|
@ -130,6 +131,7 @@ bool
|
|||
PlaylistModel::handle_update_pos (const uint32_t &pos)
|
||||
{
|
||||
m_current_pos = pos;
|
||||
emit currentPosChanged (index (pos, 0));
|
||||
emit dataChanged(index (pos, 0), index (pos, m_columns.size ()));
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -65,7 +65,9 @@ class PlaylistModel : public QAbstractItemModel
|
|||
bool dropMimeData (const QMimeData * data, Qt::DropAction action, int row, int column, const QModelIndex & parent);
|
||||
Qt::DropActions supportedDropActions () const;
|
||||
QStringList mimeTypes () const;
|
||||
|
||||
|
||||
QModelIndex currentPos () {return index (m_current_pos, 0);}
|
||||
|
||||
/**
|
||||
* Set the columns that should be shown in the view.
|
||||
* @param columns A list of property keys. i.e. "artist", "album"
|
||||
|
@ -122,6 +124,7 @@ class PlaylistModel : public QAbstractItemModel
|
|||
|
||||
signals:
|
||||
void entryMoved (const QModelIndex &, const QModelIndex &);
|
||||
void currentPosChanged (QModelIndex);
|
||||
|
||||
public slots:
|
||||
void got_connection (XClient *);
|
||||
|
|
|
@ -166,10 +166,21 @@ PlaylistView::removeSelected () {
|
|||
}
|
||||
|
||||
void
|
||||
PlaylistView::setModel (QAbstractItemModel *model) {
|
||||
QListView::setModel (model);
|
||||
PlaylistView::setModel (PlaylistModel *plmodel) {
|
||||
if (model ()) disconnect (model (), 0, this, SLOT (currentPosChanged (QModelIndex)));
|
||||
QListView::setModel (plmodel);
|
||||
setModelColumn(0);
|
||||
updateGeometry();
|
||||
connect (plmodel, SIGNAL (currentPosChanged (QModelIndex)),
|
||||
this, SLOT (currentPosChanged (QModelIndex)));
|
||||
}
|
||||
|
||||
void
|
||||
PlaylistView::currentPosChanged (QModelIndex index) {
|
||||
QSettings s;
|
||||
if (s.value ("playlist/scrolltocurrent", true).toBool ()) {
|
||||
scrollTo (index);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -228,6 +239,8 @@ PlaylistView::settingsChanged ()
|
|||
}
|
||||
m_fontmetrics = new QFontMetrics (*m_font);
|
||||
update ();
|
||||
// Scroll to current pos, if enabled
|
||||
currentPosChanged (qobject_cast<PlaylistModel *>(model())->currentPos ());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
#include "entryinfo.h"
|
||||
class Skin;
|
||||
class PlaylistModel;
|
||||
|
||||
#include <QObject>
|
||||
#include <QAbstractItemDelegate>
|
||||
|
@ -50,7 +51,9 @@ class PlaylistView : public QListView {
|
|||
PlaylistView (QWidget *parent);
|
||||
~PlaylistView () {}
|
||||
|
||||
void setModel (QAbstractItemModel *model);
|
||||
void setModel (QAbstractItemModel *model)
|
||||
{qWarning ("Trying to set wrong model in PlaylistView"); return;};
|
||||
void setModel (PlaylistModel *model);
|
||||
|
||||
public slots:
|
||||
void contextMenuEvent (QContextMenuEvent *e);
|
||||
|
@ -62,7 +65,7 @@ class PlaylistView : public QListView {
|
|||
void showEntryInfo (void);
|
||||
void settingsChanged (void);
|
||||
void setPixmaps (Skin *skin);
|
||||
|
||||
void currentPosChanged (QModelIndex);
|
||||
protected:
|
||||
void mouseDoubleClickEvent (QMouseEvent *event);
|
||||
|
||||
|
|
|
@ -311,6 +311,18 @@ SettingsTabPlaylist::SettingsTabPlaylist (QWidget *parent) : QWidget (parent)
|
|||
l = new QLabel (tr ("Use remote filebrowsing"), c);
|
||||
h->addWidget (l, 1);
|
||||
|
||||
c = new QWidget (dummy);
|
||||
h = new QHBoxLayout (c);
|
||||
vbox->addWidget (c, 1);
|
||||
|
||||
m_scroll_view = new QCheckBox (c);
|
||||
if (!s.contains ("scrolltocurrent"))
|
||||
s.setValue ("scrolltocurrent", true);
|
||||
m_scroll_view->setCheckState (s.value ("scrolltocurrent").toBool () ? Qt::Checked : Qt::Unchecked);
|
||||
h->addWidget (m_scroll_view);
|
||||
l = new QLabel (tr ("Scroll playlist to current entry"), c);
|
||||
h->addWidget (l, 1);
|
||||
|
||||
s.endGroup ();
|
||||
}
|
||||
|
||||
|
@ -321,6 +333,7 @@ SettingsTabPlaylist::saveSettings (void)
|
|||
s.setValue ("playlist/fontsize", m_fontsize->value ());
|
||||
s.setValue ("playlist/shadedsize", m_shadesize->value ());
|
||||
s.setValue ("playlist/useremote", m_remote_fs->checkState () == Qt::Checked);
|
||||
s.setValue ("playlist/scrolltocurrent", m_scroll_view->checkState () == Qt::Checked);
|
||||
//TODO: Check if we really changed something
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ class SettingsTabPlaylist : public QWidget {
|
|||
QSpinBox *m_fontsize;
|
||||
QSpinBox *m_shadesize;
|
||||
QCheckBox *m_remote_fs;
|
||||
QCheckBox *m_scroll_view;
|
||||
};
|
||||
|
||||
class SettingsTabMain : public QWidget {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue