summaryrefslogtreecommitdiffstats
path: root/libktorrent/interfaces/filetreediritem.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-01-20 02:37:40 +0000
commit9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0 (patch)
treed088b5210e77d9fa91d954d8550e00e372b47378 /libktorrent/interfaces/filetreediritem.h
downloadktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.tar.gz
ktorrent-9ad5c7b5e23b4940e7a3ea3ca3a6fb77e6a8fab0.zip
Updated to final KDE3 ktorrent release (2.2.6)
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktorrent@1077377 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'libktorrent/interfaces/filetreediritem.h')
-rw-r--r--libktorrent/interfaces/filetreediritem.h140
1 files changed, 140 insertions, 0 deletions
diff --git a/libktorrent/interfaces/filetreediritem.h b/libktorrent/interfaces/filetreediritem.h
new file mode 100644
index 0000000..00650f2
--- /dev/null
+++ b/libktorrent/interfaces/filetreediritem.h
@@ -0,0 +1,140 @@
+/***************************************************************************
+ * Copyright (C) 2005 by Joris Guisson *
+ * joris.guisson@gmail.com *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+#ifndef KTFILETREEDIRITEM_H
+#define KTFILETREEDIRITEM_H
+
+#include <klistview.h>
+#include <util/constants.h>
+#include <util/ptrmap.h>
+
+namespace kt
+{
+ using namespace bt;
+
+ class FileTreeItem;
+ class TorrentFileInterface;
+ class TorrentInterface;
+
+ class FileTreeRootListener
+ {
+ public:
+ /// An item in the file tree has changed his state
+ virtual void treeItemChanged() = 0;
+ };
+
+ /**
+ * @author Joris Guisson
+ *
+ * Directory item the file tree showing the files in a multifile torrent
+ */
+ class FileTreeDirItem : public QCheckListItem
+ {
+ protected:
+ QString name;
+ Uint64 size;
+ bt::PtrMap<QString,FileTreeItem> children;
+ bt::PtrMap<QString,FileTreeDirItem> subdirs;
+ FileTreeDirItem* parent;
+ bool manual_change;
+ FileTreeRootListener* root_listener;
+ public:
+ FileTreeDirItem(KListView* klv,const QString & name,FileTreeRootListener* rl = 0);
+ FileTreeDirItem(FileTreeDirItem* parent,const QString & name);
+ virtual ~FileTreeDirItem();
+
+ /// Get the path of the directory (if this is the root directory / will be returned)
+ QString getPath() const;
+
+ /**
+ * Recursively insert a TorrentFileInterface.
+ * @param path Path of file
+ * @param file File itself
+ */
+ void insert(const QString & path,kt::TorrentFileInterface & file);
+
+ /**
+ * Recursivly walk the tree to find the TorrentFile which
+ * is shown by a QListViewItem (which should be an FileTreeItem).
+ * If item can't be found or item is an FileTreeDirItem, a reference to
+ * TorrentFile::null will be returned. In which case the isNull() function
+ * of TorrentFile will return true
+ * @param item Pointer to the QListViewItem
+ * @return A reference to the TorrentFile
+ */
+ kt::TorrentFileInterface & findTorrentFile(QListViewItem* item);
+
+ /**
+ * Set all items checked or not.
+ * @param on true everything checked, false everything not checked
+ * @param keep_data In case of unchecking keep the data or not
+ */
+ void setAllChecked(bool on,bool keep_data = false);
+
+ /**
+ * Invert all items, checked items become unchecked and unchecked become checked.
+ */
+ void invertChecked();
+
+ /**
+ * Called by the child to notify the parent it's state has changed.
+ */
+ void childStateChange();
+
+ FileTreeDirItem* getParent() {return parent;}
+
+ /// Recusively get the total number of bytes to download
+ Uint64 bytesToDownload() const;
+
+ protected:
+ /**
+ * Can be overrided by subclasses, so they can use their own
+ * custom FileTreeItem's. Will be called in insert.
+ * @param name Name of the file
+ * @param file The TorrentFileInterface
+ * @return A newly created FileTreeItem
+ */
+ virtual FileTreeItem* newFileTreeItem(const QString & name,
+ TorrentFileInterface & file);
+
+
+ /**
+ * Can be overrided by subclasses, so they can use their own
+ * custom FileTreeDirItem's. Will be called in insert.
+ * @param subdir The name of the subdir
+ * @return A newly created FileTreeDirItem
+ */
+ virtual FileTreeDirItem* newFileTreeDirItem(const QString & subdir);
+
+
+ /**
+ * Subclasses should override this if they want to show a confirmation dialog.
+ * @return What to do (i.e. keep the data, get rid of it or do nothing
+ */
+ virtual bt::ConfirmationResult confirmationDialog();
+
+ private:
+ virtual void stateChange(bool on);
+ virtual int compare(QListViewItem* i, int col, bool ascending) const;
+ bool allChildrenOn();
+ };
+
+}
+
+#endif