File indexing completed on 2024-05-19 04:48:39

0001 /****************************************************************************************
0002  * Copyright (c) 2009-2010 Bart Cerneels <bart.cerneels@kde.org>                        *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef PLAYLISTBROWSERCATEGORY_H
0018 #define PLAYLISTBROWSERCATEGORY_H
0019 
0020 #include "browsers/BrowserCategory.h"
0021 
0022 #include <QMap>
0023 #include <QAction>
0024 
0025 namespace Amarok {
0026     class PrettyTreeView;
0027 }
0028 
0029 class QAbstractItemDelegate;
0030 class QTreeView;
0031 
0032 class QAction;
0033 class KActionMenu;
0034 class KToolBar;
0035 
0036 class PlaylistsInFoldersProxy;
0037 class PlaylistsByProviderProxy;
0038 class PlaylistBrowserFilterProxy;
0039 
0040 namespace Playlists {
0041     class PlaylistProvider;
0042 }
0043 
0044 namespace PlaylistBrowserNS {
0045 
0046 class PlaylistBrowserModel;
0047 
0048 class PlaylistBrowserCategory : public BrowserCategory
0049 {
0050     Q_OBJECT
0051 
0052 public:
0053     static QString s_mergeViewKey;
0054 
0055     explicit PlaylistBrowserCategory( int playlistCategory,
0056                                   const QString &categoryName,
0057                                   const QString &configGroup,
0058                                   PlaylistBrowserModel *model,
0059                                   QWidget *parent );
0060     ~PlaylistBrowserCategory() override;
0061 
0062     QString filter() const override;
0063     void setFilter( const QString &filter ) override;
0064 
0065     /**
0066      * Sets the help text for the action.
0067      * This help text will be set for all help mechanisms:
0068      *  - the status-bar help text
0069      *  - the tooltip (for toolbar buttons)
0070      *  - the "WhatsThis" help text (unless one was already set)
0071      *
0072      * This is more convenient than calling all three methods with the
0073      * same text, and this level of abstraction can allow to change
0074      * the default implementation of help one day more easily.
0075      * Of course you can also call setStatusTip, setToolTip and setWhatsThis
0076      * separately for more flexibility.
0077      *
0078      */
0079     void setHelpText(const QString &text, QAction *qa);
0080 
0081 protected:
0082     KToolBar *m_toolBar;
0083 
0084     /**
0085      * A separator in between the add-folder action and visible-source,
0086      * merged-view actions. Subclasses can use it to insert their specialized
0087      * actions at a suitable place, thus keeping the generic actions in order.
0088      */
0089     QAction *m_separator;
0090 
0091     QTreeView *playlistView();
0092 
0093 private Q_SLOTS:
0094     void toggleView( bool mergedView );
0095     void slotProviderAdded( Playlists::PlaylistProvider *provider, int category );
0096     void slotProviderRemoved( Playlists::PlaylistProvider *provider, int category );
0097     void slotToggleProviderButton();
0098 
0099     void createNewFolder();
0100 
0101     void newPalette( const QPalette &palette );
0102 
0103 private:
0104     void createProviderButton( const Playlists::PlaylistProvider *provider );
0105 
0106     KActionMenu *m_providerMenu;
0107     QMap<const Playlists::PlaylistProvider *, QAction *> m_providerActions;
0108 
0109     Amarok::PrettyTreeView *m_playlistView;
0110 
0111     QAction *m_addFolderAction;
0112 
0113     QAbstractItemDelegate *m_byProviderDelegate;
0114     QAbstractItemDelegate *m_defaultItemDelegate;
0115     PlaylistsInFoldersProxy *m_byFolderProxy;
0116     PlaylistsByProviderProxy *m_byProviderProxy;
0117     PlaylistBrowserFilterProxy *m_filterProxy;
0118 
0119     QString m_configGroup;
0120     int m_playlistCategory;
0121 };
0122 
0123 } //namespace PlaylistBrowserNS
0124 
0125 //for saving it in a QVariant
0126 Q_DECLARE_METATYPE( const Playlists::PlaylistProvider * )
0127 
0128 #endif // PLAYLISTBROWSERCATEGORY_H