File indexing completed on 2025-01-19 12:59:16
0001 /* This file is part of the KDE project 0002 Copyright (C) 2000 David Faure <faure@kde.org> 0003 2000 Carsten Pfeiffer <pfeiffer@kde.org> 0004 0005 This library is free software; you can redistribute it and/or 0006 modify it under the terms of the GNU Library General Public 0007 License version 2 as published by the Free Software Foundation. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef FILETREEVIEWITEM_H 0021 #define FILETREEVIEWITEM_H 0022 0023 #include <qtreewidget.h> 0024 0025 #include <kfileitem.h> 0026 #include <kcoredirlister.h> 0027 0028 #include <kio/global.h> 0029 #include <kio/job.h> 0030 0031 class QUrl; 0032 0033 class FileTreeView; 0034 class FileTreeBranch; 0035 0036 /** 0037 * An item for a FileTreeView that knows about its own KFileItem. 0038 */ 0039 class FileTreeViewItem : public QTreeWidgetItem 0040 { 0041 public: 0042 FileTreeViewItem(FileTreeViewItem *parent, const KFileItem &fi, FileTreeBranch *branch); 0043 FileTreeViewItem(FileTreeView *parent, const KFileItem &fi, FileTreeBranch *branch); 0044 ~FileTreeViewItem() = default; 0045 0046 /** 0047 * @return the KFileTreeBranch the item is sorted in. 0048 */ 0049 FileTreeBranch *branch() const 0050 { 0051 return (m_branch); 0052 } 0053 0054 /** 0055 * @return the KFileItem the viewitem is representing. 0056 * A copy of the original (provided by the KDirLister), so there is not 0057 * much point in trying to modify it. 0058 */ 0059 const KFileItem *fileItem() const 0060 { 0061 return (&m_kfileitem); 0062 } 0063 0064 /** 0065 * @return the path of the item 0066 */ 0067 // TODO: is this simply equivalent to 'url().path()'? 0068 QString path() const; 0069 0070 /** 0071 * @return the item's URL 0072 */ 0073 QUrl url() const; 0074 void setUrl(const QUrl &url); 0075 0076 /** 0077 * @return if the item represents a directory 0078 */ 0079 bool isDir() const; 0080 0081 /** 0082 * @return if the item represents the root of its branch 0083 */ 0084 bool isRoot() const; 0085 0086 /** 0087 * @return if this directory has already been seen by a KDirLister 0088 */ 0089 bool alreadyListed() const; 0090 0091 /** 0092 * set the flag to indicate if the directory has already been listed 0093 */ 0094 void setListed(bool wasListed); 0095 0096 private: 0097 void init(const KFileItem &fi, FileTreeBranch *branch); 0098 0099 KFileItem m_kfileitem; 0100 FileTreeBranch *m_branch; 0101 bool m_wasListed; 0102 }; 0103 0104 /** 0105 * List of KFileTreeViewItems 0106 */ 0107 typedef QList<FileTreeViewItem *> FileTreeViewItemList; 0108 0109 #endif // FILETREEVIEWITEM_H