1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

Expand breadcrumb fully when any item is selected

This commit is contained in:
Leo Franchi
2011-10-16 23:19:57 -04:00
parent 75cb466909
commit c4c94de1ac
3 changed files with 28 additions and 28 deletions

View File

@@ -132,26 +132,27 @@ void BreadcrumbBar::deleteAnimationFinished()
void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget) void BreadcrumbBar::deleteButton(BreadcrumbButtonBase *widget)
{ {
if( !m_useAnimation ) { widget->hide();
widget->hide(); widget->deleteLater();
widget->deleteLater(); return; // all done here
return; // all done here
}
int index = m_layout->indexOf(widget); // Don't animate on delete. We expand a child recursively until it has no more children---this makes
if( index != 0 && m_navButtons.size() > 0 ) { // the deleting and creating animations overlap.
QWidget* neighbor = m_layout->itemAt(index-1)->widget();
QPropertyAnimation *animation = new QPropertyAnimation(widget,"pos"); // int index = m_layout->indexOf(widget);
m_layout->removeWidget(widget); // if( index != 0 && m_navButtons.size() > 0 ) {
connect(animation, SIGNAL(finished()), SLOT(deleteAnimationFinished())); // QWidget* neighbor = m_layout->itemAt(index-1)->widget();
animation->setDuration(300); // QPropertyAnimation *animation = new QPropertyAnimation(widget,"pos");
animation->setStartValue(widget->pos()); // m_layout->removeWidget(widget);
animation->setEndValue(neighbor->pos()); // connect(animation, SIGNAL(finished()), SLOT(deleteAnimationFinished()));
animation->start(); // animation->setDuration(300);
} else { // animation->setStartValue(widget->pos());
widget->hide(); // animation->setEndValue(neighbor->pos());
widget->deleteLater(); // animation->start();
} // } else {
// widget->hide();
// widget->deleteLater();
// }
} }

View File

@@ -44,10 +44,11 @@ SiblingCrumbButton::SiblingCrumbButton(
void SiblingCrumbButton::setIndex( QModelIndex index ) void SiblingCrumbButton::setIndex( QModelIndex index )
{ {
if ( m_index == index && text() == index.data().toString() ) if ( !(m_index == index && text() == index.data().toString()) )
return; {
m_index = index; m_index = index;
setText( index.data().toString() ); setText( index.data().toString() );
}
fillCombo(); fillCombo();
} }
@@ -59,6 +60,8 @@ QModelIndex SiblingCrumbButton::index() const
void SiblingCrumbButton::setActive( bool active ) void SiblingCrumbButton::setActive( bool active )
{ {
Q_UNUSED( active ); Q_UNUSED( active );
if ( active )
QTimer::singleShot( 0, this, SLOT( activateSelf() ) );
} }
bool SiblingCrumbButton::isActive() const bool SiblingCrumbButton::isActive() const
@@ -152,7 +155,7 @@ void SiblingCrumbButton::comboboxActivated(int i)
QModelIndex activated = m_index.sibling(i,0); QModelIndex activated = m_index.sibling(i,0);
int count = breadcrumbBar()->model()->rowCount(activated); int count = breadcrumbBar()->model()->rowCount(activated);
if( count > 0 ) { 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)); breadcrumbBar()->currentChangedTriggered(activated.child(0,0));
} else { } else {
// if it has no children, then emit itself // if it has no children, then emit itself

View File

@@ -160,10 +160,6 @@ WhatsHotWidget::infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestDat
ui->breadCrumbLeft->setSelectionModel(selectionModelLeft); ui->breadCrumbLeft->setSelectionModel(selectionModelLeft);
//ui->breadCrumbRight->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; break;
} }
case InfoSystem::InfoChart: case InfoSystem::InfoChart: