~ubuntu-branches/ubuntu/quantal/kde-runtime/quantal

« back to all changes in this revision

Viewing changes to nepomuk/services/backupsync/gui/filesystemtree.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-06-03 21:50:00 UTC
  • mto: This revision was merged to the branch mainline in revision 21.
  • Revision ID: package-import@ubuntu.com-20120603215000-vn7oarsq0ynrydj5
Tags: upstream-4.8.80
Import upstream version 4.8.80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
    This file is part of the Nepomuk KDE project.
3
 
    Copyright (C) 2010  Vishesh Handa <handa.vish@gmail.com>
4
 
    
5
 
    This library is free software; you can redistribute it and/or
6
 
    modify it under the terms of the GNU Lesser General Public
7
 
    License as published by the Free Software Foundation; either
8
 
    version 2.1 of the License, or (at your option) version 3, or any
9
 
    later version accepted by the membership of KDE e.V. (or its
10
 
    successor approved by the membership of KDE e.V.), which shall
11
 
    act as a proxy defined in Section 6 of version 3 of the license.
12
 
    
13
 
    This library is distributed in the hope that it will be useful,
14
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 
    Lesser General Public License for more details.
17
 
    
18
 
    You should have received a copy of the GNU Lesser General Public
19
 
    License along with this library.  If not, see <http://www.gnu.org/licenses/>.
20
 
*/
21
 
 
22
 
 
23
 
#ifndef FILESYSTEMTREE_H
24
 
#define FILESYSTEMTREE_H
25
 
 
26
 
#include <QtCore/QString>
27
 
#include <QtCore/QUrl>
28
 
#include <KDebug>
29
 
 
30
 
class FileSystemTreeItem;
31
 
 
32
 
class FileSystemTree
33
 
{
34
 
public :
35
 
    FileSystemTree();
36
 
    virtual ~FileSystemTree();
37
 
    
38
 
    virtual void add( FileSystemTreeItem * item );
39
 
    virtual void remove( const QString& url );
40
 
    virtual void remove( FileSystemTreeItem * item );
41
 
    
42
 
    FileSystemTreeItem * find( const QString & url );
43
 
    
44
 
    QList<FileSystemTreeItem*> rootNodes() const;
45
 
    
46
 
    QList<QString> toList() const;
47
 
 
48
 
    bool isEmpty() const;
49
 
    int size() const;
50
 
    
51
 
private :
52
 
    friend class FileSystemTreeItem;
53
 
 
54
 
    QList<FileSystemTreeItem *> m_rootNodes;
55
 
};
56
 
 
57
 
 
58
 
class FileSystemTreeItem {
59
 
    
60
 
public:
61
 
    FileSystemTreeItem();
62
 
    FileSystemTreeItem( const QString & url );
63
 
    FileSystemTreeItem( const QString & url, bool folder );
64
 
 
65
 
    virtual ~FileSystemTreeItem();
66
 
 
67
 
    void add( FileSystemTreeItem * item );
68
 
 
69
 
    FileSystemTreeItem* find( const QString& url );
70
 
    
71
 
    QList<FileSystemTreeItem*> children() const;
72
 
    FileSystemTreeItem* child(int row) const;
73
 
    int numChildren() const;
74
 
    
75
 
    /**
76
 
     * Returns the row number of the current TreeItem in it's parents children list.
77
 
     * Returns -1 if it doesn't have a parent
78
 
     */
79
 
    int parentRowNum();
80
 
    
81
 
    FileSystemTreeItem * parent() const;
82
 
    QString url() const;
83
 
   
84
 
    QList< QString > toList() const;
85
 
 
86
 
    /// Returns the number of nodes in this tree
87
 
    int size() const;
88
 
    
89
 
    bool isNull() const;
90
 
    bool isFile() const;
91
 
    bool isFolder() const;
92
 
private :
93
 
    
94
 
    QList<FileSystemTreeItem *> m_children;
95
 
    FileSystemTreeItem * m_parent;
96
 
    bool m_isFolder;
97
 
    
98
 
    QString m_url;
99
 
    
100
 
    friend class FileSystemTree;
101
 
 
102
 
    int depth();
103
 
    bool shouldBeParentOf( FileSystemTreeItem * item );
104
 
 
105
 
    static void insert(QList<FileSystemTreeItem*>& list,
106
 
                       FileSystemTreeItem* item, FileSystemTreeItem * parent );
107
 
    static FileSystemTreeItem* find( QList<FileSystemTreeItem*>& list, const QString & url );
108
 
};
109
 
 
110
 
 
111
 
 
112
 
 
113
 
#endif // FILESYSTEMTREE_H