Wt examples  3.3.8
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
FileTreeTableNode Class Reference

A single node in a file tree table. More...

#include <FileTreeTableNode.h>

Inheritance diagram for FileTreeTableNode:
Inheritance graph
[legend]

Public Member Functions

 FileTreeTableNode (const boost::filesystem::path &path)
 Construct a new node for the given file. More...
 
- Public Member Functions inherited from Wt::WTreeTableNode
 WTreeTableNode (const WString &labelText, WIconPair *labelIcon=0, WTreeTableNode *parentNode=0)
 
void setColumnWidget (int column, WWidget *item)
 
WWidgetcolumnWidget (int column)
 
WTreeTabletable () const
 
virtual void insertChildNode (int index, WTreeNode *node)
 
- Public Member Functions inherited from Wt::WTreeNode
 WTreeNode (const WString &labelText, WIconPair *labelIcon=0, WTreeNode *parentNode=0)
 
 ~WTreeNode ()
 
virtual WTreetree () const
 
WTextlabel () const
 
WIconPairlabelIcon () const
 
void setLabelIcon (WIconPair *labelIcon)
 
void addChildNode (WTreeNode *node)
 
void removeChildNode (WTreeNode *node)
 
const std::vector< WTreeNode * > & childNodes () const
 
virtual int displayedChildCount () const
 
void setChildCountPolicy (ChildCountPolicy policy)
 
ChildCountPolicy childCountPolicy () const
 
void setImagePack (const std::string &url)
 
void setLoadPolicy (LoadPolicy loadPolicy)
 
bool isExpanded () const
 
void setSelectable (bool selectable)
 
virtual bool isSelectable () const
 
WTreeNodeparentNode () const
 
void setNodeVisible (bool visible)
 
void setChildrenDecorated (bool decorated)
 
void setInteractive (bool interactive)
 
void expand ()
 
void collapse ()
 
EventSignal< WMouseEvent > & expanded ()
 
EventSignal< WMouseEvent > & collapsed ()
 
Signal< bool > & selected ()
 
- Public Member Functions inherited from Wt::WCompositeWidget
 WCompositeWidget (WContainerWidget *parent=0)
 
 WCompositeWidget (WWidget *implementation, WContainerWidget *parent)
 
virtual void setObjectName (const std::string &name)
 
virtual std::string objectName () const
 
virtual const std::string id () const
 
virtual void setPositionScheme (PositionScheme scheme)
 
virtual PositionScheme positionScheme () const
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)
 
virtual WLength offset (Side s) const
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const
 
virtual WLength height () const
 
virtual void setMinimumSize (const WLength &width, const WLength &height)
 
virtual WLength minimumWidth () const
 
virtual WLength minimumHeight () const
 
virtual void setMaximumSize (const WLength &width, const WLength &height)
 
virtual WLength maximumWidth () const
 
virtual WLength maximumHeight () const
 
virtual void setLineHeight (const WLength &height)
 
virtual WLength lineHeight () const
 
virtual void setFloatSide (Side s)
 
virtual Side floatSide () const
 
virtual void setClearSides (WFlags< Side > sides)
 
virtual WFlags< SideclearSides () const
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)
 
virtual WLength margin (Side side) const
 
virtual void setHiddenKeepsGeometry (bool enabled)
 
virtual bool hiddenKeepsGeometry () const
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())
 
virtual bool isHidden () const
 
virtual bool isVisible () const
 
virtual void setDisabled (bool disabled)
 
virtual bool isDisabled () const
 
virtual bool isEnabled () const
 
virtual void setPopup (bool popup)
 
virtual bool isPopup () const
 
virtual void setInline (bool isInline)
 
virtual bool isInline () const
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)
 
virtual WCssDecorationStyledecorationStyle ()
 
virtual void setStyleClass (const WString &styleClass)
 
virtual WString styleClass () const
 
virtual void addStyleClass (const WString &styleClass, bool force=false)
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)
 
virtual bool hasStyleClass (const WString &styleClass) const
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)
 
virtual AlignmentFlag verticalAlignment () const
 
virtual WLength verticalAlignmentLength () const
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)
 
virtual WString toolTip () const
 
virtual void setDeferredToolTip (bool enable, TextFormat textFormat=PlainText)
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)
 
virtual WString attributeValue (const std::string &name) const
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)
 
virtual std::string javaScriptMember (const std::string &name) const
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)
 
virtual void load ()
 
virtual bool loaded () const
 
virtual void setCanReceiveFocus (bool enabled)
 
virtual bool canReceiveFocus () const
 
virtual void setFocus (bool focus)
 
virtual bool setFirstFocus ()
 
virtual bool hasFocus () const
 
virtual void setTabIndex (int index)
 
virtual int tabIndex () const
 
virtual void setId (const std::string &id)
 
virtual WWidgetfind (const std::string &name)
 
virtual WWidgetfindById (const std::string &name)
 
virtual void doJavaScript (const std::string &js)
 
virtual void propagateSetEnabled (bool enabled)
 
virtual bool scrollVisibilityEnabled () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityEnabled (bool enabled) WT_CXX11ONLY(finaloverride)
 
virtual int scrollVisibilityMargin () const WT_CXX11ONLY(finaloverride)
 
virtual void setScrollVisibilityMargin (int margin) WT_CXX11ONLY(finaloverride)
 
virtual Signal< bool > & scrollVisibilityChanged () WT_CXX11ONLY(finaloverride)
 
virtual bool isScrollVisible () const WT_CXX11ONLY(finaloverride)
 
virtual void setThemeStyleEnabled (bool enabled)
 
virtual bool isThemeStyleEnabled () const
 
- Public Member Functions inherited from Wt::WWidget
virtual ~WWidget ()
 
WWidgetparent () const
 
virtual void removeChild (WObject *child)
 
void setWidth (const WLength &width)
 
void setHeight (const WLength &height)
 
virtual void positionAt (const WWidget *widget, Orientation orientation=Vertical)
 
virtual void toggleStyleClass (const WString &styleClass, bool add, bool force=false)
 
std::string jsRef () const
 
void setFocus ()
 
virtual void acceptDrops (const std::string &mimeType, const WString &hoverStyleClass=WString())
 
virtual void stopAcceptDrops (const std::string &mimeType)
 
virtual void htmlText (std::ostream &out)
 
bool isRendered () const
 
void hide ()
 
void animateHide (const WAnimation &animation)
 
void show ()
 
void animateShow (const WAnimation &animation)
 
void enable ()
 
void disable ()
 
bool layoutSizeAware () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Private Member Functions

virtual void populate ()
 Reimplements WTreeNode::populate to read files within a directory. More...
 
virtual bool expandable ()
 Reimplements WTreeNode::expandable. More...
 

Static Private Member Functions

static Wt::WIconPaircreateIcon (const boost::filesystem::path &path)
 Create the iconpair for representing the path. More...
 

Private Attributes

boost::filesystem::path path_
 The path. More...
 

Additional Inherited Members

- Public Types inherited from Wt::WTreeNode
enum  LoadPolicy
 
enum  ChildCountPolicy
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WWidget
static WString tr (const char *key)
 
- Public Attributes inherited from Wt::WTreeNode
 LazyLoading
 
 PreLoading
 
 NextLevelLoading
 
 Disabled
 
 Enabled
 
 Lazy
 
- Protected Member Functions inherited from Wt::WTreeTableNode
virtual void setTable (WTreeTable *table)
 
- Protected Member Functions inherited from Wt::WTreeNode
 WTreeNode (WTreeNode *parentNode=0)
 
WContainerWidgetlabelArea ()
 
bool populated () const
 
virtual void renderSelected (bool selected)
 
std::string imagePack () const
 
virtual void descendantRemoved (WTreeNode *node)
 
virtual void descendantAdded (WTreeNode *node)
 
virtual void doExpand ()
 
virtual void doCollapse ()
 
virtual void undoDoExpand ()
 
virtual void undoDoCollapse ()
 
WIconPairexpandIcon () const
 
- Protected Member Functions inherited from Wt::WCompositeWidget
virtual void enableAjax ()
 
void setImplementation (WWidget *widget)
 
WWidgetimplementation ()
 
virtual int boxPadding (Orientation orientation) const
 
virtual int boxBorder (Orientation orientation) const
 
virtual void render (WFlags< RenderFlag > flags)
 
- Protected Member Functions inherited from Wt::WWidget
void setLayoutSizeAware (bool sizeAware)
 
virtual void layoutSizeChanged (int width, int height)
 
 WWidget (WContainerWidget *parent=0)
 
virtual void dropEvent (WDropEvent dropEvent)
 
void scheduleRender (WFlags< RepaintFlag > flags=0)
 
virtual WStatelessSlot * getStateless (Method method)
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

Detailed Description

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.

Constructor & Destructor Documentation

FileTreeTableNode::FileTreeTableNode ( const boost::filesystem::path &  path)

Construct a new node for the given file.

Definition at line 22 of file FileTreeTableNode.C.

25  : WTreeTableNode(Wt::widen(path.leaf()), createIcon(path)),
26 #else
27  : WTreeTableNode(path.leaf(), createIcon(path)),
28 #endif
29 #else
30  : WTreeTableNode(path.leaf().string(), createIcon(path)),
31 #endif
32  path_(path)
33 {
34  label()->setTextFormat(PlainText);
35 
36  if (boost::filesystem::exists(path)) {
37  if (!boost::filesystem::is_directory(path)) {
38  int fsize = (int)boost::filesystem::file_size(path);
39  setColumnWidget(1, new WText(boost::lexical_cast<std::string>(fsize)));
40  columnWidget(1)->setStyleClass("fsize");
41  } else
42  setSelectable(false);
43 
44  std::time_t t = boost::filesystem::last_write_time(path);
45  struct tm ttm;
46 #if WIN32
47  ttm=*localtime(&t);
48 #else
49  localtime_r(&t, &ttm);
50 #endif
51 
52  char c[100];
53  strftime(c, 100, "%b %d %Y", &ttm);
54 
55  setColumnWidget(2, new WText(c));
56  columnWidget(2)->setStyleClass("date");
57  }
58 }
static Wt::WIconPair * createIcon(const boost::filesystem::path &path)
Create the iconpair for representing the path.
WText * label() const
WTreeTableNode(const WString &labelText, WIconPair *labelIcon=0, WTreeTableNode *parentNode=0)
void setColumnWidget(int column, WWidget *item)
bool setTextFormat(TextFormat format)
void setSelectable(bool selectable)
boost::filesystem::path path_
The path.
WWidget * columnWidget(int column)
virtual void setStyleClass(const WString &styleClass)=0

Member Function Documentation

WIconPair * FileTreeTableNode::createIcon ( const boost::filesystem::path &  path)
staticprivate

Create the iconpair for representing the path.

Definition at line 60 of file FileTreeTableNode.C.

61 {
62  if (boost::filesystem::exists(path)
63  && boost::filesystem::is_directory(path))
64  return new WIconPair("icons/yellow-folder-closed.png",
65  "icons/yellow-folder-open.png", false);
66  else
67  return new WIconPair("icons/document.png",
68  "icons/yellow-folder-open.png", false);
69 }
bool FileTreeTableNode::expandable ( )
privatevirtual

Reimplements WTreeNode::expandable.

Reimplemented from Wt::WTreeNode.

Definition at line 94 of file FileTreeTableNode.C.

95 {
96  if (!populated()) {
97  return boost::filesystem::is_directory(path_);
98  } else
99  return WTreeTableNode::expandable();
100 }
bool populated() const
boost::filesystem::path path_
The path.
void FileTreeTableNode::populate ( )
privatevirtual

Reimplements WTreeNode::populate to read files within a directory.

Reimplemented from Wt::WTreeNode.

Definition at line 71 of file FileTreeTableNode.C.

72 {
73  if (boost::filesystem::is_directory(path_)) {
74  std::set<boost::filesystem::path> paths;
75  boost::filesystem::directory_iterator end_itr;
76 
77  for (boost::filesystem::directory_iterator i(path_); i != end_itr; ++i)
78  try {
79  paths.insert(*i);
80  } catch (boost::filesystem::filesystem_error& e) {
81  std::cerr << e.what() << std::endl;
82  }
83 
84  for (std::set<boost::filesystem::path>::iterator i = paths.begin();
85  i != paths.end(); ++i)
86  try {
88  } catch (boost::filesystem::filesystem_error& e) {
89  std::cerr << e.what() << std::endl;
90  }
91  }
92 }
boost::filesystem::path path_
The path.
void addChildNode(WTreeNode *node)
FileTreeTableNode(const boost::filesystem::path &path)
Construct a new node for the given file.

Member Data Documentation

boost::filesystem::path FileTreeTableNode::path_
private

The path.

Definition at line 37 of file FileTreeTableNode.h.


The documentation for this class was generated from the following files:

Generated on Mon Sep 4 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.11