Revert previous commit, was incorrect
[amarok.git] / src / servicebrowser / servicebase.h
blobb1eafb33aeac43bfe50bbe17321761bef359407a
1 /***************************************************************************
2 * Copyright (c) 2007 Nikolaj Hald Nielsen <nhnFreespirit@gmail.com> *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ***************************************************************************/
20 #ifndef AMAROKSERVICEBASE_H
21 #define AMAROKSERVICEBASE_H
24 #include "amarok.h"
25 //#include "servicemodelitembase.h"
26 //#include "servicemodelbase.h"
28 #include "infoparserbase.h"
30 #include "amarok_export.h"
31 #include "../collectionbrowser/SingleCollectionTreeItemModel.h"
32 #include "../collectionbrowser/CollectionTreeItem.h"
33 #include "../collectionbrowser/CollectionTreeView.h"
34 #include "plugin/plugin.h"
36 #include <khtml_part.h>
37 //#include <klistwidget.h>
38 #include <kvbox.h>
40 #include <QPushButton>
41 #include <QSortFilterProxyModel>
42 #include <QSplitter>
43 //#include <QTreeView>
45 #include <KPluginInfo>
47 class ServiceBase;
49 class AMAROK_EXPORT ServiceFactory : public QObject, public Amarok::Plugin
51 Q_OBJECT
52 public:
53 ServiceFactory();
54 virtual ~ServiceFactory();
56 virtual void init() = 0;
57 virtual QString name() = 0;
58 virtual KConfigGroup config() = 0;
59 virtual KPluginInfo info() = 0;
61 signals:
62 void newService( class ServiceBase *newService );
66 /**
67 A very basic composite widget used as a base for building service browsers.
69 @author Nikolaj Hald Nielsen <nhnFreespirit@gmail.com>
71 class AMAROK_EXPORT ServiceBase : public KVBox
73 Q_OBJECT
75 public:
78 /**
79 * Constructor
81 ServiceBase( const QString &name );
83 /**
84 * Destructor
86 ~ServiceBase();
89 QString getName();
91 void setShortDescription( const QString &shortDescription );
92 QString getShortDescription();
93 void setLongDescription( const QString &longDescription );
94 QString getLongDescription();
95 void setIcon( const QIcon &icon );
96 QIcon getIcon();
97 void setModel( SingleCollectionTreeItemModel * model );
98 SingleCollectionTreeItemModel * getModel();
101 virtual void polish() = 0;
102 virtual bool updateContextView() { return false; }
104 public slots:
106 //void treeViewSelectionChanged( const QItemSelection & selected );
107 void infoChanged ( const QString &infoHtml );
110 signals:
112 void home();
113 void selectionChanged ( CollectionTreeItem * );
116 protected slots:
119 * Toggles the info area on and off
120 * @param show If true the info box is shown, if false it is hidden
122 void showInfo(bool show);
124 void homeButtonClicked();
126 void itemActivated ( const QModelIndex & index );
128 void itemSelected( CollectionTreeItem * item );
131 protected:
133 virtual void generateWidgetInfo() const;
135 static ServiceBase *s_instance;
137 QSplitter *m_mainSplitter;
138 CollectionTreeView *m_contentView;
139 KHTMLPart *m_infoBox;
141 QPushButton *m_homeButton;
143 KVBox *m_topPanel;
144 KVBox *m_bottomPanel;
145 bool m_isInfoShown;
146 bool m_polished;
148 QString m_name;
149 QString m_shortDescription;
150 QString m_longDescription;
151 QIcon m_icon;
153 KUrl::List m_urlsToInsert;
155 InfoParserBase * m_infoParser;
157 //void addToPlaylist( CollectionTreeItem * item );
161 private: // need to move stuff here
162 SingleCollectionTreeItemModel * m_model;
163 QSortFilterProxyModel * m_filterModel;
168 #endif