2
This file is part of the Nepomuk KDE project.
3
Copyright (C) 2010 Vishesh Handa <handa.vish@gmail.com>
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.
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.
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/>.
23
#ifndef FILESYSTEMTREE_H
24
#define FILESYSTEMTREE_H
26
#include <QtCore/QString>
27
#include <QtCore/QUrl>
30
class FileSystemTreeItem;
36
virtual ~FileSystemTree();
38
virtual void add( FileSystemTreeItem * item );
39
virtual void remove( const QString& url );
40
virtual void remove( FileSystemTreeItem * item );
42
FileSystemTreeItem * find( const QString & url );
44
QList<FileSystemTreeItem*> rootNodes() const;
46
QList<QString> toList() const;
52
friend class FileSystemTreeItem;
54
QList<FileSystemTreeItem *> m_rootNodes;
58
class FileSystemTreeItem {
62
FileSystemTreeItem( const QString & url );
63
FileSystemTreeItem( const QString & url, bool folder );
65
virtual ~FileSystemTreeItem();
67
void add( FileSystemTreeItem * item );
69
FileSystemTreeItem* find( const QString& url );
71
QList<FileSystemTreeItem*> children() const;
72
FileSystemTreeItem* child(int row) const;
73
int numChildren() const;
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
81
FileSystemTreeItem * parent() const;
84
QList< QString > toList() const;
86
/// Returns the number of nodes in this tree
91
bool isFolder() const;
94
QList<FileSystemTreeItem *> m_children;
95
FileSystemTreeItem * m_parent;
100
friend class FileSystemTree;
103
bool shouldBeParentOf( FileSystemTreeItem * item );
105
static void insert(QList<FileSystemTreeItem*>& list,
106
FileSystemTreeItem* item, FileSystemTreeItem * parent );
107
static FileSystemTreeItem* find( QList<FileSystemTreeItem*>& list, const QString & url );
113
#endif // FILESYSTEMTREE_H