File indexing completed on 2024-05-19 04:48:41
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 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 PLAYLISTSINFOLDERSPROXY_H 0018 #define PLAYLISTSINFOLDERSPROXY_H 0019 0020 #include "QtGroupingProxy.h" 0021 #include "PlaylistBrowserModel.h" 0022 0023 #include <QAction> 0024 0025 class QAction; 0026 0027 typedef QList<QPersistentModelIndex> QPersistentModelIndexList; 0028 0029 class PlaylistsInFoldersProxy : public QtGroupingProxy 0030 { 0031 Q_OBJECT 0032 public: 0033 explicit PlaylistsInFoldersProxy( QAbstractItemModel *model ); 0034 ~PlaylistsInFoldersProxy() override; 0035 0036 /* PlaylistInGroupsProxy methods */ 0037 QModelIndex createNewFolder( const QString &groupName ); 0038 0039 /* QtGroupingProxy methods */ 0040 //re-implemented to make folder name (== label) editable. 0041 Qt::ItemFlags flags(const QModelIndex &idx) const override; 0042 QVariant data( const QModelIndex &idx, int role ) const override; 0043 0044 /* QAbstractModel methods */ 0045 bool removeRows( int row, int count, 0046 const QModelIndex &parent = QModelIndex() ) override; 0047 QStringList mimeTypes() const override; 0048 QMimeData *mimeData( const QModelIndexList &indexes ) const override; 0049 bool dropMimeData( const QMimeData *data, Qt::DropAction action, 0050 int row, int column, const QModelIndex &parent ) override; 0051 0052 Qt::DropActions supportedDropActions() const override; 0053 Qt::DropActions supportedDragActions() const override; 0054 0055 // re-implement to connect renameIndex signal 0056 void setSourceModel( QAbstractItemModel *sourceModel ) override; 0057 0058 private Q_SLOTS: 0059 void slotRenameIndex( const QModelIndex &idx ); 0060 0061 void slotDeleteFolder(); 0062 void slotRenameFolder(); 0063 0064 private: 0065 QList<QAction *> createGroupActions(); 0066 void deleteFolder( const QModelIndex &groupIdx ); 0067 0068 QAction *m_renameFolderAction; 0069 QAction *m_deleteFolderAction; 0070 }; 0071 0072 Q_DECLARE_METATYPE(QPersistentModelIndexList); 0073 0074 #endif //PLAYLISTSINFOLDERSPROXY_H