summaryrefslogtreecommitdiffstats
path: root/amarok/src/contextbrowser.h
blob: 2f046c5cd0e5e8a131a45681f43579b32222216b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
// (c) 2004 Christian Muehlhaeuser <chris@chris.de>
// (c) 2005 Reigo Reinmets <xatax@hot.ee>
// (c) 2005 Mark Kretschmann <markey@web.de>
// (c) 2006 Peter C. Ndikuwera <pndiku@gmail.com>
// License: GNU General Public License V2


#ifndef AMAROK_CONTEXTBROWSER_H
#define AMAROK_CONTEXTBROWSER_H

#include "amarokdcophandler.h"
#include "clicklineedit.h"
#include "engineobserver.h"

#include <ktabwidget.h>
#include <tdetoolbarbutton.h>
#include <kurl.h>

class ClickLineEdit;
class CollectionDB;
class Color;
class HTMLView;
class TDEPopupMenu;
class MetaBundle;
class TQPalette;
class TQVBox;
class TQLineEdit;
class TQComboBox;
class KDialogBase;
class KTabBar;
class KTextEdit;

class CueFile;

namespace Browser { class ToolBar; }
namespace TDEIO { class Job; class TransferJob; }


class ContextBrowser : public KTabWidget, public EngineObserver
{
    Q_OBJECT
  

        friend class CurrentTrackJob;
        friend class Amarok::DcopContextBrowserHandler;

        static ContextBrowser *s_instance;

    public:
        ContextBrowser( const char *name );
       ~ContextBrowser();

        static ContextBrowser *instance() { return s_instance; }

        void setFont( const TQFont& );
        void reloadStyleSheet();
        static KURL::List expandURL( const KURL &url ); // expand urls (album, compilation, ...)
        static bool hasContextProtocol( const KURL &url ); // is url expandable by context browser?

        virtual bool eventFilter( TQObject *o, TQEvent *e ); //required by the labels dialog

    public slots:
        void openURLRequest(const KURL &url );
        void collectionScanStarted();
        void collectionScanDone( bool changed );
        void renderView();
        void lyricsChanged( const TQString& );
        void lyricsScriptChanged();
        void lyricsResult( TQCString cXmlDoc, bool cached = false );

    protected:
        void engineNewMetaData( const MetaBundle&, bool );
        void engineStateChanged( Engine::State, Engine::State = Engine::Empty );
        void paletteChange( const TQPalette& );

    protected slots:
        void wheelDelta( int delta );

    private slots:
        void tabChanged( TQWidget *page );
        void slotContextMenu( const TQString& urlString, const TQPoint& point );
        void showContext( const KURL& url, bool fromHistory = false );
        void showCurrentTrack();
        void showLyrics( const TQString& url = TQString() );
        void showWikipedia( const TQString& url = TQString(), bool fromHistory = false, bool replaceHistory = false );
        void showWikipediaEntry( const TQString& entry, bool replaceHistory = false );
        void reloadWikipedia();
        void showLabelsDialog();

        void coverFetched( const TQString &artist, const TQString &album );
        void coverRemoved( const TQString &artist, const TQString &album );
        void similarArtistsFetched( const TQString &artist );
        void imageFetched( const TQString &remoteURL );
        void tagsChanged( const MetaBundle &bundle );
        void tagsChanged( const TQString &oldArtist, const TQString &oldAlbum );
        void ratingOrScoreOrLabelsChanged( const TQString &path );
        void refreshCurrentTrackPage();

        void contextHistoryBack();

        void lyricsAdd();
        void lyricsEditToggle();
        void lyricsSearch();
        void lyricsRefresh();
        void lyricsExternalPage();

	void lyricsSearchText( const TQString &text );
	void lyricsSearchTextNext();
	void lyricsSearchTextHide();
	void lyricsSearchTextShow();
	void lyricsSearchTextToggle();

        void wikiHistoryBack();
        void wikiHistoryForward();
        void wikiBackPopupActivated( int id );
        void wikiForwardPopupActivated( int id );
        void wikiArtistPage();
        void wikiAlbumPage();
        void wikiTitlePage();
        void wikiExternalPage();
        void wikiResult( TDEIO::Job* job );
        void wikiConfigApply();
        void wikiConfig();
        void wikiConfigChanged( int activeItem );

    private:
        enum { CONTEXT_BACK, CONTEXT_FORWARD, CONTEXT_CURRENT, CONTEXT_HOME, CONTEXT_SEARCH };
        enum { LYRICS_ADD, LYRICS_EDIT, LYRICS_SEARCH, LYRICS_REFRESH, LYRICS_BROWSER };
        enum { WIKI_BACK, WIKI_FORWARD, WIKI_ARTIST, WIKI_ALBUM, WIKI_TITLE, WIKI_BROWSER, WIKI_CONFIG };
        typedef enum {SHOW_ALBUM_NORMAL, SHOW_ALBUM_SCORE, SHOW_ALBUM_LEAST_PLAY} T_SHOW_ALBUM_TYPE;
        static const uint WIKI_MAX_HISTORY = 20;
        static const uint CONTEXT_MAX_HISTORY = 20;

        void showIntroduction();
        void saveHtmlData();
        void showScanning();

        static TQString getEncodedImage( const TQString &imageUrl );

        static TQString wikiLocale();
        static void setWikiLocale( const TQString &locale );
        static TQString wikiURL( const TQString &item );
        TQString wikiArtistPostfix() const;
        TQString wikiAlbumPostfix() const;
        TQString wikiTrackPostfix() const;

        HTMLView    *m_currentTrackPage;
        HTMLView    *m_lyricsPage;
        HTMLView    *m_wikiPage;

        TQVBox        *m_contextTab;
        TQVBox        *m_lyricsTab;
        TQVBox        *m_wikiTab;
        // These controls are used to dictate whether the page should be rebuilt
        // true -> need rebuild
        bool          m_dirtyCurrentTrackPage;
        bool          m_dirtyLyricsPage;
        bool          m_dirtyWikiPage;

        TQStringList   m_contextBackHistory;
        KURL          m_contextURL;

        TQString       m_styleSheet;
        bool          m_emptyDB;
        TQString       m_lyricAddUrl;
        TQString       m_lyricSearchUrl;
        TQString       m_lyricCurrentUrl;
        Browser::ToolBar* m_lyricsToolBar;
        KTextEdit*    m_lyricsTextEdit;
        TQString       m_lyricsBeingEditedUrl;
        TQString       m_lyricsBeingEditedArtist;
        TQString       m_lyricsBeingEditedTitle;
        ClickLineEdit* m_lyricsSearchText;
        TDEToolBar*     m_lyricsTextBar;
        bool          m_lyricsTextBarShowed;


        TQString       m_wiki;
        TQString       m_wikiLanguages;
        static TQString s_wikiLocale;
        TQString       m_wikiBaseUrl;
        TQString       m_wikiCurrentUrl;
        TQString       m_wikiCurrentEntry;
        TQStringList   m_wikiBackHistory;
        TQStringList   m_wikiForwardHistory;
        TDEPopupMenu*   m_wikiBackPopup;
        TDEPopupMenu*   m_wikiForwardPopup;
        TDEIO::TransferJob* m_wikiJob;
        Browser::ToolBar* m_wikiToolBar;
        TQLineEdit*    m_wikiLocaleEdit;
        TQComboBox*    m_wikiLocaleCombo;
        KDialogBase*  m_wikiConfigDialog;

        TQString       m_HTMLSource;
        TQStringList   m_metadataHistory;
        KURL          m_currentURL;

        bool          m_relatedOpen;
        bool          m_suggestionsOpen;
        bool          m_favoritesOpen;
        bool          m_labelsOpen;
        bool          m_showRelated;
        bool          m_showSuggested;
        bool          m_showFaves;
        bool          m_showLabels;

        bool          m_showFreshPodcasts;
        bool          m_showFavoriteAlbums;
        bool          m_showNewestAlbums;

        bool          m_browseArtists;
        TQString       m_artist;
        TQStringList   m_shownAlbums;

        bool          m_browseLabels;
        TQString       m_label;
        ClickLineEdit* m_addLabelEdit;
        TQListView*    m_labelListView;

        CueFile      *m_cuefile;
};

#endif /* AMAROK_CONTEXTBROWSER_H */