archivemodel.h 2.26 KB
Newer Older
Henrique Pinto's avatar
Henrique Pinto committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/*
 * ark -- archiver for the KDE project
 *
 * Copyright (C) 2007 Henrique Pinto <henrique.pinto@kdemail.net>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */
21
22
23
24
25
26
#ifndef ARCHIVEMODEL_H
#define ARCHIVEMODEL_H

#include <QAbstractItemModel>
#include "kerfuffle/arch.h"

27
class ArchiveNode;
28
29
30
31
32
33
class ArchiveDirNode;

class ArchiveModel: public QAbstractItemModel
{
	Q_OBJECT
	public:
34
		ArchiveModel( QObject *parent = 0 );
35
36
37
38
39
40
41
42
43
44
45
46
		~ArchiveModel();

		QVariant data( const QModelIndex &index, int role ) const;
		Qt::ItemFlags flags( const QModelIndex &index ) const;
		QVariant headerData( int section, Qt::Orientation orientation,
		                     int role = Qt::DisplayRole ) const;
		QModelIndex index( int row, int column,
		                   const QModelIndex &parent = QModelIndex() ) const;
		QModelIndex parent( const QModelIndex &index ) const;
		int rowCount( const QModelIndex &parent = QModelIndex() ) const;
		int columnCount( const QModelIndex &parent = QModelIndex() ) const;

47
		void setArchive( Arch *archive );
48
		Arch *archive() const { return m_archive; }
49

50
51
		ArchiveEntry entryForIndex( const QModelIndex &index );

Henrique Pinto's avatar
Henrique Pinto committed
52
53
		void extractFile( const QVariant& fileName, const QString & destinationDir );

54
55
56
	signals:
		void loadingStarted();
		void loadingFinished();
Henrique Pinto's avatar
Henrique Pinto committed
57
		void extractionFinished( bool success );
58
		void error( const QString& error, const QString& details );
59

60
61
62
63
	private slots:
		void slotNewEntry( const ArchiveEntry& entry );

	private:
64
65
66
		ArchiveDirNode* parentFor( const ArchiveEntry& entry );
		QModelIndex indexForNode( ArchiveNode *node );

67
68
69
70
71
		Arch *m_archive;
		ArchiveDirNode *m_rootNode;
};

#endif // ARCHIVEMODEL_H