File indexing completed on 2024-05-05 04:51:44
0001 /* 0002 SPDX-FileCopyrightText: 2008 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-FileCopyrightText: 2010-2011 Michal Malek <michalm@jabster.pl> 0004 SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org> 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef _K3B_DATA_PROJECT_MODEL_H_ 0009 #define _K3B_DATA_PROJECT_MODEL_H_ 0010 0011 #include <QAbstractItemModel> 0012 #include <QUrl> 0013 0014 namespace K3b { 0015 class DataDoc; 0016 class DataItem; 0017 class DirItem; 0018 0019 class DataProjectModel : public QAbstractItemModel 0020 { 0021 Q_OBJECT 0022 0023 public: 0024 explicit DataProjectModel( DataDoc* doc, QObject* parent = 0 ); 0025 ~DataProjectModel() override; 0026 0027 enum Columns { 0028 FilenameColumn = 0, 0029 TypeColumn, 0030 SizeColumn, 0031 NumColumns 0032 }; 0033 0034 enum AdditionalRoles 0035 { 0036 ItemTypeRole = Qt::UserRole, ///< returns int which is a combination of ItemType 0037 CustomFlagsRole, ///< returns int which is a combination of ItemFlags 0038 SortRole ///< returns data most suitable for sorting 0039 }; 0040 0041 enum ItemType 0042 { 0043 DirItemType, 0044 FileItemType 0045 }; 0046 0047 enum ItemFlags 0048 { 0049 ItemIsRemovable = 1 0050 }; 0051 0052 DataDoc* project() const; 0053 0054 DataItem* itemForIndex( const QModelIndex& index ) const; 0055 QModelIndex indexForItem( DataItem* item ) const; 0056 0057 int columnCount( const QModelIndex& parent = QModelIndex() ) const override; 0058 QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override; 0059 QVariant headerData ( int section, Qt::Orientation orientation, int role ) const override; 0060 Qt::ItemFlags flags( const QModelIndex& index ) const override; 0061 QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override; 0062 QModelIndex parent( const QModelIndex& index ) const override; 0063 int rowCount( const QModelIndex& parent = QModelIndex() ) const override; 0064 bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override; 0065 QMimeData* mimeData( const QModelIndexList& indexes ) const override; 0066 Qt::DropActions supportedDropActions() const override; 0067 QStringList mimeTypes() const override; 0068 bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) override; 0069 bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ) override; 0070 QModelIndex buddy( const QModelIndex& index ) const override; 0071 0072 Q_SIGNALS: 0073 void addUrlsRequested( QList<QUrl> urls, K3b::DirItem* targetDir ); 0074 void moveItemsRequested( QList<K3b::DataItem*> items, K3b::DirItem* targetDir ); 0075 0076 private: 0077 class Private; 0078 Private* const d; 0079 0080 Q_PRIVATE_SLOT( d, void _k_itemsAboutToBeInserted( K3b::DirItem* parent, int start, int end ) ) 0081 Q_PRIVATE_SLOT( d, void _k_itemsAboutToBeRemoved( K3b::DirItem* parent, int start, int end ) ) 0082 Q_PRIVATE_SLOT( d, void _k_itemsInserted( K3b::DirItem* parent, int start, int end ) ) 0083 Q_PRIVATE_SLOT( d, void _k_itemsRemoved( K3b::DirItem* parent, int start, int end ) ) 0084 Q_PRIVATE_SLOT( d, void _k_volumeIdChanged() ) 0085 }; 0086 } 0087 0088 #endif