~ubuntu-branches/ubuntu/trusty/tomahawk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/libtomahawk/widgets/CheckDirTree.h

  • Committer: Package Import Robot
  • Author(s): Harald Sitter
  • Date: 2013-03-07 21:50:13 UTC
  • Revision ID: package-import@ubuntu.com-20130307215013-6gdjkdds7i9uenvs
Tags: upstream-0.6.0+dfsg
ImportĀ upstreamĀ versionĀ 0.6.0+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
28
class DLLEXPORT CheckDirModel : public QFileSystemModel
 
29
{
 
30
    Q_OBJECT
 
31
 
 
32
public:
 
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
 
 
43
    void cleanup();
 
44
signals:
 
45
    void dataChangedByUser( const QModelIndex & index );
 
46
 
 
47
private slots:
 
48
    void getFileInfoResult();
 
49
    void volumeShowFinished();
 
50
    void processErrorOutput();
 
51
private:
 
52
    QHash<QPersistentModelIndex, Qt::CheckState> m_checkTable;
 
53
 
 
54
    bool m_shownVolumes;
 
55
    QString m_setFilePath;
 
56
    QString m_getFileInfoPath;
 
57
};
 
58
 
 
59
 
 
60
class DLLEXPORT CheckDirTree : public QTreeView
 
61
{
 
62
    Q_OBJECT
 
63
 
 
64
public:
 
65
    CheckDirTree( QWidget* parent );
 
66
 
 
67
    void checkPath( const QString& path, Qt::CheckState state );
 
68
 
 
69
    void setExclusions( const QStringList& list );
 
70
    QStringList getExclusions();
 
71
    QStringList getCheckedPaths();
 
72
 
 
73
    void cleanup();
 
74
signals:
 
75
    void changed();
 
76
 
 
77
private slots:
 
78
    void onCollapse( const QModelIndex& idx );
 
79
    void onExpand( const QModelIndex& idx );
 
80
    void updateNode( const QModelIndex& idx );
 
81
 
 
82
    void modelReset();
 
83
private:
 
84
    CheckDirModel m_dirModel;
 
85
    QSet<qint64> m_expandedSet;
 
86
 
 
87
    void fillDown( const QModelIndex& index );
 
88
    void updateParent( const QModelIndex& index );
 
89
    void getExclusionsForNode( const QModelIndex& index, QStringList& exclusions );
 
90
    void getChecksForNode( const QModelIndex& index, QStringList& checks );
 
91
};
 
92
 
 
93
#endif // CHECKDIRTREE_H