diff options
| author | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
|---|---|---|
| committer | hibby <d@vehibberd.com> | 2018-02-16 15:17:14 +0000 |
| commit | 37f727ac0746fd85504aa46c1f023c09b3eff33a (patch) | |
| tree | c8a7ce04545040a8f161ba279528730bd9a3e6ab /SampleDownloader/DirectoryNode.hpp | |
| parent | d63dd8d081a6fcd0715cd13f26df59fb831769d2 (diff) | |
New upstream version 1.8.0+repackupstream/1.8.0+repack
Diffstat (limited to 'SampleDownloader/DirectoryNode.hpp')
| -rw-r--r-- | SampleDownloader/DirectoryNode.hpp | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/SampleDownloader/DirectoryNode.hpp b/SampleDownloader/DirectoryNode.hpp new file mode 100644 index 00000000..2de16eac --- /dev/null +++ b/SampleDownloader/DirectoryNode.hpp @@ -0,0 +1,51 @@ +#ifndef DIRECTORY_NODE_HPP__ +#define DIRECTORY_NODE_HPP__ + +#include <QTreeWidgetItem> +#include <QString> + +// +// Tree widget item representing a file system directory. +// +// It renders the directory name in the first column and progress +// information in the 2nd column. The progress information consists of +// two 64 bit integer values, the 1st in the DisplayRole is the number +// of bytes received and the 2nd in the UserRole the total bytes +// expected. The progress information is not automatically +// maintained, see the Directory class for an example of how to +// dynamically maintain the DirectoryNode progress values. The 1st +// column also renders a tristate check box that controls the first +// column check boxes of child items. +// +class DirectoryNode final + : public QTreeWidgetItem +{ +public: + explicit DirectoryNode (QTreeWidgetItem * parent, QString const& name) + : QTreeWidgetItem {parent, Type} + { + setFlags (flags () | Qt::ItemIsUserCheckable | Qt::ItemIsTristate); + setText (0, name); + setCheckState (0, Qt::Unchecked); + + // initialize as empty, the owning QTreeWidget must maintain these + // progress values + setData (1, Qt::DisplayRole, 0ll); // progress in bytes + setData (1, Qt::UserRole, 0ll); // expected bytes + } + + bool operator == (QString const& name) const + { + return name == text (0); + } + + static int constexpr Type {UserType}; +}; + +inline +bool operator == (QString const& lhs, DirectoryNode const& rhs) +{ + return rhs == lhs; +} + +#endif |
