Bug 253058 - Applet chooser stuck when clicked right arrow too many times
Summary: Applet chooser stuck when clicked right arrow too many times
Status: RESOLVED FIXED
Alias: None
Product: amarok
Classification: Applications
Component: Context View (show other bugs)
Version: 2.4-GIT
Platform: Compiled Sources Linux
: HI normal
Target Milestone: 2.4.0
Assignee: Amarok Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-10-02 21:31 UTC by Oskar Wróbel
Modified: 2010-10-27 14:44 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 2.4
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oskar Wróbel 2010-10-02 21:31:12 UTC
Version:           2.4-GIT (using KDE 4.5.1) 
OS:                Linux

I was browsing available applets and clicked right arrow three or four times. Applets scrolled "too far" to the left, beyond border. And clicking left arrow doesn't bring them back (looks like arrow is inactive although it isn't disabled). Looks like some bounds check is not working.

Reproducible: Always

Steps to Reproduce:
1. Click on configuration button of applets.
2. Click "+" icon to add new applet.
3. Scroll available applets 4 times with right arrow


Actual Results:  
Applets missing, couldn't be brought back. Even after closing window and opening it again. Arrow buttons didn't work.

Expected Results:  
Applets scroll normally.

OS: Linux (x86_64) release 2.6.35-pf10
Compiler: x86_64-pc-linux-gnu-gcc gcc-4.4.4

QT-4.7.0-rc1

Gentoo OS
Comment 1 Oskar Wróbel 2010-10-02 21:34:35 UTC
Forget to add: (Build Date: Oct 2 2010)
Small suggestion: maybe exact git commit number could be added to version number in "About box"? Build date could be too ambiguous.
Comment 2 Myriam Schweingruber 2010-10-07 09:53:49 UTC
Happens to me every time I click on the right arrow, impossible to go back. Using current 2.4-git
Comment 3 Rick W. Chen 2010-10-27 13:44:32 UTC
commit 303e95c59875ab0929e04b28769d40a00d0b9ebb
branch master
Author: Rick W. Chen <stuffcorpse@archlinux.us>
Date:   Thu Oct 28 00:34:21 2010 +1300

    Use a scrollwidget in the applet explorer
    
    This also fixes the "Applet chooser stuck when clicked right
    arrow too many times" bug.
    
    BUG:253058

diff --git a/ChangeLog b/ChangeLog
index fa0e859..edc6ea3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -25,6 +25,7 @@ VERSION 2.4-Beta 1
       to music provided by a running local Playdar service.
 
   CHANGES:
+    * Better scrolling in the applet explorer.
     * The default moodbar style now uses system colors.
     * Added tray icon context-menu action to open the preferences dialog.
     * Show a progress bar while loading pages in the Wikipedia applet.
@@ -49,6 +50,7 @@ VERSION 2.4-Beta 1
       pressing SHIFT while clicking the action will bypass trash.
 
   BUGFIXES:
+    * Fixed applet explorer getting stuck. (BR 253058)
     * Fixed Wikipedia applet header layout issues. (BR 215171)
     * Fixed truncated heading in albums applet. (BR 231001)
     * Playlist sorting breadcrumb items have been untranslatable.
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5412d75..5f2ac9d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -343,8 +343,6 @@ set( libcontextview_SRCS
     context/widgets/ContainmentSelectionLayer.cpp
     context/widgets/appletexplorer/AppletExplorer.cpp
     context/widgets/appletexplorer/AppletIcon.cpp
-    context/widgets/appletexplorer/AppletItemModel.cpp
-    context/widgets/appletexplorer/AppletsList.cpp
     context/widgets/TrackWidget.cpp
 )
 
diff --git a/src/context/ContextView.cpp b/src/context/ContextView.cpp
index 13c7525..2293183 100644
--- a/src/context/ContextView.cpp
+++ b/src/context/ContextView.cpp
@@ -20,6 +20,8 @@
   available at kdebase/workspace/plasma
 */
 
+#define DEBUG_PREFIX "ContextView"
+
 #include "ContextView.h"
 
 #include "core/support/Amarok.h"
@@ -94,6 +96,7 @@ ContextView::ContextView( Plasma::Containment *cont, Plasma::Corona *corona, QWi
     m_appletExplorer->setContainment( amarokContainment );
     m_appletExplorer->setPos( 0, cont->size().height() - m_appletExplorer->size().height() );
     m_appletExplorer->setZValue( m_appletExplorer->zValue() + 1000 );
+    m_appletExplorer->setFlag( QGraphicsItem::ItemIsSelectable );
     m_appletExplorer->hide();
 
     connect( m_appletExplorer, SIGNAL( addAppletToContainment( const QString&, const int ) ),
@@ -282,7 +285,7 @@ void
 ContextView::wheelEvent( QWheelEvent* event )
 {
     if( event->orientation() != Qt::Horizontal )
-        QGraphicsView::wheelEvent( event );
+        Plasma::View::wheelEvent( event );
 }
 
 QStringList
diff --git a/src/context/applets/similarartists/SimilarArtistsApplet.cpp b/src/context/applets/similarartists/SimilarArtistsApplet.cpp
index 54b1049..6452ce9 100644
--- a/src/context/applets/similarartists/SimilarArtistsApplet.cpp
+++ b/src/context/applets/similarartists/SimilarArtistsApplet.cpp
@@ -39,6 +39,7 @@
 //Qt
 #include <QDesktopServices>
 #include <QTextEdit>
+#include <QGraphicsLinearLayout>
 #include <QGraphicsProxyWidget>
 #include <QScrollArea>
 #include <QVBoxLayout>
diff --git a/src/context/widgets/appletexplorer/AppletExplorer.cpp b/src/context/widgets/appletexplorer/AppletExplorer.cpp
index 82cd8a0..99d41d5 100644
--- a/src/context/widgets/appletexplorer/AppletExplorer.cpp
+++ b/src/context/widgets/appletexplorer/AppletExplorer.cpp
@@ -21,6 +21,7 @@
  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
  ****************************************************************************************/
 
+#define DEBUG_PREFIX "AppletExplorer"
 
 #include "AppletExplorer.h"
 
@@ -28,19 +29,15 @@
 #include "core/support/Debug.h"
 #include "PaletteHandler.h"
 
-#include <plasma/containment.h>
-#include <plasma/widgets/pushbutton.h>
-#include <plasma/widgets/label.h>
-
 #include <KIcon>
+#include <Plasma/Applet>
+#include <Plasma/ScrollWidget>
 
-#include <QAction>
+#include <QGraphicsLinearLayout>
 #include <QStyleOptionGraphicsItem>
-#include <QSizePolicy>
-
-#define HEIGHT 130
-#define ICON_SIZE 16
+#include <QSignalMapper>
 
+#define HEIGHT 120
 
 namespace Context
 {
@@ -48,7 +45,7 @@ namespace Context
 AppletExplorer::AppletExplorer( QGraphicsItem *parent )
     : QGraphicsWidget( parent )
     , m_containment( 0 )
-    , m_mainLayout( 0 )
+    , m_scrollWidget( 0 )
 {
     init();
 }
@@ -57,11 +54,11 @@ AppletExplorer::~AppletExplorer()
 {}
 
 void
-AppletExplorer::addApplet( AppletItem *appletItem )
+AppletExplorer::addApplet( const QString &name )
 {
     DEBUG_BLOCK
-    if( appletItem && !appletItem->pluginName().isEmpty() && containment() )
-        emit  addAppletToContainment( appletItem->pluginName(), -1 ); //always add the applet at the end
+    if( !name.isEmpty() && containment() )
+        emit addAppletToContainment( name, -1 ); //always add the applet at the end
 }
 
 void
@@ -74,15 +71,24 @@ AppletExplorer::hideMenu()
 void
 AppletExplorer::init()
 {
-    m_mainLayout = new QGraphicsLinearLayout( Qt::Vertical );
-
-    m_appletsListWidget = new AppletsListWidget();
-
-    m_appletsListWidget->setPreferredSize( -1, -1 );
-
-    connect( m_appletsListWidget, SIGNAL( appletClicked( AppletItem * ) ), SLOT( addApplet( AppletItem * ) ) );
-
-    m_appletsListWidget->setModel( &m_model );
+    QGraphicsLinearLayout *layout = new QGraphicsLinearLayout( Qt::Vertical, this );
+    QSignalMapper *iconTriggerMapper = new QSignalMapper( this );
+    QGraphicsWidget *scrollView = new QGraphicsWidget( this );
+    m_scrollWidget = new Plasma::ScrollWidget( this );
+    m_scrollWidget->setWidget( scrollView );
+    m_scrollWidget->setHorizontalScrollBarPolicy( Qt::ScrollBarAsNeeded );
+    QGraphicsLinearLayout *scrollLayout = new QGraphicsLinearLayout( scrollView );
+
+    foreach( AppletIconWidget *widget, listAppletWidgets() )
+    {
+        scrollLayout->addItem( widget );
+        widget->setMinimumSize( widget->sizeFromIconSize( 48 ) );
+        widget->setMaximumSize( widget->sizeFromIconSize( 48 ) );
+        connect( widget, SIGNAL(clicked()), iconTriggerMapper, SLOT(map()) );
+        iconTriggerMapper->setMapping( widget, widget->pluginName() );
+    }
+
+    connect( iconTriggerMapper, SIGNAL(mapped(QString)), SLOT(addApplet(QString)) );
 
     m_hideIcon = new Plasma::IconWidget( this );
     
@@ -90,18 +96,15 @@ AppletExplorer::init()
     m_hideIcon->setToolTip( i18n( "Hide menu" ) );
 
     connect( m_hideIcon, SIGNAL( clicked() ), this, SLOT( hideMenu() ) );
-    m_hideIcon->setMinimumSize( m_hideIcon->sizeFromIconSize( ICON_SIZE ) );
-    m_hideIcon->setMaximumSize( m_hideIcon->sizeFromIconSize( ICON_SIZE ) );
+    m_hideIcon->setMinimumSize( m_hideIcon->sizeFromIconSize( 16 ) );
+    m_hideIcon->setMaximumSize( m_hideIcon->sizeFromIconSize( 16 ) );
     
-    m_mainLayout->addItem( m_hideIcon );
-    m_mainLayout->addItem( m_appletsListWidget );
-    m_mainLayout->setAlignment( m_hideIcon, Qt::AlignLeft );
-    m_mainLayout->setAlignment( m_appletsListWidget, Qt::AlignTop | Qt::AlignHCenter );
+    layout->addItem( m_hideIcon );
+    layout->addItem( m_scrollWidget );
+    layout->setAlignment( m_hideIcon, Qt::AlignRight );
     
     setMaximumHeight( HEIGHT );
     setMinimumHeight( HEIGHT );
-
-    setLayout( m_mainLayout );
 }
 
 void
@@ -149,14 +152,20 @@ AppletExplorer::containment() const
     return m_containment;
 }
 
-void
-AppletExplorer::resizeEvent( QGraphicsSceneResizeEvent *event )
+QList<AppletIconWidget*>
+AppletExplorer::listAppletWidgets()
 {
-    DEBUG_BLOCK
-
-    m_mainLayout->setGeometry( QRectF( QPointF( 0, 0 ), event->newSize() ) );
+    QList<AppletIconWidget*> widgets;
+    foreach( const KPluginInfo &info, Plasma::Applet::listAppletInfo( QString(), "amarok" ) )
+    {
+        if( info.property( "NoDisplay" ).toBool() || info.category() == i18n( "Containments" ) )
+            continue;
+
+        widgets << new AppletIconWidget( info, this );
+    }
+    return widgets;
 }
 
-}//namespace Context
+} //namespace Context
 
 #include "AppletExplorer.moc"
diff --git a/src/context/widgets/appletexplorer/AppletExplorer.h b/src/context/widgets/appletexplorer/AppletExplorer.h
index 25a9c66..d4eccd4 100644
--- a/src/context/widgets/appletexplorer/AppletExplorer.h
+++ b/src/context/widgets/appletexplorer/AppletExplorer.h
@@ -25,21 +25,22 @@
 #define APPLET_EXPLORER_H
 
 #include "amarok_export.h"
-#include "AppletItemModel.h"
-#include "AppletsList.h"
-#include "Containment.h"
 
-#include <QGraphicsLinearLayout>
-#include <QGraphicsSceneResizeEvent>
 #include <QGraphicsWidget>
 #include <QPainter>
 
 class QAction;
 class QStyleOptionGraphicsItem;
-class QSizePolicy;
+
+namespace Plasma {
+    class IconWidget;
+    class ScrollWidget;
+}
 
 namespace Context
 {
+class AppletIconWidget;
+class Containment;
 
 class AMAROK_EXPORT AppletExplorer: public QGraphicsWidget
 {
@@ -51,29 +52,24 @@ public:
 
     void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
     void setContainment( Containment *containment );
-    QSizePolicy sizePolicy () const;
+    QSizePolicy sizePolicy() const;
     Containment *containment() const;
 
 signals:
     void addAppletToContainment( const QString &pluginName, const int loc );
     void appletExplorerHid();
 
-protected:
-    virtual void resizeEvent( QGraphicsSceneResizeEvent *event );
-
 private slots:
-    void addApplet( AppletItem *appletItem );
+    void addApplet( const QString &name );
     void hideMenu();
 
 private:
     void init();
+    QList<AppletIconWidget*> listAppletWidgets();
 
     Containment *m_containment;
-    QGraphicsLinearLayout *m_mainLayout;
-
-    AppletItemModel m_model;
-    AppletsListWidget *m_appletsListWidget;
     Plasma::IconWidget *m_hideIcon;
+    Plasma::ScrollWidget *m_scrollWidget;
 };
 
 } // namespace Context
diff --git a/src/context/widgets/appletexplorer/AppletIcon.cpp b/src/context/widgets/appletexplorer/AppletIcon.cpp
index 1a0b1b3..a669a33 100644
--- a/src/context/widgets/appletexplorer/AppletIcon.cpp
+++ b/src/context/widgets/appletexplorer/AppletIcon.cpp
@@ -24,41 +24,31 @@
  ****************************************************************************************/
 
 #include "AppletIcon.h"
+
+#include <KIcon>
+#include <KPluginInfo>
 #include <KStandardDirs>
 
 #include <QColor>
 #include <QGraphicsSceneMouseEvent>
+#include <QPainter>
 
 namespace Context
 {
     
-AppletIconWidget::AppletIconWidget( AppletItem *appletItem, QGraphicsItem *parent )
+AppletIconWidget::AppletIconWidget( const KPluginInfo &info, QGraphicsItem *parent )
     : Plasma::IconWidget( parent )
-    , m_appletItem( appletItem )
+    , m_pluginName( info.pluginName() )
 {
-    if( appletItem )
-    {
-        setText( appletItem->name() );
-        setIcon( appletItem->icon() );
-        setToolTip( appletItem->name() );
-    }
-    else
-    {
-        setText( "no name" );
-        setIcon( "widgets/clock" );
-    }
-    setTextBackgroundColor( QColor() );
+    setText( info.name() );
+    setIcon( KIcon( info.icon().isEmpty() ? "application-x-plasma" : info.icon() ) );
+    setToolTip( info.name() );
+    setTextBackgroundColor( Qt::transparent );
 }
 
 AppletIconWidget::~AppletIconWidget()
 {}
 
-AppletItem *
-AppletIconWidget::appletItem() const
-{
-    return m_appletItem;
-}
-
 void
 AppletIconWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget )
 {
@@ -101,6 +91,12 @@ AppletIconWidget::paint( QPainter *painter, const QStyleOptionGraphicsItem *opti
     Plasma::IconWidget::paint( painter, option, widget );
 }
 
+QString
+AppletIconWidget::pluginName() const
+{
+    return m_pluginName;
 }
 
+} // namespace Context
+
 #include "AppletIcon.moc"
diff --git a/src/context/widgets/appletexplorer/AppletIcon.h b/src/context/widgets/appletexplorer/AppletIcon.h
index df720f1..3d84e49 100644
--- a/src/context/widgets/appletexplorer/AppletIcon.h
+++ b/src/context/widgets/appletexplorer/AppletIcon.h
@@ -27,12 +27,11 @@
 #define APPLET_ICON_H
 
 #include "amarok_export.h"
-#include "AppletItemModel.h"
 
-#include <plasma/widgets/iconwidget.h>
-
-#include <QPainter>
+#include <Plasma/IconWidget>
 
+class KPluginInfo;
+class QPainter;
 class QGraphicsSceneMouseEvent;
 
 namespace Context
@@ -43,18 +42,19 @@ class AMAROK_EXPORT AppletIconWidget: public Plasma::IconWidget
     Q_OBJECT
 
 public:
-    explicit AppletIconWidget( AppletItem *appletItem = 0, QGraphicsItem *parent = 0 );
+    explicit AppletIconWidget( const KPluginInfo &info, QGraphicsItem *parent = 0 );
     virtual ~AppletIconWidget();
 
-    AppletItem *appletItem() const;
+    QString pluginName() const;
 
 protected:
     void paint( QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0 );
 
 private:
-    AppletItem *m_appletItem;
+    QString m_pluginName;
+    Q_DISABLE_COPY( AppletIconWidget )
 };
 
-}
+} // namespace Context
 
-#endif
+#endif // APPLET_ICON_H
diff --git a/src/context/widgets/appletexplorer/AppletItemModel.cpp b/src/context/widgets/appletexplorer/AppletItemModel.cpp
deleted file mode 100644
index f72a173..0000000
--- a/src/context/widgets/appletexplorer/AppletItemModel.cpp
+++ /dev/null
@@ -1,110 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2009 William Viana Soares <vianasw@gmail.com>                          *
- *                       Significant parts of this code is inspired                     *
- *                       and/or copied from KDE Plasma sources, available               *
- *                       at kdebase/workspace/libs/plasmagenericshell                   *
- *                                                                                      *
- ****************************************************************************************/
-
-/****************************************************************************************
- *                                                                                      *
- * 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 "AppletItemModel.h"
-
-#include <plasma/applet.h>
-
-#include <KIcon>
-#include <KPluginInfo>
-
-#include <QIcon>
-
-namespace Context
-{
-
-//AppletItem
-
-AppletItem::AppletItem( AppletItemModel *model, const QMap< QString, QVariant > &info )
-{
-    m_model = model;
-    setText( info[ "name" ].toString() );
-    setData( info );
-    setIcon( qvariant_cast< QIcon >( info[ "icon" ] ) );
-}
-
-
-QString
-AppletItem::name() const
-{
-    return data().toMap()[ "name" ].toString();
-}
-
-
-QString
-AppletItem::pluginName() const
-{
-    return data().toMap()[ "pluginName" ].toString();
-}
-
-int
-AppletItem::running() const
-{
-    return data().toMap()[ "runningCount" ].toInt();
-}
-
-void
-AppletItem::setRunning( int count )
-{
-    QMap< QString, QVariant > info = data().toMap();
-    info.insert( "runningCount", count );
-    setData( QVariant( info ) );
-}
-
-
-
-//AppletItemModel
-
-AppletItemModel::AppletItemModel( QObject *parent )
-    : QStandardItemModel( parent )
-{
-    populateModel();
-}
-
-
-void
-AppletItemModel::populateModel()
-{
-    clear();
-
-    foreach( const KPluginInfo &info, Plasma::Applet::listAppletInfo( QString(), "amarok" ) )
-    {
-        if( info.property( "NoDisplay" ).toBool() || info.category() == i18n( "Containments" ) )
-        {
-            continue;
-        }
-
-        QMap< QString, QVariant > attrs;
-        attrs.insert( "name", info.name() );
-        attrs.insert( "pluginName", info.pluginName() );
-        attrs.insert( "icon",
-                      static_cast< QIcon >( KIcon( info.icon().isEmpty() ?
-                            "application-x-plasma": info.icon() ) ) );
-        appendRow( new AppletItem( this, attrs ) );
-    }
-}
-
-}
-
-#include "AppletItemModel.moc"
diff --git a/src/context/widgets/appletexplorer/AppletItemModel.h b/src/context/widgets/appletexplorer/AppletItemModel.h
deleted file mode 100644
index 74e9646..0000000
--- a/src/context/widgets/appletexplorer/AppletItemModel.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2009 William Viana Soares <vianasw@gmail.com>                          *
- *                       Significant parts of this code is inspired                     *
- *                       and/or copied from KDE Plasma sources, available               *
- *                       at kdebase/workspace/libs/plasmagenericshell                   *
- *                                                                                      *
- ****************************************************************************************/
-
-/****************************************************************************************
- *                                                                                      *
- * 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 APPLET_ITEM_MODEL_H
-#define APPLET_ITEM_MODEL_H
-
-#include "amarok_export.h"
-
-#include <QStandardItem>
-#include <QStandardItemModel>
-
-namespace Context
-{
-
-class AppletItemModel;
-
-class AMAROK_EXPORT AppletItem: public QObject, public QStandardItem
-{
-    Q_OBJECT
-
-public:
-    AppletItem( AppletItemModel *model, const QMap< QString, QVariant>& info );
-
-    QString name() const;
-    QString pluginName() const;
-    int running() const;
-
-    void setRunning( int count );
-
-private:
-    AppletItemModel *m_model;
-};
-
-class AMAROK_EXPORT AppletItemModel: public QStandardItemModel
-{
-    Q_OBJECT
-
-public:
-    AppletItemModel( QObject *parent = 0 );
-
-private:
-    void populateModel();
-};
-
-
-} //namespace Context
-
-#endif
diff --git a/src/context/widgets/appletexplorer/AppletsList.cpp b/src/context/widgets/appletexplorer/AppletsList.cpp
deleted file mode 100644
index 0d1a524..0000000
--- a/src/context/widgets/appletexplorer/AppletsList.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2009 William Viana Soares <vianasw@gmail.com>                          *
- * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org>                            *
- *                                                                                      *
- *                       Significant parts of this code is inspired                     *
- *                       and/or copied from KDE Plasma sources, available               *
- *                       at kdebase/workspace/libs/plasmagenericshell                   *
- *                                                                                      *
- ****************************************************************************************/
-
-/****************************************************************************************
- *                                                                                      *
- * 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 "AppletsList.h"
-#include "core/support/Debug.h"
-
-#include <KIcon>
-
-#include <cmath>
-
-#include <Plasma/Animator>
-#include <Plasma/Animation>
-
-#define ICON_SIZE 48 
-#define ARROW_SIZE 15
-
-namespace Context
-{
-
-AppletsListWidget::AppletsListWidget( QGraphicsItem *parent )
-    : QGraphicsWidget( parent )
-{
-    init();
-}
-
-AppletsListWidget::~AppletsListWidget()
-{}
-
-void
-AppletsListWidget::init()
-{
-    m_mainLayout = new QGraphicsLinearLayout( Qt::Horizontal );
-
-    m_leftArrow = new Plasma::IconWidget( this );
-    m_rightArrow = new Plasma::IconWidget( this );
-
-    m_leftArrow->setIcon( KIcon( "go-previous" ) );
-    m_rightArrow->setIcon( KIcon( "go-next" ) );
-
-    m_leftArrow->setDrawBackground( false );
-    m_rightArrow->setDrawBackground( false );
-
-    m_leftArrow->setMinimumSize( m_leftArrow->sizeFromIconSize( ARROW_SIZE ) );
-    m_leftArrow->setMaximumSize( m_leftArrow->sizeFromIconSize( ARROW_SIZE ) );
-    m_rightArrow->setMinimumSize( m_rightArrow->sizeFromIconSize( ARROW_SIZE ) );
-    m_rightArrow->setMaximumSize( m_rightArrow->sizeFromIconSize( ARROW_SIZE ) );
-
-    m_leftArrow->setEnabled( false );
-
-    connect( m_rightArrow, SIGNAL( clicked() ), this, SLOT( scrollRight() ) );
-    connect( m_leftArrow, SIGNAL( clicked() ), this, SLOT( scrollLeft() ) );
-
-    m_appletsListWidget = new QGraphicsWidget();
-    m_appletsListWindow = new QGraphicsWidget();
-
-    m_appletsListLayout = new QGraphicsLinearLayout( Qt::Horizontal );
-    m_appletsListWidget->setLayout( m_appletsListLayout );
-
-    m_appletsListWindow->setFlag( QGraphicsItem::ItemClipsChildrenToShape, true );
-    m_appletsListWidget->setParentItem( m_appletsListWindow );
-
-    m_mainLayout->addItem( m_leftArrow );
-    m_mainLayout->addItem( m_appletsListWindow );
-    m_mainLayout->addItem( m_rightArrow );
-
-    m_mainLayout->setAlignment( m_leftArrow, Qt::AlignVCenter | Qt::AlignHCenter );
-    m_mainLayout->setAlignment( m_rightArrow, Qt::AlignVCenter | Qt::AlignHCenter );
-    m_mainLayout->setAlignment( m_appletsListWindow, Qt::AlignVCenter | Qt::AlignHCenter );
-    setLayout( m_mainLayout );
-}
-
-void
-AppletsListWidget::appletIconClicked()
-{
-    DEBUG_BLOCK
-
-    AppletIconWidget* applet = dynamic_cast<AppletIconWidget*>( sender() );
-
-    if( applet )
-        emit( appletClicked( applet->appletItem() ) );
-}
-
-AppletIconWidget *
-AppletsListWidget::createAppletIcon( AppletItem *appletItem )
-{
-    AppletIconWidget *applet = new AppletIconWidget( appletItem, m_appletsListWidget );
-    applet->setMinimumSize( applet->sizeFromIconSize( ICON_SIZE ) );
-    applet->setMaximumSize( applet->sizeFromIconSize( ICON_SIZE ) );
-    connect( applet, SIGNAL( clicked() ), SLOT( appletIconClicked() ) );
-    return applet;
-}
-
-int
-AppletsListWidget::findLastVisibleAppletIdx() const
-{
-    DEBUG_BLOCK
-    qreal listTotalSize = m_appletsListLayout->preferredSize().width();
-    qreal iconAverageSize = listTotalSize / m_model->rowCount() + m_appletsListLayout->spacing();
-    qreal width = visibleListRect().right();
-    return floor( width / iconAverageSize );
-}
-
-int
-AppletsListWidget::findFirstVisibleAppletIdx() const
-{
-    DEBUG_BLOCK
-    qreal listTotalSize = m_appletsListLayout->preferredSize().width();
-    qreal iconAverageSize = listTotalSize / m_model->rowCount() + m_appletsListLayout->spacing();
-    qreal width = visibleListRect().left();
-
-    return ceil( width / iconAverageSize );
-}
-
-void
-AppletsListWidget::insertAppletIcon( AppletIconWidget *appletIcon )
-{
-    appletIcon->setVisible( true );
-    m_appletsListLayout->addItem( appletIcon );
-    m_appletsListLayout->setAlignment( appletIcon, Qt::AlignHCenter );
-    m_appletsListLayout->setAlignment( appletIcon, Qt::AlignVCenter );
-}
-
-int
-AppletsListWidget::maximumVisibleAppletsOnList() const
-{
-    DEBUG_BLOCK
-    qreal listTotalSize = m_appletsListLayout->preferredSize().width();
-    qreal iconAverageSize = listTotalSize / m_model->rowCount() + m_appletsListLayout->spacing();
-    qreal visibleRectSize = boundingRect().width();
-    debug() << "model row count: " << m_model->rowCount();
-    debug() << "icon average size: " << iconAverageSize;
-    debug() << "visible rect size: " << visibleRectSize;
-    debug() << "listTotalSize: " << listTotalSize;
-
-    return floor( visibleRectSize / iconAverageSize );
-}
-
-
-void
-AppletsListWidget::resizeEvent( QGraphicsSceneResizeEvent *event )
-{
-    DEBUG_BLOCK
-    Q_UNUSED( event );
-
-    updateGeometry();
-    if( maximumVisibleAppletsOnList() >= m_applets->count() )
-    {
-        m_rightArrow->setEnabled( false );
-    }
-    else
-    {
-        m_rightArrow->setEnabled( true );
-    }
-}
-
-void
-AppletsListWidget::setModel( QStandardItemModel *model )
-{
-    m_model = model;
-    AppletItem *appletItem;
-    m_applets = new QHash< QString, AppletIconWidget * >();
-    m_model->sort( 0 );
-
-    for( int i = 0; i < m_model->rowCount(); i++ )
-    {
-        appletItem = ( AppletItem * )m_model->item( i );
-        m_applets->insert( appletItem->pluginName(), createAppletIcon( appletItem ) );
-    }
-    updateList();
-}
-
-void
-AppletsListWidget::scrollLeft()
-{
-    DEBUG_BLOCK
-    int firstAppletIdx = findFirstVisibleAppletIdx();
-    int newFirstAppletIdx = qMax( 0, firstAppletIdx - ( maximumVisibleAppletsOnList() ) );
-    debug() << "first: " << firstAppletIdx;
-    debug() << "new first: " << newFirstAppletIdx;
-    AppletIconWidget *applet = dynamic_cast< AppletIconWidget * >( m_appletsListLayout->itemAt( newFirstAppletIdx ) );
-    if( applet )
-    {
-        int xPos = - applet->mapToItem( m_appletsListWidget, 0 , 0 ).x();
-        debug() << "x pos: " << xPos;
-
-        Plasma::Animation *animation = m_slideAnimation.data();
-        if( !animation )
-        {
-            animation = Plasma::Animator::create( Plasma::Animator::SlideAnimation );
-            animation->setTargetWidget( m_appletsListWidget );
-            animation->setProperty( "movementDirection", Plasma::Animation::MoveAny );
-            m_slideAnimation = animation;
-        }
-        else if( animation->state() == QAbstractAnimation::Running )
-            animation->stop();
-
-        animation->setProperty( "distance", xPos );
-        animation->start( QAbstractAnimation::DeleteWhenStopped );
-
-        if( !m_rightArrow->isEnabled() && maximumVisibleAppletsOnList() < m_applets->count() )
-            m_rightArrow->setEnabled( true );
-
-        if( newFirstAppletIdx <= 0 )
-            m_leftArrow->setEnabled( false );
-    }
-}
-
-
-void
-AppletsListWidget::scrollRight()
-{
-    DEBUG_BLOCK
-
-    int lastAppletIdx = findLastVisibleAppletIdx();
-    AppletIconWidget *applet = dynamic_cast< AppletIconWidget * >( m_appletsListLayout->itemAt( lastAppletIdx ) );
-    if( applet )
-    {
-        qreal lastAppletXPos = applet->mapToItem( m_appletsListWidget, 0, 0 ).x();
-
-        int scrollAmount = lastAppletXPos - visibleListRect().x();
-        int xPos = m_appletsListWidget->geometry().x() - scrollAmount;
-        debug() << "x pos: " << xPos;
-
-        Plasma::Animation *animation = m_slideAnimation.data();
-        if( !animation )
-        {
-            animation = Plasma::Animator::create( Plasma::Animator::SlideAnimation );
-            animation->setTargetWidget( m_appletsListWidget );
-            animation->setProperty( "movementDirection", Plasma::Animation::MoveAny );
-            m_slideAnimation = animation;
-        }
-        else if( animation->state() == QAbstractAnimation::Running )
-            animation->stop();
-
-        animation->setProperty( "distance", xPos );
-        animation->start( QAbstractAnimation::DeleteWhenStopped );
-
-        if( !m_leftArrow->isEnabled() )
-            m_leftArrow->setEnabled( true );
-        int newLastAppletIdx = qMin( lastAppletIdx + maximumVisibleAppletsOnList() - 1, m_applets->count() - 1 );
-        debug() << "new last idx: " << newLastAppletIdx;
-        if( newLastAppletIdx >= ( m_applets->count() - 1 ) )
-            m_rightArrow->setEnabled( false );
-    }
-}
-
-
-
-void
-AppletsListWidget::updateList()
-{
-    DEBUG_BLOCK
-    AppletItem *appletItem;
-    AppletIconWidget *appletIcon;
-
-    m_appletsListWidget->setLayout( NULL );
-    m_appletsListLayout = new QGraphicsLinearLayout( Qt::Horizontal );
-
-    for( int i = 0; i < m_model->rowCount(); i++ )
-    {
-        appletItem = ( AppletItem * )m_model->item( i );
-        if( appletItem != 0 )
-        {
-            appletIcon = m_applets->value( appletItem->pluginName() );
-            insertAppletIcon( appletIcon );
-        }
-    }
-    m_appletsListWidget->setLayout( m_appletsListLayout );
-    m_appletsListLayout->setSpacing( 10 );
-    debug() << "visible icons:" << maximumVisibleAppletsOnList();
-}
-
-QRectF
-AppletsListWidget::visibleListRect() const
-{
-    return m_appletsListWindow->mapRectToItem( m_appletsListWidget, 0, 0,
-                                               m_appletsListWindow->geometry().width(),
-                                               m_appletsListWindow->geometry().height() );
-}
-
-}
-
-#include "AppletsList.moc"
diff --git a/src/context/widgets/appletexplorer/AppletsList.h b/src/context/widgets/appletexplorer/AppletsList.h
deleted file mode 100644
index 3a96e5f..0000000
--- a/src/context/widgets/appletexplorer/AppletsList.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************************
- * Copyright (c) 2009 William Viana Soares <vianasw@gmail.com>                          *
- * Copyright (c) 2009 Mark Kretschmann <kretschmann@kde.org>                            *
- *                                                                                      *
- *                       Significant parts of this code is inspired                     *
- *                       and/or copied from KDE Plasma sources, available               *
- *                       at kdebase/workspace/libs/plasmagenericshell                   *
- *                                                                                      *
- ****************************************************************************************/
-
-/****************************************************************************************
- *                                                                                      *
- * 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 APPLETS_LIST_H
-#define APPLETS_LIST_H
-
-#include "amarok_export.h"
-#include "AppletIcon.h"
-#include "AppletItemModel.h"
-
-#include "plasma/widgets/iconwidget.h"
-
-#include <QGraphicsLinearLayout>
-#include <QGraphicsWidget>
-#include <QPainter>
-#include <QWeakPointer>
-
-namespace Plasma
-{
-    class Animation;
-}
-
-namespace Context
-{
-
-class AMAROK_EXPORT AppletsListWidget: public QGraphicsWidget
-{
-    Q_OBJECT
-
-public:
-    AppletsListWidget( QGraphicsItem *parent = 0 );
-    virtual ~AppletsListWidget();
-
-    void setModel( QStandardItemModel *model );
-
-protected:
-    virtual void resizeEvent( QGraphicsSceneResizeEvent *event );
-
-signals:
-    void appletClicked( AppletItem *appletItem );
-
-private slots:
-    void appletIconClicked();
-    void scrollLeft();
-    void scrollRight();
-
-private:
-    void init();
-
-    AppletIconWidget *createAppletIcon( AppletItem *appletItem );
-    void insertAppletIcon( AppletIconWidget *appletIcon );
-    void updateList();
-    int maximumVisibleAppletsOnList() const;
-    QRectF visibleListRect() const;
-    int findFirstVisibleAppletIdx() const;
-    int findLastVisibleAppletIdx() const;
-
-    QGraphicsLinearLayout *m_mainLayout;
-    QGraphicsLinearLayout *m_appletsListLayout;
-    QStandardItemModel *m_model;
-    QHash< QString, AppletIconWidget *> *m_applets;
-    QGraphicsWidget *m_appletsListWidget;
-    QGraphicsWidget *m_appletsListWindow;
-
-    Plasma::IconWidget *m_leftArrow;
-    Plasma::IconWidget *m_rightArrow;
-    QWeakPointer<Plasma::Animation> m_slideAnimation;
-};
-
-} //namespace Context
-
-#endif