|
Wt examples
3.3.0
|
A single node in a file tree table. More...
#include <FileTreeTableNode.h>

Public Member Functions | |
| FileTreeTableNode (const boost::filesystem::path &path) | |
| Construct a new node for the given file. | |
Private Member Functions | |
| virtual void | populate () |
| Reimplements WTreeNode::populate to read files within a directory. | |
| virtual bool | expandable () |
| Reimplements WTreeNode::expandable. | |
Static Private Member Functions | |
| static Wt::WIconPair * | createIcon (const boost::filesystem::path &path) |
| Create the iconpair for representing the path. | |
Private Attributes | |
| boost::filesystem::path | path_ |
| The path. | |
A single node in a file tree table.
The node manages the details about one file, and if the file is a directory, populates a subtree with nodes for every directory item.
The tree node reimplements Wt::WTreeTableNode::populate() to populate a directory node only when the node is expanded. In this way, only directories that are actually browsed are loaded from disk.
Definition at line 28 of file FileTreeTableNode.h.
| FileTreeTableNode::FileTreeTableNode | ( | const boost::filesystem::path & | path | ) |
Construct a new node for the given file.
Definition at line 22 of file FileTreeTableNode.C.
: WTreeTableNode(Wt::widen(path.leaf()), createIcon(path)), #else : WTreeTableNode(path.leaf(), createIcon(path)), #endif #else : WTreeTableNode(path.leaf().string(), createIcon(path)), #endif path_(path) { label()->setTextFormat(PlainText); if (boost::filesystem::exists(path)) { if (!boost::filesystem::is_directory(path)) { int fsize = (int)boost::filesystem::file_size(path); setColumnWidget(1, new WText(boost::lexical_cast<std::string>(fsize))); columnWidget(1)->setStyleClass("fsize"); } else setSelectable(false); std::time_t t = boost::filesystem::last_write_time(path); struct tm ttm; #if WIN32 ttm=*localtime(&t); #else localtime_r(&t, &ttm); #endif char c[100]; strftime(c, 100, "%b %d %Y", &ttm); setColumnWidget(2, new WText(c)); columnWidget(2)->setStyleClass("date"); } }
| WIconPair * FileTreeTableNode::createIcon | ( | const boost::filesystem::path & | path | ) | [static, private] |
Create the iconpair for representing the path.
Definition at line 60 of file FileTreeTableNode.C.
| bool FileTreeTableNode::expandable | ( | ) | [private, virtual] |
Reimplements WTreeNode::expandable.
Reimplemented from Wt::WTreeNode.
Definition at line 90 of file FileTreeTableNode.C.
{
if (!populated()) {
return boost::filesystem::is_directory(path_);
} else
return WTreeTableNode::expandable();
}
| void FileTreeTableNode::populate | ( | ) | [private, virtual] |
Reimplements WTreeNode::populate to read files within a directory.
Reimplemented from Wt::WTreeNode.
Definition at line 71 of file FileTreeTableNode.C.
{
try {
if (boost::filesystem::is_directory(path_)) {
std::set<boost::filesystem::path> paths;
boost::filesystem::directory_iterator end_itr;
for (boost::filesystem::directory_iterator i(path_); i != end_itr; ++i)
paths.insert(*i);
for (std::set<boost::filesystem::path>::iterator i = paths.begin();
i != paths.end(); ++i)
addChildNode(new FileTreeTableNode(*i));
}
} catch (boost::filesystem::filesystem_error& e) {
std::cerr << e.what() << std::endl;
}
}
boost::filesystem::path FileTreeTableNode::path_ [private] |
The path.
Definition at line 37 of file FileTreeTableNode.h.
1.7.5.1