1 /*
2     SPDX-FileCopyrightText: 2008 Sebastian Trueg <trueg@k3b.org>
3     SPDX-FileCopyrightText: 2010-2011 Michal Malek <michalm@jabster.pl>
4     SPDX-FileCopyrightText: 1998-2008 Sebastian Trueg <trueg@k3b.org>
5     SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #ifndef _K3B_DATA_PROJECT_MODEL_H_
9 #define _K3B_DATA_PROJECT_MODEL_H_
10 
11 #include <QAbstractItemModel>
12 #include <QUrl>
13 
14 namespace K3b {
15     class DataDoc;
16     class DataItem;
17     class DirItem;
18 
19     class DataProjectModel : public QAbstractItemModel
20     {
21         Q_OBJECT
22 
23     public:
24         explicit DataProjectModel( DataDoc* doc, QObject* parent = 0 );
25         ~DataProjectModel() override;
26 
27         enum Columns {
28             FilenameColumn = 0,
29             TypeColumn,
30             SizeColumn,
31             NumColumns
32         };
33 
34         enum AdditionalRoles
35         {
36             ItemTypeRole = Qt::UserRole,  ///< returns int which is a combination of ItemType
37             CustomFlagsRole,              ///< returns int which is a combination of ItemFlags
38             SortRole                      ///< returns data most suitable for sorting
39         };
40 
41         enum ItemType
42         {
43             DirItemType,
44             FileItemType
45         };
46 
47         enum ItemFlags
48         {
49             ItemIsRemovable = 1
50         };
51 
52         DataDoc* project() const;
53 
54         DataItem* itemForIndex( const QModelIndex& index ) const;
55         QModelIndex indexForItem( DataItem* item ) const;
56 
57         int columnCount( const QModelIndex& parent = QModelIndex() ) const override;
58         QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const override;
59         QVariant headerData ( int section, Qt::Orientation orientation, int role ) const override;
60         Qt::ItemFlags flags( const QModelIndex& index ) const override;
61         QModelIndex index( int row, int column, const QModelIndex& parent = QModelIndex() ) const override;
62         QModelIndex parent( const QModelIndex& index ) const override;
63         int rowCount( const QModelIndex& parent = QModelIndex() ) const override;
64         bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole ) override;
65         QMimeData* mimeData( const QModelIndexList& indexes ) const override;
66         Qt::DropActions supportedDropActions() const override;
67         QStringList mimeTypes() const override;
68         bool dropMimeData( const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent ) override;
69         bool removeRows( int row, int count, const QModelIndex& parent = QModelIndex() ) override;
70         QModelIndex buddy( const QModelIndex& index ) const override;
71 
72     Q_SIGNALS:
73         void addUrlsRequested( QList<QUrl> urls, K3b::DirItem* targetDir );
74         void moveItemsRequested( QList<K3b::DataItem*> items, K3b::DirItem* targetDir );
75 
76     private:
77         class Private;
78         Private* const d;
79 
80         Q_PRIVATE_SLOT( d, void _k_itemsAboutToBeInserted( K3b::DirItem* parent, int start, int end ) )
81         Q_PRIVATE_SLOT( d, void _k_itemsAboutToBeRemoved( K3b::DirItem* parent, int start, int end ) )
82         Q_PRIVATE_SLOT( d, void _k_itemsInserted( K3b::DirItem* parent, int start, int end ) )
83         Q_PRIVATE_SLOT( d, void _k_itemsRemoved( K3b::DirItem* parent, int start, int end ) )
84         Q_PRIVATE_SLOT( d, void _k_volumeIdChanged() )
85     };
86 }
87 
88 #endif
89