File indexing completed on 2024-05-05 04:48:44
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Téo Mrnjavac <teo@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 PLAYLISTSORTWIDGET_H 0018 #define PLAYLISTSORTWIDGET_H 0019 0020 #include "PlaylistBreadcrumbItem.h" 0021 0022 #include <QAction> 0023 #include <QHBoxLayout> 0024 0025 namespace Playlist 0026 { 0027 0028 /** 0029 * A breadcrumb-based widget that allows the user to build a multilevel sorting scheme for 0030 * the playlist. 0031 * @author Téo Mrnjavac 0032 */ 0033 class SortWidget : public QWidget 0034 { 0035 Q_OBJECT 0036 public: 0037 /** 0038 * Constructor. 0039 */ 0040 explicit SortWidget( QWidget *parent ); 0041 0042 /** 0043 * Destructor. 0044 */ 0045 ~SortWidget() override; 0046 0047 /** 0048 * Returns the list of levels that are currently defined in the breadcrumb path. 0049 * @return the list of names of levels. 0050 */ 0051 QStringList levels() const; 0052 0053 /** 0054 * Generates a QString usable by a URL runner that represents the current sort scheme. 0055 */ 0056 QString sortPath() const; 0057 0058 /** 0059 * Generate current sort scheme from a sort path stored in a QString. 0060 */ 0061 void readSortPath( const QString &sortPath ); 0062 0063 /** 0064 * Generates a user-visible QString usable by a URL runner for the title of a bookmark. 0065 */ 0066 QString prettySortPath() const; 0067 0068 public Q_SLOTS: 0069 /** 0070 * Generates a new sort scheme and forwards it to Playlist::SortProxy to apply it to 0071 * the playlist. 0072 */ 0073 void updateSortScheme(); 0074 0075 /** 0076 * Removes items from the breadcrumb path up to a certain level. 0077 * @param level the cutoff level of the breadcrumb path. 0078 */ 0079 void trimToLevel( const int level = -1 ); 0080 0081 private: 0082 QHBoxLayout * m_ribbon; 0083 QList< BreadcrumbItem * > m_items; 0084 BreadcrumbAddMenuButton * m_addButton; 0085 QHBoxLayout * m_layout; 0086 BreadcrumbUrlMenuButton *m_urlButton; 0087 0088 private Q_SLOTS: 0089 /** 0090 * Adds a level to the breadcrumb path. 0091 * @param internalColumnName the name of the level. 0092 * @param sortOrder the Qt::SortOrder of the level. 0093 */ 0094 void addLevel( const QString &internalColumnName, Qt::SortOrder sortOrder = Qt::AscendingOrder ); 0095 0096 /** 0097 * Adds a level to the breadcrumb path. 0098 * Orders the level in ascending order. 0099 * @param internalColumnName the name of the level. 0100 */ 0101 void addLevelAscending( const QString &internalColumnName ); 0102 0103 /** 0104 * Handles the (possible) deletion of further levels when an item is clicked. 0105 */ 0106 void onItemClicked(); 0107 0108 /** 0109 * Handles the rearrangement of the breadcrumb path when a sibling of an item is clicked. 0110 * @param action the action in the menu. 0111 */ 0112 void onItemSiblingClicked( const QString &internalColumnName ); 0113 0114 /** 0115 * Handles the rearrangement of the breadcrumb path when a Shuffle action is clicked. 0116 */ 0117 void onShuffleSiblingClicked(); 0118 }; 0119 0120 } //namespace Playlist 0121 0122 #endif //PLAYLISTSORTWIDGET_H