File indexing completed on 2024-05-05 04:47:22

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Ian Monroe <ian@monroe.nu>                                        *
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) version 3 or        *
0007  * any later version accepted by the membership of KDE e.V. (or its successor approved  *
0008  * by the membership of KDE e.V.), which shall act as a proxy defined in Section 14 of  *
0009  * version 3 of the license.                                                            *
0010  *                                                                                      *
0011  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0012  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0013  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0014  *                                                                                      *
0015  * You should have received a copy of the GNU General Public License along with         *
0016  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0017  ****************************************************************************************/
0018 
0019 #ifndef AMAROK_COLLECTION_WIDGET
0020 #define AMAROK_COLLECTION_WIDGET
0021 
0022 #include "browsers/BrowserCategory.h"
0023 
0024 class QAction;
0025 class CollectionBrowserTreeView;
0026 class SearchWidget;
0027 
0028 class CollectionWidget : public BrowserCategory
0029 {
0030     Q_OBJECT
0031 
0032     public:
0033         enum ViewMode
0034         {
0035             UnifiedCollection,
0036             NormalCollections
0037         };
0038         Q_ENUM( ViewMode )
0039 
0040         explicit CollectionWidget( const QString &name , QWidget *parent );
0041         ~CollectionWidget() override;
0042         static CollectionWidget *instance() { return s_instance; }
0043 
0044 
0045         QString filter() const override;
0046 
0047         /**
0048          * Apply a filter to the tree view.
0049          * @param filter The filter to apply.
0050          */
0051         void setFilter( const QString &filter ) override;
0052 
0053         /** Return the current views selected levels */
0054         QList<CategoryId::CatMenuId> levels() const override;
0055 
0056         /** Set the current views selected levels */
0057         void setLevels( const QList<CategoryId::CatMenuId> &levels ) override;
0058 
0059         void focusInputLine();
0060         CollectionBrowserTreeView *currentView();
0061         SearchWidget *searchWidget();
0062         ViewMode viewMode() const;
0063 
0064     public Q_SLOTS:
0065         void sortLevelSelected( QAction * );
0066         void sortByActionPayload( QAction * );
0067         void slotShowYears( bool checked );
0068         void slotShowTrackNumbers( bool checked );
0069         void slotShowCovers( bool checked );
0070 
0071         void toggleView( bool merged );
0072 
0073     private:
0074         QList<CategoryId::CatMenuId> readLevelsFromConfig() const;
0075 
0076         class Private;
0077         Private *const d;
0078         static CollectionWidget *s_instance;
0079 
0080         CollectionWidget( const CollectionWidget& );
0081         CollectionWidget& operator=( const CollectionWidget& );
0082 };
0083 
0084 #endif