diff options
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r-- | playerwidget.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index 1bd8ac6..deddfe6 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -15,6 +15,7 @@ #include <QAction> #include <QToolBar> #include <QHash> +#include <QPainter> #include <QApplication> #include <algorithm> @@ -25,6 +26,7 @@ #include "beetview.h" #include "indexerdialog.h" #include "globals.h" +#include "helper.h" PlayerWidget::PlayerWidget(QWidget *parent) : QWidget(parent){ setupGui(); @@ -203,6 +205,10 @@ void PlayerWidget::createActions(){ connect(addToPlayListA, SIGNAL(triggered()), this, SLOT(addToPlayList())); QAction *addToPlayListAndClearA = new QAction(QIcon(":/belly_right_and_clear.png"), tr("Clear and add"), this); connect(addToPlayListAndClearA, SIGNAL(triggered()), this, SLOT(addToPlayListAndClear())); + QAction *expandA = new QAction(Helper::iconFromQChar(QChar(0x2640), 90), tr("Expand"), this); + connect(expandA, SIGNAL(triggered()), this, SLOT(expand())); + QAction *collapseAllA = new QAction(Helper::iconFromQChar(QChar(0x2642), 120), tr("Collapse all"), this); + connect(collapseAllA, SIGNAL(triggered()), mView, SLOT(collapseAll())); QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this); connect(removeFromPlayListA, SIGNAL(triggered()), this, SLOT(removeFromPlayList())); QAction *clearPlayListA = new QAction(QIcon(":/delete.png"), tr("Clear Playlist"), this); @@ -219,9 +225,10 @@ void PlayerWidget::createActions(){ QAction *configA = Globals::instance()->action(Globals::ConfigAction); mView->addAction(addToPlayListA); mView->addAction(addToPlayListAndClearA); - QAction *mViewAS1 = new QAction(this); - mViewAS1->setSeparator(true); - mView->addAction(mViewAS1); + mView->addAction(Helper::createSeparator(this)); + mView->addAction(expandA); + mView->addAction(collapseAllA); + mView->addAction(Helper::createSeparator(this)); mView->addAction(randomPlayA); mPlayListView->addAction(removeFromPlayListA); mPlayListView->addAction(shufflePlayistA); @@ -720,3 +727,22 @@ void PlayerWidget::continuePlaying(QMediaPlayer::State state){ next(); } } + +void PlayerWidget::expand(){ + QModelIndexList sel = mView->selectionModel()->selectedRows(); + foreach(QModelIndex i, sel){ + mView->expand(i); + expandRecursive(i); + } +} + +void PlayerWidget::expandRecursive(const QModelIndex &idx){ + const QStandardItemModel *model = static_cast<const QStandardItemModel*>(idx.model()); + QStandardItem *item = model->itemFromIndex(idx); + for(int i = 0; i < item->rowCount(); ++i){ + QModelIndex cur = model->indexFromItem(item->child(i, 0)); + if(cur.isValid()){ + mView->expand(cur); + } + } +} |