From c4c94de1ac00b5cca9b608c2f9bef21bc4a4d8c1 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sun, 16 Oct 2011 23:19:57 -0400 Subject: [PATCH] Expand breadcrumb fully when any item is selected --- src/libtomahawk/widgets/breadcrumbbar.cpp | 39 ++++++++++--------- .../widgets/siblingcrumbbutton.cpp | 13 ++++--- src/libtomahawk/widgets/whatshotwidget.cpp | 4 -- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/libtomahawk/widgets/breadcrumbbar.cpp b/src/libtomahawk/widgets/breadcrumbbar.cpp index 2fea1a518..dea514c0e 100644 --- a/src/libtomahawk/widgets/breadcrumbbar.cpp +++ b/src/libtomahawk/widgets/breadcrumbbar.cpp @@ -132,26 +132,27 @@ void BreadcrumbBar::deleteAnimationFinished() void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget) { - if( !m_useAnimation ) { - widget->hide(); - widget->deleteLater(); - return; // all done here - } + widget->hide(); + widget->deleteLater(); + return; // all done here - int index = m_layout->indexOf(widget); - if( index != 0 && m_navButtons.size() > 0 ) { - QWidget* neighbor = m_layout->itemAt(index-1)->widget(); - QPropertyAnimation *animation = new QPropertyAnimation(widget,"pos"); - m_layout->removeWidget(widget); - connect(animation, SIGNAL(finished()), SLOT(deleteAnimationFinished())); - animation->setDuration(300); - animation->setStartValue(widget->pos()); - animation->setEndValue(neighbor->pos()); - animation->start(); - } else { - widget->hide(); - widget->deleteLater(); - } + // Don't animate on delete. We expand a child recursively until it has no more children---this makes + // the deleting and creating animations overlap. + +// int index = m_layout->indexOf(widget); +// if( index != 0 && m_navButtons.size() > 0 ) { +// QWidget* neighbor = m_layout->itemAt(index-1)->widget(); +// QPropertyAnimation *animation = new QPropertyAnimation(widget,"pos"); +// m_layout->removeWidget(widget); +// connect(animation, SIGNAL(finished()), SLOT(deleteAnimationFinished())); +// animation->setDuration(300); +// animation->setStartValue(widget->pos()); +// animation->setEndValue(neighbor->pos()); +// animation->start(); +// } else { +// widget->hide(); +// widget->deleteLater(); +// } } diff --git a/src/libtomahawk/widgets/siblingcrumbbutton.cpp b/src/libtomahawk/widgets/siblingcrumbbutton.cpp index 0a9a36c87..537d62fc7 100644 --- a/src/libtomahawk/widgets/siblingcrumbbutton.cpp +++ b/src/libtomahawk/widgets/siblingcrumbbutton.cpp @@ -44,10 +44,11 @@ SiblingCrumbButton::SiblingCrumbButton( void SiblingCrumbButton::setIndex( QModelIndex index ) { - if ( m_index == index && text() == index.data().toString() ) - return; - m_index = index; - setText( index.data().toString() ); + if ( !(m_index == index && text() == index.data().toString()) ) + { + m_index = index; + setText( index.data().toString() ); + } fillCombo(); } @@ -59,6 +60,8 @@ QModelIndex SiblingCrumbButton::index() const void SiblingCrumbButton::setActive( bool active ) { Q_UNUSED( active ); + if ( active ) + QTimer::singleShot( 0, this, SLOT( activateSelf() ) ); } bool SiblingCrumbButton::isActive() const @@ -152,7 +155,7 @@ void SiblingCrumbButton::comboboxActivated(int i) QModelIndex activated = m_index.sibling(i,0); int count = breadcrumbBar()->model()->rowCount(activated); if( count > 0 ) { - qDebug() << "activated" << activated.child(0,0).data().toString(); +// qDebug() << "activated crumb with children:" << activated.child(0,0).data().toString(); breadcrumbBar()->currentChangedTriggered(activated.child(0,0)); } else { // if it has no children, then emit itself diff --git a/src/libtomahawk/widgets/whatshotwidget.cpp b/src/libtomahawk/widgets/whatshotwidget.cpp index 7b04f2f5f..f3477bc6c 100644 --- a/src/libtomahawk/widgets/whatshotwidget.cpp +++ b/src/libtomahawk/widgets/whatshotwidget.cpp @@ -160,10 +160,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat ui->breadCrumbLeft->setSelectionModel(selectionModelLeft); //ui->breadCrumbRight->setSelectionModel(selectionModelLeft); - //HACK ALERT - we want the second crumb to expand right away, so we - //force it here. We should find a more elegant want to do this - /// @note: this expands the billboard chart, as its fast loading and intersting album view ;) i think - ui->breadCrumbLeft->currentChangedTriggered(m_crumbModelLeft->index(1,0).child(0,0).child(0,0)); break; } case InfoSystem::InfoChart: