PageRenderTime 837ms CodeModel.GetById 31ms app.highlight 71ms RepoModel.GetById 39ms app.codeStats 0ms

/src/libtomahawk/widgets/checkdirtree.h

http://github.com/tomahawk-player/tomahawk
C++ Header | 91 lines | 53 code | 20 blank | 18 comment | 0 complexity | 596fcf4709fbafb0004ab2ec5da3d4af MD5 | raw file
 1/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
 2 *
 3 *   Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
 4 *   Copyright      2011, Leo Franchi <lfranchi@kde.org>
 5 *
 6 *   Tomahawk is free software: you can redistribute it and/or modify
 7 *   it under the terms of the GNU General Public License as published by
 8 *   the Free Software Foundation, either version 3 of the License, or
 9 *   (at your option) any later version.
10 *
11 *   Tomahawk is distributed in the hope that it will be useful,
12 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
13 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *   GNU General Public License for more details.
15 *
16 *   You should have received a copy of the GNU General Public License
17 *   along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef CHECKDIRTREE_H
21#define CHECKDIRTREE_H
22
23#include "DllMacro.h"
24
25#include <QFileSystemModel>
26#include <QTreeView>
27
28class DLLEXPORT CheckDirModel : public QFileSystemModel
29{
30    Q_OBJECT
31
32public:
33    CheckDirModel( QWidget* parent = 0 );
34    virtual ~CheckDirModel();
35
36    virtual Qt::ItemFlags flags( const QModelIndex& index ) const;
37    virtual QVariant data( const QModelIndex& index, int role = Qt::DisplayRole ) const;
38    virtual bool setData( const QModelIndex& index, const QVariant& value, int role = Qt::EditRole );
39
40    void setCheck( const QModelIndex& index, const QVariant& value );
41    Qt::CheckState getCheck( const QModelIndex& index );
42
43signals:
44    void dataChangedByUser( const QModelIndex & index );
45
46private slots:
47    void getFileInfoResult();
48    void volumeShowFinished();
49    void processErrorOutput();
50private:
51    QHash<QPersistentModelIndex, Qt::CheckState> m_checkTable;
52
53    bool m_shownVolumes;
54    QString m_setFilePath;
55    QString m_getFileInfoPath;
56};
57
58
59class DLLEXPORT CheckDirTree : public QTreeView
60{
61    Q_OBJECT
62
63public:
64    CheckDirTree( QWidget* parent );
65
66    void checkPath( const QString& path, Qt::CheckState state );
67
68    void setExclusions( const QStringList& list );
69    QStringList getExclusions();
70    QStringList getCheckedPaths();
71
72signals:
73    void changed();
74
75private slots:
76    void onCollapse( const QModelIndex& idx );
77    void onExpand( const QModelIndex& idx );
78    void updateNode( const QModelIndex& idx );
79
80    void modelReset();
81private:
82    CheckDirModel m_dirModel;
83    QSet<qint64> m_expandedSet;
84
85    void fillDown( const QModelIndex& index );
86    void updateParent( const QModelIndex& index );
87    void getExclusionsForNode( const QModelIndex& index, QStringList& exclusions );
88    void getChecksForNode( const QModelIndex& index, QStringList& checks );
89};
90
91#endif // CHECKDIRTREE_H