summaryrefslogtreecommitdiffstats
path: root/katapult/plugins/catalogs/amarokcatalog
diff options
context:
space:
mode:
Diffstat (limited to 'katapult/plugins/catalogs/amarokcatalog')
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/Makefile.am15
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/actionplaysong.cpp58
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/actionplaysong.h42
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp342
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/amarokcatalog.h62
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/coverimage.cpp106
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/coverimage.h54
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/katapult_amarokcatalog.desktop44
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/settings.ui80
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/song.cpp91
-rw-r--r--katapult/plugins/catalogs/amarokcatalog/song.h56
11 files changed, 950 insertions, 0 deletions
diff --git a/katapult/plugins/catalogs/amarokcatalog/Makefile.am b/katapult/plugins/catalogs/amarokcatalog/Makefile.am
new file mode 100644
index 0000000..24de402
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/Makefile.am
@@ -0,0 +1,15 @@
+# set the include path for X, qt and KDE
+INCLUDES = -I$(top_srcdir)/katapult/common $(all_includes)
+
+# header files
+noinst_HEADERS = coverimage.h song.h amarokcatalog.h actionplaysong.h
+
+# use automoc
+METASOURCES = AUTO
+
+# our plugin
+kde_module_LTLIBRARIES = katapult_amarokcatalog.la
+katapult_amarokcatalog_la_SOURCES = settings.ui amarokcatalog.cpp coverimage.cpp song.cpp actionplaysong.cpp
+katapult_amarokcatalog_la_LDFLAGS = -module $(KDE_RPATH) $(KDE_PLUGIN) $(all_libraries)
+katapult_amarokcatalog_la_LIBADD = $(LIB_QT) $(LIB_KDECORE) -lDCOP $(LIB_KDEUI) $(LIB_KIO) $(top_builddir)/katapult/common/libkatapult.la
+kde_services_DATA = katapult_amarokcatalog.desktop
diff --git a/katapult/plugins/catalogs/amarokcatalog/actionplaysong.cpp b/katapult/plugins/catalogs/amarokcatalog/actionplaysong.cpp
new file mode 100644
index 0000000..43fdc2b
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/actionplaysong.cpp
@@ -0,0 +1,58 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <qpixmap.h>
+#include <qstring.h>
+#include <qcstring.h>
+#include <qdatastream.h>
+#include <kapp.h>
+#include <dcopclient.h>
+#include <klocale.h>
+
+#include <katapultitem.h>
+
+#include "actionplaysong.h"
+#include "song.h"
+
+QPixmap ActionPlaySong::icon(int size) const
+{
+ return KGlobal::iconLoader()->loadIcon("amarok", KIcon::NoGroup, size);
+}
+
+QString ActionPlaySong::text() const
+{
+ return i18n("Play Song");
+}
+
+bool ActionPlaySong::accepts(const KatapultItem *item) const
+{
+ return strcmp(item->className(), "Song") == 0;
+}
+
+void ActionPlaySong::execute(const KatapultItem *item) const
+{
+ const Song *song = (const Song *) item;
+ QByteArray buffer;
+ QDataStream stream(buffer, IO_WriteOnly);
+ stream << song->url();
+ kapp->dcopClient()->send("amarok", "playlist", "playMedia(KURL)", buffer);
+}
diff --git a/katapult/plugins/catalogs/amarokcatalog/actionplaysong.h b/katapult/plugins/catalogs/amarokcatalog/actionplaysong.h
new file mode 100644
index 0000000..bd2f0af
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/actionplaysong.h
@@ -0,0 +1,42 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef ACTIONPLAYSONG_H
+#define ACTIONPLAYSONG_H
+
+#include "katapultaction.h"
+
+class KatapultItem;
+class QPixmap;
+class QString;
+
+/**
+@author Bastian Holst
+*/
+class ActionPlaySong : public KatapultAction
+{
+public:
+ virtual QPixmap icon(int) const;
+ virtual QString text() const;
+ virtual bool accepts(const KatapultItem *) const;
+ virtual void execute(const KatapultItem *) const;
+};
+
+#endif //ACTIONPLAYSONG_H
diff --git a/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp b/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp
new file mode 100644
index 0000000..f924c6d
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.cpp
@@ -0,0 +1,342 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * Copyright (C) 2006 by Martin Meredith *
+ * mez@thekatapult.org.uk *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kapplication.h>
+#include <ksycocaentry.h>
+#include <ksycocatype.h>
+#include <knuminput.h>
+#include <kurl.h>
+#include <kapp.h>
+#include <qstring.h>
+#include <qcstring.h>
+#include <qstringlist.h>
+#include <qdatastream.h>
+#include <dcopclient.h>
+#include <qregexp.h>
+
+#include "actionplaysong.h"
+#include "song.h"
+#include "amarokcatalog.h"
+#include "actionregistry.h"
+#include "status.h"
+#include "settings.h"
+
+K_EXPORT_COMPONENT_FACTORY( katapult_amarokcatalog,
+ KGenericFactory<AmarokCatalog>( "katapult_amarokcatalog" ) )
+
+AmarokCatalog::AmarokCatalog(QObject*, const char*, const QStringList&): _result(QString::null)
+{
+ _minQueryLen = 3;
+ ActionRegistry::self()->registerAction(new ActionPlaySong());
+ _gotCollectionStatus = false;
+ _dynamicCollection = false;
+ checkCollectionType();
+
+}
+AmarokCatalog::~AmarokCatalog()
+{
+}
+
+void AmarokCatalog::queryChanged()
+{
+ int newStatus = 0;
+ QString queryString = query();
+
+ if((QString(queryString).remove(':').remove('\"').remove(' ').isEmpty()) || (queryString.length() < _minQueryLen)) {
+ reset();
+ setBestMatch(Match());
+ setStatus(0);
+ } else {
+
+ if ( _gotCollectionStatus)
+ {
+
+ if (!_dynamicCollection)
+ {
+
+ // Stuff for Amarok < 1.4.2
+
+ QStringList queryList;
+ //prepares SQL-queryQRegExp
+ QString sqlQuery(
+ "SELECT artist.name, tags.title, tags.url, images.path, album.name "
+ "FROM tags"
+ "INNER JOIN album ON (tags.album = album.id) "
+ "INNER JOIN artist ON (tags.artist = artist.id) "
+ "LEFT JOIN statistics ON (tags.url = statistics.url) "
+ "LEFT JOIN images ON (artist.name = images.artist AND album.name = images.album) "
+ "WHERE 1=1 "
+ );// AND
+
+ queryList = QStringList::split ( QString(" "), QString(queryString).replace(QChar(':')," ").replace(QChar('\''), " ").replace(QChar('\''), "%") );
+ for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
+ sqlQuery.append(QString(" AND (t.title LIKE '\%%1\%'").arg(*it));
+ sqlQuery.append(QString(" OR a.name LIKE '\%%1\%')").arg(*it));
+ }
+ sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC");
+
+ //sending SQL-query to ararok via dcop
+ QByteArray sqlQueryData, replyData;
+ QCString replyType;
+ QDataStream arg(sqlQueryData, IO_WriteOnly);
+ arg << sqlQuery;
+ if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)",
+ sqlQueryData, replyType, replyData)) {
+ newStatus = 0;
+ } else {
+ QDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "QStringList") {
+ QStringList sqlResult;
+ reply >> sqlResult;
+
+ if(sqlResult.isEmpty()) {
+ newStatus = 0;
+ } else {
+ reset();
+ //Reads information from SQL-Query
+ _result.setArtist(sqlResult[0]);
+ _result.setName(sqlResult[1]);
+ _result.setURL(KURL(sqlResult[2]));
+ _result.setAlbum(sqlResult[4]);
+
+ //_result.setIcon(QString());
+ if ( !sqlResult[3].isEmpty() ) {
+ _result.setIcon(sqlResult[3]);
+ }
+
+ //counts the matched charecters
+ int i = queryString.find( ':' );
+ if ( i != -1 ) {
+ if ( queryString[i+1] != ' ' )
+ queryString.insert(i+1, ' ');
+ if ( queryString[i-1] != ' ' )
+ queryString.insert(i, ' ');
+ }
+ queryList = QStringList::split ( " ", queryString );
+ unsigned int matched = 0;
+ for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
+ if(matched < (_result.text().find(*it, matched, false) + (*it).length()))
+ matched = _result.text().find(*it, matched, false) + (*it).length();
+ }
+ setBestMatch(Match(&_result, 100*queryString.length()/_result.text().length(), matched));
+
+ //Checks if there are multiple results
+ if( !sqlResult[5].isEmpty() )
+ newStatus = S_HasResults | S_Multiple;
+ else
+ newStatus = S_HasResults;
+ }
+ } else {
+ newStatus = 0;
+ }
+ }
+
+ } else { // Dynamic Collection
+
+ // Do same as above here again but with dyn collection stuff
+
+ QStringList queryList;
+ //prepares SQL-queryQRegExp
+ QString sqlQuery("SELECT a.name, t.title, t.deviceid, d.lastmountpoint, t.url, i.path, album.name FROM tags t LEFT JOIN statistics s ON (t.url = s.url AND t.deviceid = s.deviceid) LEFT JOIN artist a ON (t.artist = a.id) LEFT JOIN album ON (t.album = album.id) LEFT JOIN images i ON ( a.name = i.artist AND album.name = i.album) LEFT JOIN devices d ON (t.deviceid = d.id) WHERE ");
+ queryList = QStringList::split ( QString(" "), QString(queryString).replace(QChar(':')," ").replace(QChar('\''), " ").replace(QChar('\''), "%") );
+
+ // Let's build each of these clauses
+ QStringList clauses;
+ for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
+
+ clauses += QString(" (t.title LIKE '\%%1\%'").arg(*it) +
+ QString(" OR a.name LIKE '\%%1\%')").arg(*it);
+ }
+ sqlQuery.append(clauses.join(QString(" AND ")));
+ sqlQuery.append(" ORDER BY a.name, t.title, s.percentage DESC");
+
+ //sending SQL-query to ararok via dcop
+ QByteArray sqlQueryData, replyData;
+ QCString replyType;
+ QDataStream arg(sqlQueryData, IO_WriteOnly);
+ arg << sqlQuery;
+ if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)",
+ sqlQueryData, replyType, replyData)) {
+ newStatus = 0;
+ } else {
+ QDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "QStringList") {
+ QStringList sqlResult;
+ reply >> sqlResult;
+
+ if(sqlResult.isEmpty()) {
+ newStatus = 0;
+ } else {
+ reset();
+ //Reads information from SQL-Query
+ _result.setArtist(sqlResult[0]);
+ _result.setName(sqlResult[1]);
+ if (sqlResult[2]!="-1") {
+ KURL absolutePath;
+ absolutePath.setPath( sqlResult[3] );
+ absolutePath.addPath( sqlResult[4] );
+ absolutePath.cleanPath();
+
+ _result.setURL( absolutePath );
+ } else {
+ KURL absolutePath;
+ absolutePath.setPath( "/" );
+ absolutePath.addPath( sqlResult[4] );
+ absolutePath.cleanPath();
+
+ _result.setURL( absolutePath );
+ }
+
+ _result.setAlbum(sqlResult[6]);
+
+ //_result.setIcon(QString());
+ if ( !sqlResult[3].isEmpty() ) {
+ _result.setIcon(sqlResult[5]);
+ }
+
+ //counts the matched charecters
+ int i = queryString.find( ':' );
+ if ( i != -1 ) {
+ if ( queryString[i+1] != ' ' )
+ queryString.insert(i+1, ' ');
+ if ( queryString[i-1] != ' ' )
+ queryString.insert(i, ' ');
+ }
+ queryList = QStringList::split ( " ", queryString );
+ unsigned int matched = 0;
+ for(QStringList::Iterator it = queryList.begin(); it != queryList.end(); ++it) {
+ if(matched < (_result.text().find(*it, matched, false) + (*it).length()))
+ matched = _result.text().find(*it, matched, false) + (*it).length();
+ }
+ setBestMatch(Match(&_result, 100*queryString.length()/_result.text().length(), matched));
+
+ //Checks if there are multiple results
+ if( !sqlResult[7].isEmpty() )
+ newStatus = S_HasResults | S_Multiple;
+ else
+ newStatus = S_HasResults;
+ }
+ } else {
+ newStatus = 0;
+ }
+ }
+
+
+ } //end of >1.4.2 section
+ setStatus(newStatus);
+
+ } else { //We haven't got the collection status
+
+ checkCollectionType();
+ reset();
+ setBestMatch(Match());
+ setStatus(0);
+ }
+
+
+ } //dont go after this while fixing
+
+}
+
+void AmarokCatalog::reset()
+{
+ _result.setName(QString::null);
+ _result.setArtist(QString::null);
+ _result.setAlbum(QString::null);
+ _result.setIcon(QString::null);
+}
+
+void AmarokCatalog::checkCollectionType()
+{
+ QString sqlQuery("SELECT COUNT(*) FROM admin WHERE noption = 'Database Devices Version'");
+
+ QByteArray sqlQueryData, replyData;
+ QCString replyType;
+ QDataStream arg(sqlQueryData, IO_WriteOnly);
+ arg << sqlQuery;
+ if (!kapp->dcopClient()->call("amarok", "collection", "query(QString)", sqlQueryData, replyType, replyData))
+ {
+ _gotCollectionStatus = false;
+
+ }
+ else
+ {
+ QDataStream reply(replyData, IO_ReadOnly);
+ if (replyType == "QStringList")
+ {
+ QStringList sqlResult;
+ reply >> sqlResult;
+
+ if (sqlResult[0] == "1")
+ {
+ _dynamicCollection = true;
+
+ }
+ else
+ {
+ _dynamicCollection = false;
+
+ }
+ _gotCollectionStatus = true;
+ }
+ else
+ {
+ _gotCollectionStatus = false;
+ }
+ }
+}
+
+
+/*
+void AmarokCatalog::initialize()
+{
+}
+*/
+
+unsigned int AmarokCatalog::minQueryLen() const
+{
+ return _minQueryLen;
+}
+
+QWidget * AmarokCatalog::configure()
+{
+ AmarokCatalogSettings *settings = new AmarokCatalogSettings();
+
+ settings->minQueryLen->setValue(_minQueryLen);
+ connect(settings->minQueryLen, SIGNAL(valueChanged(int)), this, SLOT(minQueryLenChanged(int)));
+ return settings;
+}
+
+void AmarokCatalog::minQueryLenChanged(int _minQueryLen)
+{
+ this->_minQueryLen = _minQueryLen;
+}
+
+void AmarokCatalog::readSettings(KConfigBase *config)
+{
+ _minQueryLen = config->readUnsignedNumEntry("MinQueryLen", 3);
+}
+
+void AmarokCatalog::writeSettings(KConfigBase *config)
+{
+ config->writeEntry("MinQueryLen", _minQueryLen);
+}
diff --git a/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.h b/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.h
new file mode 100644
index 0000000..bd735a3
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/amarokcatalog.h
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef AMAROKCATALOG_H
+#define AMAROKCATALOG_H
+
+#include <katapultcatalog.h>
+#include <kgenericfactory.h>
+#include <kconfigbase.h>
+#include "song.h"
+
+class QWidget;
+class QString;
+
+/**
+@author Bastian Holst
+*/
+class AmarokCatalog : public KatapultCatalog
+{
+ Q_OBJECT
+public:
+ AmarokCatalog(QObject*, const char*, const QStringList&);
+ virtual ~AmarokCatalog();
+
+ unsigned int minQueryLen() const;
+ void readSettings(KConfigBase *);
+ void writeSettings(KConfigBase *);
+ QWidget * configure();
+ //virtual void initialize();
+
+public slots:
+ void minQueryLenChanged(int);
+
+protected:
+ void queryChanged();
+ void reset();
+ void checkCollectionType();
+
+private:
+ unsigned int _minQueryLen;
+ bool _dynamicCollection;
+ bool _gotCollectionStatus;
+ Song _result;
+};
+
+#endif //AMAROkCATALOG_H
diff --git a/katapult/plugins/catalogs/amarokcatalog/coverimage.cpp b/katapult/plugins/catalogs/amarokcatalog/coverimage.cpp
new file mode 100644
index 0000000..4ea3f24
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/coverimage.cpp
@@ -0,0 +1,106 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kmdcodec.h>
+#include <qimage.h>
+#include <qdir.h>
+
+#include "coverimage.h"
+
+CoverImage::CoverImage()
+{
+ setArtist(QString());
+ setAlbum(QString());
+ setURL(QString());
+
+ _coverfolder = QDir::homeDirPath();
+ _coverfolder.append("/.kde/share/apps/amarok/albumcovers/");
+ _largefolder = QString(_coverfolder).append("large/");
+ _cachefolder = QString(_coverfolder).append("cache/");
+
+ QDir foldertest;
+ foldertest.setPath(_coverfolder);
+ if ( !foldertest.exists() )
+ foldertest.mkdir(_coverfolder);
+ if ( !foldertest.exists(_largefolder) )
+ foldertest.mkdir(_largefolder);
+ if ( !foldertest.exists(_cachefolder) )
+ foldertest.mkdir(_cachefolder);
+}
+
+QImage CoverImage::load(int size) const
+{
+ QString imagepath(_cachefolder);
+ KMD5 md5sum(artist().lower().utf8()+album().lower().utf8());
+ imagepath.append(QString::number ( size )).append("@").append(md5sum.hexDigest());
+ QImage image( imagepath );
+ if ( image.isNull() )
+ {
+ if ( !url().isEmpty() ) {
+ image.load(url());
+ } else {
+ imagepath = _largefolder;
+ imagepath.append(md5sum.hexDigest());
+ image.load( imagepath );
+ }
+
+ if ( !image.isNull() ) {
+ QString savepath(_cachefolder);
+ savepath.append(QString::number ( size )).append("@").append(md5sum.hexDigest());
+ image = image.smoothScale(size, size, QImage::ScaleMin);
+ if ( !url().isEmpty() ) {
+ image.save( savepath, QImage::imageFormat ( url() ));
+ } else {
+ image.save( savepath, QImage::imageFormat ( imagepath ));
+ }
+ }
+ }
+ return image;
+}
+
+QString CoverImage::artist() const
+{
+ return _artist;
+}
+
+QString CoverImage::album() const
+{
+ return _album;
+}
+
+QString CoverImage::url() const
+{
+ return _url;
+}
+
+void CoverImage::setArtist(const QString& artist)
+{
+ _artist = artist;
+}
+
+void CoverImage::setAlbum(const QString& album)
+{
+ _album = album;
+}
+
+void CoverImage::setURL(const QString& url)
+{
+ _url = url;
+}
diff --git a/katapult/plugins/catalogs/amarokcatalog/coverimage.h b/katapult/plugins/catalogs/amarokcatalog/coverimage.h
new file mode 100644
index 0000000..c7982c3
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/coverimage.h
@@ -0,0 +1,54 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef COVERIMAGE_H
+#define COVERIMAGE_H
+
+#include<qstring.h>
+#include<qimage.h>
+
+/**
+@author Bastian Holst
+*/
+class CoverImage
+{
+public:
+ CoverImage();
+
+ QImage load(int) const;
+
+ virtual QString artist() const;
+ virtual QString album() const;
+ virtual QString url() const;
+
+ void setArtist(const QString&);
+ void setAlbum(const QString&);
+ void setURL(const QString&);
+private:
+ QString _artist;
+ QString _album;
+ QString _url;
+
+ QString _coverfolder;
+ QString _largefolder;
+ QString _cachefolder;
+};
+
+#endif // COVERIMAGE_H
+
diff --git a/katapult/plugins/catalogs/amarokcatalog/katapult_amarokcatalog.desktop b/katapult/plugins/catalogs/amarokcatalog/katapult_amarokcatalog.desktop
new file mode 100644
index 0000000..deceddf
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/katapult_amarokcatalog.desktop
@@ -0,0 +1,44 @@
+[Desktop Entry]
+Name=Amarok Catalog
+Name[ar]=مستعرض ( Catalog ) Amarok
+Name[bg]=Каталог на Amarok
+Name[br]=Katalog Amarok
+Name[da]=Katalogisér Amarok
+Name[de]=amaroK-Katalog
+Name[el]=Κατάλογος Amarok
+Name[es]=Catálogo Amarok
+Name[et]=Amaroki kataloog
+Name[fr]=Catalogue Amarok
+Name[ga]=Catalóg Amarok
+Name[gl]=Catálogo de Amarok
+Name[it]=Catalogo Amarok
+Name[ja]=Amarok カタログ
+Name[nb]=Amarok-katalog
+Name[nl]=Amarok-catalogus
+Name[pt]=Catálogo do Amarok
+Name[pt_BR]=Catálogo do Amarok
+Name[sv]=Katalogisera Amarok
+Name[tr]=Amarok Kataloğu
+Name[uk]=Каталог Amarok
+Comment=Catalogs your KDE programs for easy launching through Katapult
+Comment[ar]=يستعرض برامجك كي دي أي ( KDE ) كي تستطيع اقلاعها بسهولة مستخدما Katapult
+Comment[bg]=Каталогизира с Katapult програмите в KDE за лесно стартиране
+Comment[da]=Katalogiserer dine KDE-programmer for nem start via Katapult
+Comment[de]=Katalogisiert Ihre KDE-Programme, um sie bequem mit Katapult zu starten
+Comment[el]=Δημιουργεί κατάλογο των προγραμμάτων σας του KDE για την εύκολη εκτέλεσή τους μέσω του Katapult
+Comment[es]=Cataloga sus programas de KDE para iniciarlos con facilidad a través de Katapult
+Comment[et]=Kataloogib sinu KDE programmid hõlpsaks käivitamiseks Katapultiga
+Comment[fr]=Cataloguer vos programmes KDE pour un lancement facile via Katapult
+Comment[gl]=Cataloga os seus programas de KDE para seren iniciados mediante Katapult
+Comment[it]=Cataloga in tuoi programmi KDE per avviarli facilmente attraverso Katapult
+Comment[ja]=Katapult から簡単に起動できるように KDE のプログラムをカタログ化
+Comment[nb]=Katalogiserer KDE-programmene for lettvint oppstart med Katapult
+Comment[nl]=Catalogiseert uw KDE-programma's voor eenvoudige opstart via Katapult
+Comment[pt]=Cataloga os seus programas do KDE para lançá-los facilmente através do Katapult
+Comment[pt_BR]=Cataloga os seus programas do KDE para lançá-los facilmente através do Katapult
+Comment[sv]=Katalogiserar dina KDE-program för enkel start via Katapult
+Comment[uk]=Робить каталог з програм KDE для легкого запуску через Катапульту
+ServiceTypes=Katapult/Catalog
+Type=Service
+X-KDE-Library=katapult_amarokcatalog
+X-Katapult-ID=Amarok Catalog
diff --git a/katapult/plugins/catalogs/amarokcatalog/settings.ui b/katapult/plugins/catalogs/amarokcatalog/settings.ui
new file mode 100644
index 0000000..70bb3ab
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/settings.ui
@@ -0,0 +1,80 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>AmarokCatalogSettings</class>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>AmarokCatalogSettings</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>376</width>
+ <height>519</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>Settings</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout1</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Number of characters before searching:</string>
+ </property>
+ </widget>
+ <widget class="KIntSpinBox">
+ <property name="name">
+ <cstring>minQueryLen</cstring>
+ </property>
+ <property name="maxValue">
+ <number>10</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>3</number>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Katapult will not search for programs until you have typed at least this many characters in the Katapult launcher.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>370</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+</widget>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>knuminput.h</includehint>
+</includehints>
+</UI>
diff --git a/katapult/plugins/catalogs/amarokcatalog/song.cpp b/katapult/plugins/catalogs/amarokcatalog/song.cpp
new file mode 100644
index 0000000..78b69fb
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/song.cpp
@@ -0,0 +1,91 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kurl.h>
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qstring.h>
+#include <amarokcatalog.h>
+
+#include "song.h"
+
+Song::Song(const QString&)
+ : KatapultItem()
+{
+ setName(QString());
+ setArtist(QString());
+ setURL(KURL());
+ setIcon(QString());
+ setAlbum(QString::null);
+}
+
+void Song::setArtist(const QString& artist)
+{
+ _artist = artist;
+ cover.setArtist(artist);
+}
+
+void Song::setName(const QString& name)
+{
+ _name = name;
+}
+
+void Song::setAlbum(const QString& album)
+{
+ cover.setAlbum(album);
+}
+
+void Song::setURL(const KURL url)
+{
+ _url = url;
+}
+
+void Song::setIcon(const QString icon)
+{
+ cover.setURL(icon);
+}
+
+QPixmap Song::icon(int size) const
+{
+ QImage image = cover.load(size);
+ if ( image.isNull() )
+ return KGlobal::iconLoader()->loadIcon("multimedia", KIcon::NoGroup, size);
+ return QPixmap(image);
+}
+
+QString Song::text() const
+{
+ QString text;
+ if( !_artist.isEmpty() ) {
+ text.append(_artist);
+ text.append(": ");
+ }
+ text.append(_name);
+ return text;
+}
+
+KURL Song::url() const
+{
+ return _url;
+}
+
+#include "song.moc"
diff --git a/katapult/plugins/catalogs/amarokcatalog/song.h b/katapult/plugins/catalogs/amarokcatalog/song.h
new file mode 100644
index 0000000..90e4819
--- /dev/null
+++ b/katapult/plugins/catalogs/amarokcatalog/song.h
@@ -0,0 +1,56 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Bastian Holst *
+ * bastianholst@gmx.de *
+ * *
+ * 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, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef SONG_H
+#define SONG_H
+
+#include "katapultitem.h"
+#include "coverimage.h"
+#include <kurl.h>
+#include <qstring.h>
+#include <qpixmap.h>
+
+/**
+@author Bastian Holst
+*/
+class Song : public KatapultItem
+{
+ Q_OBJECT
+public:
+ Song(const QString&);
+
+ virtual QPixmap icon(int) const;
+ virtual QString text() const;
+ virtual KURL url() const;
+
+ void setArtist(const QString&);
+ void setName(const QString&);
+ void setURL(const KURL);
+ void setIcon(const QString);
+ void setAlbum(const QString&);
+
+protected:
+ QString _artist;
+ QString _name;
+ KURL _url;
+
+ CoverImage cover;
+};
+
+#endif //SONG_H