diff --git a/src/tomahawk/CMakeLists.txt b/src/tomahawk/CMakeLists.txt index d77d36086..28c233d5f 100644 --- a/src/tomahawk/CMakeLists.txt +++ b/src/tomahawk/CMakeLists.txt @@ -41,7 +41,6 @@ SET( tomahawkSourcesGui ${tomahawkSourcesGui} sourcetree/SourcesProxyModel.cpp sourcetree/SourceTreeView.cpp sourcetree/SourceDelegate.cpp - sourcetree/AnimationHelper.cpp sourcetree/items/ScriptCollectionItem.cpp sourcetree/items/SourceTreeItem.cpp sourcetree/items/SourceItem.cpp diff --git a/src/tomahawk/sourcetree/AnimationHelper.cpp b/src/tomahawk/sourcetree/AnimationHelper.cpp deleted file mode 100644 index d11a3f648..000000000 --- a/src/tomahawk/sourcetree/AnimationHelper.cpp +++ /dev/null @@ -1,166 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Michael Zanetti - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#include "AnimationHelper.h" - -#include - -AnimationHelper::AnimationHelper( const QModelIndex& index, QObject *parent ) - :QObject( parent ) - , m_index( index ) - , m_fullyExpanded( false ) - , m_expandAnimation( 0 ) -{ - m_expandTimer.setSingleShot( true ); - m_expandTimer.setInterval( 1000 ); - connect( &m_expandTimer, SIGNAL( timeout() ), SLOT( expandTimeout() ) ); - - m_collapseTimer.setSingleShot( true ); - m_collapseTimer.setInterval( 0 ); - connect( &m_collapseTimer, SIGNAL( timeout() ), SLOT( collapseTimeout() ) ); -} - - -bool -AnimationHelper::initialized() const -{ - return m_expandAnimation != 0; -} - - -void -AnimationHelper::initialize( const QSize& startValue, const QSize& endValue, int duration ) -{ - m_size = startValue; - m_targetSize = endValue; - m_startSize = startValue; - - m_expandAnimation = new QPropertyAnimation( this, "size", this ); - m_expandAnimation->setStartValue( startValue ); - m_expandAnimation->setEndValue( endValue ); - m_expandAnimation->setDuration( duration ); - m_expandAnimation->setEasingCurve( QEasingCurve::OutExpo ); - qDebug() << "starting animation" << startValue << endValue << duration; - connect( m_expandAnimation, SIGNAL( finished() ), SLOT( expandAnimationFinished() ) ); - - m_collapseAnimation= new QPropertyAnimation( this, "size", this ); - m_collapseAnimation->setStartValue( endValue ); - m_collapseAnimation->setEndValue( startValue ); - m_collapseAnimation->setDuration( duration ); - m_collapseAnimation->setEasingCurve( QEasingCurve::InExpo ); - connect( m_collapseAnimation, SIGNAL( finished() ), SLOT( collapseAnimationFinished() ) ); - -} - - -void -AnimationHelper::setSize( const QSize& size ) -{ - m_size = size; - emit sizeChanged(); - //qDebug() << "animaton setting size to" << size; -} - - -void -AnimationHelper::expand() -{ - m_collapseTimer.stop(); - m_expandTimer.start(); -} - - -void -AnimationHelper::collapse( bool immediately ) -{ - if ( m_expandTimer.isActive() ) - { - m_expandTimer.stop(); - emit finished( m_index ); - return; - } - - if ( immediately ) - { - m_fullyExpanded = false; - m_collapseAnimation->start(); - } - else - m_collapseTimer.start(); -} - - -bool -AnimationHelper::partlyExpanded() -{ - return m_size != m_startSize; -// return m_fullyExpanded -// || ( m_expandAnimation->state() == QPropertyAnimation::Running && m_expandAnimation->currentTime() > 250 ) -// || ( m_collapseAnimation->state() == QPropertyAnimation::Running && m_collapseAnimation->currentTime() < 100 ); -} - - -bool -AnimationHelper::fullyExpanded() -{ - return m_fullyExpanded; -} - - -void -AnimationHelper::expandTimeout() -{ - m_expandAnimation->start(); -} - - -void -AnimationHelper::collapseTimeout() -{ - m_fullyExpanded = false; - m_collapseAnimation->start(); -} - - -void -AnimationHelper::expandAnimationFinished() -{ - m_fullyExpanded = true; -} - - -void -AnimationHelper::collapseAnimationFinished() -{ - emit finished( m_index ); -} - - -QSize -AnimationHelper::originalSize() const -{ - return m_startSize; -} - - -QSize -AnimationHelper::size() const -{ - return m_size; -} diff --git a/src/tomahawk/sourcetree/AnimationHelper.h b/src/tomahawk/sourcetree/AnimationHelper.h deleted file mode 100644 index ab8c0fddc..000000000 --- a/src/tomahawk/sourcetree/AnimationHelper.h +++ /dev/null @@ -1,76 +0,0 @@ -/* === This file is part of Tomahawk Player - === - * - * Copyright 2010-2011, Christian Muehlhaeuser - * Copyright 2011, Michael Zanetti - * - * Tomahawk is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Tomahawk is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Tomahawk. If not, see . - */ - -#ifndef ANIMATIONHELPER_H -#define ANIMATIONHELPER_H - -#include -#include -#include -#include -#include - -class AnimationHelper: public QObject -{ - Q_OBJECT - Q_PROPERTY( QSize size READ size WRITE setSize NOTIFY sizeChanged ) - -public: - AnimationHelper( const QModelIndex& index, QObject *parent = 0 ); - - QSize originalSize() const; - QSize size() const; - - bool initialized() const; - void initialize( const QSize& startValue, const QSize& endValue, int duration ); - - void setSize( const QSize& size ); - - void expand(); - void collapse( bool immediately = false ); - - bool partlyExpanded(); - bool fullyExpanded(); - -signals: - void sizeChanged(); - void finished( const QModelIndex& index); - -private slots: - void expandTimeout(); - void collapseTimeout(); - void expandAnimationFinished(); - void collapseAnimationFinished(); - -private: - QModelIndex m_index; - QSize m_size; - QSize m_targetSize; - QSize m_startSize; - - QTimer m_expandTimer; - QTimer m_collapseTimer; - - bool m_fullyExpanded; - - QPropertyAnimation *m_expandAnimation; - QPropertyAnimation *m_collapseAnimation; -}; - -#endif // ANIMATIONHELPER_H