Make playlist's selection buttons work

This commit is contained in:
Thomas Frauendorfer 2007-10-17 03:00:15 +02:00
parent c988db9f31
commit eef3e53bd9
4 changed files with 23 additions and 3 deletions

View file

@ -38,7 +38,7 @@ XSettings::value_get (QString key)
} }
void void
XSettings::value_get (QString key, QString val) XSettings::value_set (QString key, QString val)
{ {
/* Only send change request to server here /* Only send change request to server here
* update of local cache will be done through handle_config_value_changed * update of local cache will be done through handle_config_value_changed

View file

@ -339,6 +339,7 @@ PlaylistWidget::addButtons (void)
{ {
PlaylistMenuButton *b; PlaylistMenuButton *b;
/* Add menu */
m_add = new PlaylistMenu (this, Skin::PLS_ADD, m_add = new PlaylistMenu (this, Skin::PLS_ADD,
Skin::PLS_ADD_DEC); Skin::PLS_ADD_DEC);
b = new PlaylistMenuButton (m_add, Skin::PLS_ADD_URL_0, b = new PlaylistMenuButton (m_add, Skin::PLS_ADD_URL_0,
@ -351,7 +352,7 @@ PlaylistWidget::addButtons (void)
Skin::PLS_ADD_FIL_1); Skin::PLS_ADD_FIL_1);
connect (b, SIGNAL(activated ()), this, SLOT (menuAddFile ())); connect (b, SIGNAL(activated ()), this, SLOT (menuAddFile ()));
/* Del menu */
m_del = new PlaylistMenu (this, Skin::PLS_DEL, m_del = new PlaylistMenu (this, Skin::PLS_DEL,
Skin::PLS_DEL_DEC); Skin::PLS_DEL_DEC);
b = new PlaylistMenuButton (m_del, Skin::PLS_MSC_BTN_0, b = new PlaylistMenuButton (m_del, Skin::PLS_MSC_BTN_0,
@ -366,15 +367,23 @@ PlaylistWidget::addButtons (void)
Skin::PLS_DEL_FIL_1); Skin::PLS_DEL_FIL_1);
// connect (b, SIGNAL(activated ()), m_list, SLOT (deleteFiles ())); // connect (b, SIGNAL(activated ()), m_list, SLOT (deleteFiles ()));
/* Selection menu */
m_sel = new PlaylistMenu (this, Skin::PLS_SEL, m_sel = new PlaylistMenu (this, Skin::PLS_SEL,
Skin::PLS_SEL_DEC); Skin::PLS_SEL_DEC);
b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_INV_0, b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_INV_0,
Skin::PLS_SEL_INV_1); Skin::PLS_SEL_INV_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (invertSelection ()));
b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_NIL_0, b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_NIL_0,
Skin::PLS_SEL_NIL_1); Skin::PLS_SEL_NIL_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (clearSelection ()));
b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_ALL_0, b = new PlaylistMenuButton (m_sel, Skin::PLS_SEL_ALL_0,
Skin::PLS_SEL_ALL_1); Skin::PLS_SEL_ALL_1);
connect (b, SIGNAL (activated ()),
m_view, SLOT (selectAll ()));
/* misc menu */
m_msc = new PlaylistMenu (this, Skin::PLS_MSC, m_msc = new PlaylistMenu (this, Skin::PLS_MSC,
Skin::PLS_MSC_DEC); Skin::PLS_MSC_DEC);
b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_SRT_0, b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_SRT_0,
@ -383,7 +392,7 @@ PlaylistWidget::addButtons (void)
Skin::PLS_MSC_INF_1); Skin::PLS_MSC_INF_1);
b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_OPT_0, b = new PlaylistMenuButton (m_msc, Skin::PLS_MSC_OPT_0,
Skin::PLS_MSC_OPT_1); Skin::PLS_MSC_OPT_1);
/* playlist menu */
m_lst = new PlaylistMenu (this, Skin::PLS_LST, m_lst = new PlaylistMenu (this, Skin::PLS_LST,
Skin::PLS_LST_DEC); Skin::PLS_LST_DEC);
b = new PlaylistMenuButton (m_lst, Skin::PLS_LST_NEW_0, b = new PlaylistMenuButton (m_lst, Skin::PLS_LST_NEW_0,

View file

@ -109,6 +109,16 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
this, SLOT(handleStatus(Xmms::Playback::Status))); this, SLOT(handleStatus(Xmms::Playback::Status)));
} }
void
PlaylistView::invertSelection () {
QItemSelection selection = QItemSelection (model ()->index (0, 0),
model ()->index (model ()->rowCount ()-1, 0));
selectionModel ()->select (selection, QItemSelectionModel::Toggle |
QItemSelectionModel::Columns);
selectionModel()->setCurrentIndex(model ()->index (0, 0),
QItemSelectionModel::NoUpdate);
}
void void
PlaylistView::setModel (QAbstractItemModel *model) { PlaylistView::setModel (QAbstractItemModel *model) {
QListView::setModel (model); QListView::setModel (model);

View file

@ -37,6 +37,7 @@ class PlaylistView : public QListView {
void contextMenuEvent (QContextMenuEvent *e); void contextMenuEvent (QContextMenuEvent *e);
void handleStatus (const Xmms::Playback::Status st); void handleStatus (const Xmms::Playback::Status st);
void invertSelection (void);
void settingsSaved (void); void settingsSaved (void);
void setPixmaps (Skin *skin); void setPixmaps (Skin *skin);