summaryrefslogtreecommitdiffstats
path: root/playerwidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'playerwidget.cpp')
-rw-r--r--playerwidget.cpp34
1 files changed, 11 insertions, 23 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp
index e092b3b..fb8d563 100644
--- a/playerwidget.cpp
+++ b/playerwidget.cpp
@@ -164,6 +164,17 @@ void PlayerWidget::setupGui(QSplashScreen *splash){
QAction *addToPlayListAndClearA = new QAction(QIcon(":/belly_right_and_clear.png"), tr("Clear and add"), this);
connect(addToPlayListAndClearA, &QAction::triggered, this, &PlayerWidget::addToPlayListAndClear);
curW->view()->addAction(addToPlayListAndClearA);
+ QStandardItemModel *model = curW->model();
+ QModelIndex rootIdx = model->invisibleRootItem()->index();
+ if(model->hasChildren(model->index(0, 0, rootIdx))){
+ QAction *expandA = new QAction(Helper::iconFromQChar(QChar(0x2640), 90), tr("Expand"), this);
+ connect(expandA, &QAction::triggered, [curW] { curW->view()->expandOrCollapse(BeetView::Expand);} );
+ curW->view()->addAction(Helper::createSeparator(this));
+ curW->view()->addAction(expandA);
+ QAction *collapseA = new QAction(Helper::iconFromQChar(QChar(0x2642), 120), tr("Collapse"), this);
+ connect(collapseA, &QAction::triggered, [curW] { curW->view()->expandOrCollapse(BeetView::Collapse);} );
+ curW->view()->addAction(collapseA);
+ }
}
//left widget
@@ -326,8 +337,6 @@ void PlayerWidget::createActions(){
connect(addToPlayListA, &QAction::triggered, this, &PlayerWidget::addToPlayList);
QAction *addToPlayListAndClearA = new QAction(QIcon(":/belly_right_and_clear.png"), tr("Clear and add"), this);
connect(addToPlayListAndClearA, &QAction::triggered, this, &PlayerWidget::addToPlayListAndClear);
- QAction *expandA = new QAction(Helper::iconFromQChar(QChar(0x2640), 90), tr("Expand"), this);
- connect(expandA, &QAction::triggered, this, &PlayerWidget::expand);
QAction *removeFromPlayListA = new QAction(QIcon(":/belly_left.png"), tr("Remove from playlist"), this);
connect(removeFromPlayListA, &QAction::triggered, this, &PlayerWidget::removeFromPlayList);
QAction *clearPlayListA = new QAction(QIcon(":/delete.png"), tr("Clear Playlist"), this);
@@ -960,27 +969,6 @@ void PlayerWidget::continuePlaying(QMediaPlayer::MediaStatus state){
}
}
-void PlayerWidget::expand(){
- CollectionWidget *curWidget = qobject_cast<CollectionWidget*>(mCollectionStack->currentWidget());
- QModelIndexList sel = curWidget->view()->selectionModel()->selectedRows();
- for(const QModelIndex &i : sel){
- curWidget->view()->expand(i);
- expandRecursive(i);
- }
-}
-
-void PlayerWidget::expandRecursive(const QModelIndex &idx){
- const QStandardItemModel *model = static_cast<const QStandardItemModel*>(idx.model());
- CollectionWidget *curWidget = qobject_cast<CollectionWidget*>(mCollectionStack->currentWidget());
- QStandardItem *item = model->itemFromIndex(idx);
- for(int i = 0; i < item->rowCount(); ++i){
- QModelIndex cur = model->indexFromItem(item->child(i, 0));
- if(cur.isValid()){
- curWidget->view()->expand(cur);
- }
- }
-}
-
void PlayerWidget::readSettings(){
mStarting = true;
QSettings s;