File indexing completed on 2024-05-19 04:49:51
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 AMAROK_PLAYLISTSORTSCHEME_H 0018 #define AMAROK_PLAYLISTSORTSCHEME_H 0019 0020 #include "playlist/PlaylistDefines.h" 0021 0022 #include <QSortFilterProxyModel> 0023 #include <QStack> 0024 0025 namespace Playlist 0026 { 0027 0028 /** 0029 * A sorting level for multilevel playlist sorting. Instances of this class are aggregated 0030 * by Playlist::SortScheme to describe a way to sort the playlist. 0031 * @author Téo Mrnjavac <teo@kde.org> 0032 */ 0033 class SortLevel 0034 { 0035 public: 0036 explicit SortLevel( Column sortCategory = PlaceHolder, Qt::SortOrder sortOrder = Qt::AscendingOrder ); 0037 Column category() const; 0038 Qt::SortOrder order() const; 0039 void setCategory( Column sortCategory ); 0040 void setOrder( Qt::SortOrder sortOrder ); 0041 bool isComparable() const; 0042 bool isString() const; 0043 bool isFloat() const; 0044 QString prettyName() const; 0045 private: 0046 Column m_category; //Column from PlaylistDefines.h 0047 Qt::SortOrder m_order; 0048 }; 0049 0050 /** 0051 * A sorting scheme for multilevel playlist sorting. This class wraps around a QStack to 0052 * define a way to sort the playlist and is used by Playlist::SortProxy. 0053 * @author Téo Mrnjavac <teo@kde.org> 0054 * @author Konrad Zemek <konrad.zemek@gmail.com> 0055 */ 0056 class SortScheme : private QStack<SortLevel> 0057 { 0058 public: 0059 const SortLevel &level( int i ) const; 0060 void addLevel( const SortLevel &level ); 0061 0062 /** Deletes all the levels up to level # length */ 0063 void trimToLevel( int lastLevel ); 0064 int length() const; 0065 0066 typedef QStack<SortLevel>::const_iterator const_iterator; 0067 0068 const_iterator begin() const; 0069 const_iterator end() const; 0070 }; 0071 0072 } //namespace Playlist 0073 0074 #endif //AMAROK_PLAYLISTSORTSCHEME_H