[amarok/strohel-for-2.6] src: Get rid of UpdateCapability entirely - it was no longer used

Bart Cerneels bart.cerneels at kde.org
Tue Dec 20 13:54:41 UTC 2011


+1
While I understand there were good arguments made for the use of the
rather complicated Capability pattern, it clearly was applied to
eagerly. We need to think about code readability (and clarity of
architecture) and maintainability for the long run.

On Tue, Dec 20, 2011 at 13:09, Matěj Laitl <matej at laitl.cz> wrote:
> Git commit 2e73dd379d51a5df37e996cd392b98fd66191daf by Matěj Laitl.
> Committed on 10/12/2011 at 17:51.
> Pushed by laitl into branch 'strohel-for-2.6'.
>
> Get rid of UpdateCapability entirely - it was no longer used
>
> UpdateCapability was deprecated and thanks to previous commits, all
> UpdateCapability related code was dead. Remove it completely.
>
> CCMAIL: amarok-devel at kde.org
>
> M  +0    -1    src/context/applets/labels/LabelsApplet.cpp
> M  +0    -21   src/core-impl/collections/db/sql/CapabilityDelegateImpl.cpp
> M  +0    -24   src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp
> M  +0    -1    src/core/CMakeLists.txt
> M  +1    -1    src/core/capabilities/Capability.h
> D  +0    -23   src/core/capabilities/UpdateCapability.cpp
> D  +0    -46   src/core/capabilities/UpdateCapability.h
>
> http://commits.kde.org/amarok/2e73dd379d51a5df37e996cd392b98fd66191daf
>
> diff --git a/src/context/applets/labels/LabelsApplet.cpp b/src/context/applets/labels/LabelsApplet.cpp
> index 5b58def..8708f0c 100644
> --- a/src/context/applets/labels/LabelsApplet.cpp
> +++ b/src/context/applets/labels/LabelsApplet.cpp
> @@ -24,7 +24,6 @@
>  #include "App.h"
>  #include "amarokurls/AmarokUrl.h"
>  #include "context/widgets/AppletHeader.h"
> -#include "core/capabilities/UpdateCapability.h"
>  #include "core/support/Debug.h"
>  #include "EngineController.h"
>  #include "PaletteHandler.h"
> diff --git a/src/core-impl/collections/db/sql/CapabilityDelegateImpl.cpp b/src/core-impl/collections/db/sql/CapabilityDelegateImpl.cpp
> index 4f8df54..2698f20 100644
> --- a/src/core-impl/collections/db/sql/CapabilityDelegateImpl.cpp
> +++ b/src/core-impl/collections/db/sql/CapabilityDelegateImpl.cpp
> @@ -31,7 +31,6 @@
>  #include "core/capabilities/FindInSourceCapability.h"
>  #include "core/capabilities/StatisticsCapability.h"
>  #include "core/capabilities/OrganiseCapability.h"
> -#include "core/capabilities/UpdateCapability.h"
>  #include "core/collections/support/SqlStorage.h"
>  #include "core/meta/support/MetaConstants.h"
>  #include "core-impl/capabilities/timecode/TimecodeLoadCapability.h"
> @@ -164,21 +163,6 @@ class OrganiseCapabilityImpl : public Capabilities::OrganiseCapability
>         KSharedPtr<Meta::SqlTrack> m_track;
>  };
>
> -class UpdateCapabilityImpl : public Capabilities::UpdateCapability
> -{
> -    Q_OBJECT
> -    public:
> -        UpdateCapabilityImpl( Meta::SqlTrack *track )
> -            : Capabilities::UpdateCapability()
> -            , m_track( track ) {}
> -
> -        virtual void collectionUpdated() const { m_track->collection()->collectionUpdated(); }
> -
> -
> -    private:
> -        KSharedPtr<Meta::SqlTrack> m_track;
> -};
> -
>  class TimecodeWriteCapabilityImpl : public Capabilities::TimecodeWriteCapability
>  {
>     Q_OBJECT
> @@ -296,7 +280,6 @@ TrackCapabilityDelegateImpl::hasCapabilityInterface( Capabilities::Capability::T
>         case Capabilities::Capability::Actions:
>         case Capabilities::Capability::Importable:
>         case Capabilities::Capability::Organisable:
> -        case Capabilities::Capability::Updatable:
>         case Capabilities::Capability::BookmarkThis:
>         case Capabilities::Capability::WriteTimecode:
>         case Capabilities::Capability::LoadTimecode:
> @@ -343,10 +326,6 @@ TrackCapabilityDelegateImpl::createCapabilityInterface( Capabilities::Capability
>
>         case Capabilities::Capability::Organisable:
>             return new OrganiseCapabilityImpl( track );
> -
> -        case Capabilities::Capability::Updatable:
> -            return new UpdateCapabilityImpl( track );
> -
>         case Capabilities::Capability::BookmarkThis:
>             return new Capabilities::BookmarkThisCapability( new BookmarkCurrentTrackPositionAction( 0 ) );
>         case Capabilities::Capability::WriteTimecode:
> diff --git a/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp b/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp
> index 2811d2b..242872f 100644
> --- a/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp
> +++ b/src/core-impl/collections/mediadevicecollection/MediaDeviceMeta.cpp
> @@ -25,7 +25,6 @@
>  #include "SvgHandler.h"
>  #include "core/capabilities/ActionsCapability.h"
>  #include "core/capabilities/EditCapability.h"
> -#include "core/capabilities/UpdateCapability.h"
>
>  #include <KIcon>
>  #include <KUrl>
> @@ -63,25 +62,6 @@ class EditCapabilityMediaDevice : public Capabilities::EditCapability
>         KSharedPtr<MediaDeviceTrack> m_track;
>  };
>
> -class UpdateCapabilityMediaDevice : public Capabilities::UpdateCapability
> -{
> -    Q_OBJECT
> -    public:
> -        UpdateCapabilityMediaDevice( Collections::MediaDeviceCollection *coll )
> -            : Capabilities::UpdateCapability()
> -            , m_coll( coll )
> -        {}
> -
> -        virtual void collectionUpdated() const
> -        {
> -            m_coll->collectionUpdated();
> -            m_coll->writeDatabase();
> -        }
> -
> -    private:
> -        Collections::MediaDeviceCollection *m_coll;
> -};
> -
>
>  MediaDeviceTrack::MediaDeviceTrack( Collections::MediaDeviceCollection *collection )
>     : Meta::Track()
> @@ -402,8 +382,6 @@ MediaDeviceTrack::hasCapabilityInterface( Capabilities::Capability::Type type )
>     {
>         case Capabilities::Capability::Editable:
>             return true;
> -        case Capabilities::Capability::Updatable:
> -            return true;
>         default:
>             return false;
>     }
> @@ -419,8 +397,6 @@ MediaDeviceTrack::createCapabilityInterface( Capabilities::Capability::Type type
>     {
>         case Capabilities::Capability::Editable:
>             return new EditCapabilityMediaDevice( this );
> -        case Capabilities::Capability::Updatable:
> -            return new UpdateCapabilityMediaDevice( m_collection.data() );
>         default:
>             return 0;
>     }
> diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
> index 6a876e8..4db2105 100644
> --- a/src/core/CMakeLists.txt
> +++ b/src/core/CMakeLists.txt
> @@ -46,7 +46,6 @@ set(libcore_capabilities_SRCS
>     capabilities/SourceInfoCapability.cpp
>     capabilities/StatisticsCapability.cpp
>     capabilities/StreamInfoCapability.cpp
> -    capabilities/UpdateCapability.cpp
>     capabilities/WriteLabelCapability.cpp
>  )
>
> diff --git a/src/core/capabilities/Capability.h b/src/core/capabilities/Capability.h
> index b38d916..42ffd7e 100644
> --- a/src/core/capabilities/Capability.h
> +++ b/src/core/capabilities/Capability.h
> @@ -50,7 +50,7 @@ namespace Capabilities
>                         , SourceInfo = 8
>                         // not longer used
>                         , StreamInfo = 10
> -                        , Updatable = 11
> +                        // not longer used
>                         , Importable = 12
>                         // not longer used
>                         , BookmarkThis = 14
> diff --git a/src/core/capabilities/UpdateCapability.cpp b/src/core/capabilities/UpdateCapability.cpp
> deleted file mode 100644
> index 60d0f48..0000000
> --- a/src/core/capabilities/UpdateCapability.cpp
> +++ /dev/null
> @@ -1,23 +0,0 @@
> -/****************************************************************************************
> - * Copyright (c) 2007 Alejandro Wainzinger <aikawarazuni at gmail.com>                     *
> - *                                                                                      *
> - * This program 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 2 of the License, or (at your option) any later           *
> - * version.                                                                             *
> - *                                                                                      *
> - * This program 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         *
> - * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
> - ****************************************************************************************/
> -
> -#include "core/capabilities/UpdateCapability.h"
> -
> -Capabilities::UpdateCapability::~UpdateCapability()
> -{
> -}
> -
> -#include "UpdateCapability.moc"
> diff --git a/src/core/capabilities/UpdateCapability.h b/src/core/capabilities/UpdateCapability.h
> deleted file mode 100644
> index d27ecf6..0000000
> --- a/src/core/capabilities/UpdateCapability.h
> +++ /dev/null
> @@ -1,46 +0,0 @@
> -/****************************************************************************************
> - * Copyright (c) 2007 Alejandro Wainzinger <aikawarazuni at gmail.com>                     *
> - *                                                                                      *
> - * This program 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 2 of the License, or (at your option) any later           *
> - * version.                                                                             *
> - *                                                                                      *
> - * This program 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         *
> - * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
> - ****************************************************************************************/
> -
> -#ifndef AMAROK_UPDATECAPABILITY_H
> -#define AMAROK_UPDATECAPABILITY_H
> -
> -#include "shared/amarok_export.h"
> -#include "core/capabilities/Capability.h"
> -
> -namespace Capabilities
> -{
> -    /**
> -      * Do not use this capability. Ever. If you really need to emit Collection::updated()
> -      * from outside the collection (which is wrong) use Collection::collectionUpdated(),
> -      * e.g. track->collection()->collectionUpdated().
> -      *
> -      * The proper solution is to add code to the collection that allows it figure out on its
> -      * own whether it has been changed.
> -      */
> -    class AMAROK_CORE_EXPORT UpdateCapability : public Capabilities::Capability
> -    {
> -        Q_OBJECT
> -        public:
> -            virtual ~UpdateCapability();
> -
> -            static Type capabilityInterfaceType() { return Capabilities::Capability::Updatable; }
> -        // simply should emit track's collection's updated signal
> -            virtual void collectionUpdated() const = 0;
> -
> -    };
> -}
> -
> -#endif
>
> _______________________________________________
> Amarok-devel mailing list
> Amarok-devel at kde.org
> https://mail.kde.org/mailman/listinfo/amarok-devel


More information about the Amarok-devel mailing list