Wittyshare  0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WsSiteMapView.h
Go to the documentation of this file.
1 #ifndef __WsSiteMapView__
2 #define __WsSiteMapView__
3 
4 #include <Wt/WContainerWidget>
5 #include <Wt/WStandardItemModel>
6 #include <Wt/WStandardItem>
7 #include <Wt/WTreeView>
8 #include <Wt/WMenu>
9 #include <Wt/WMessageBox>
10 
11 #include "gdwtcore/gdToolbar.h"
12 #include "gdwtcore/gdWFileView.h"
13 
14 #include <User/WsUser.h>
15 #include <Main/WsOption.h>
16 //#include <WsModule/WsModule.h>
17 
18 class WsSiteMapItem : public Wt::WStandardItem {
19 public :
20  WsSiteMapItem();
21  WsSiteMapItem(const Wt::WString& text);
22  void setNode(NodePtr pNode);
23  NodePtr node();
24 
25 private :
27 };
28 
29 
30 
31 
32 
33 
34 class WsTreeView : public Wt::WTreeView {
35 public :
36  WsTreeView();
37  void layoutSizeChanged(int width, int height);
38 };
39 
40 
41 
42 
43 
44 
45 
46 
47 class WsSiteMapView : public Wt::WContainerWidget, public WsOptions {
48 public:
49  WsSiteMapView(gdwtcore::viewType dlgType, gdWFileView::tbFlags flags = gdWFileView::tbDefault, Wt::WContainerWidget* parent = 0);
51  virtual void load();
52 
53  std::string path2SiteMapPath(const std::string& path); // Replace /var/www/demo_site/index.html by /var/www/demo_site/SiteMap/index.html
54  std::string SiteMapPath2path(const std::string& siteMapPath); // Replace /var/www/demo_site/SiteMap/index.html by /var/www/demo_site/index.html
55  void setRelativePath(const std::string& relativePath);
56  void init(NodePtr pNode);
57  bool treeTraverse(Wt::WStandardItem* rootItem, const std::vector<std::string>& vPath, int nLevel);
58  void treeMatchPath(NodePtr pNode);
59  bool loadTree(Wt::WStandardItem* currentItem, NodePtr pNode, gdWFileView::skipMode skipParentDir = gdWFileView::noSkipParent);
60  bool loadFolder(Wt::WStandardItem* currentItem, const std::string& newPath, NodePtr curNode, bool bEdit = false);
61  bool loadFile(Wt::WStandardItem* currentItem, const std::string& currentPath, NodePtr curNode);
62  void setCurrentPath(const std::string& currentPath);
63  std::string selectedDirectory();
64  std::string selectedFile();
65  std::string selectedPath();
66  std::string currentFolderPath();
67  void makeToolbar();
68 
69 public :
70  Wt::Signal<gdWFileView::signalType, std::string>& fileSelected() {
71  return fileSelected_;
72  };
73 
74 private :
75  Wt::Signal<gdWFileView::signalType, std::string> fileSelected_;
76 
77 public slots:
78  void onViewDblClick(Wt::WModelIndex idx, Wt::WMouseEvent mouseEvent);
80  void onTreeExpanded(Wt::WModelIndex idx);
82  void onViewExpanded(Wt::WModelIndex idx);
83  void doRename();
84  void doConfirmDelete();
85  void doDelete(Wt::StandardButton button);
86  void doNewFolder();
87  void onDirectoryNameChanged(Wt::WStandardItem* pItem);
88 
89 private:
90  gdwtcore::viewType m_viewType;
91  gdWFileView::tbFlags m_tbFlags;
92  Wt::WStandardItemModel* m_pModelTree;
93  Wt::WStandardItemModel* m_pModelView;
94  Wt::WTreeView* m_pTVTree;
95  Wt::WTreeView* m_pTVView;
96  gdToolbar* m_pTb;
98 
100  Wt::WMenu* m_pMenu;
103  gdToolbarItem* m_tbiDelete;
104  gdToolbarItem* m_tbiNewFolder;
105  gdToolbarItem* m_tbiRename;
106  std::string m_selectedFile;
107  std::string m_selectedDirectory;
108  std::string m_sRootPath; // /var/www/demo_site
109  std::string m_sSiteMap; // /SiteMap
110  std::string m_sRootSiteMap; // /var/www/demo_site/SiteMap
111  Wt::WMessageBox* m_pMb;
113 };
114 
115 #endif // __WsSiteMapView__
116 
bool m_bOnTreeSelect
Definition: WsSiteMapView.h:97
void onViewSelectionChanged()
void onViewDblClick(Wt::WModelIndex idx, Wt::WMouseEvent mouseEvent)
std::string m_selectedFile
NodePtr node()
void setCurrentPath(const std::string &currentPath)
boost::shared_ptr< WsAbstractNode > NodePtr
bool treeTraverse(Wt::WStandardItem *rootItem, const std::vector< std::string > &vPath, int nLevel)
void onViewExpanded(Wt::WModelIndex idx)
void setRelativePath(const std::string &relativePath)
virtual void load()
std::string m_sRootSiteMap
Wt::Signal< gdWFileView::signalType, std::string > & fileSelected()
Definition: WsSiteMapView.h:70
void layoutSizeChanged(int width, int height)
std::string SiteMapPath2path(const std::string &siteMapPath)
Wt::WStandardItemModel * m_pModelTree
Definition: WsSiteMapView.h:92
Wt::WTreeView * m_pTVTree
Definition: WsSiteMapView.h:94
std::string selectedPath()
Wt::WTreeView * m_pTVView
Definition: WsSiteMapView.h:95
NodePtr m_pTreecurNode
bool m_bOnDataChanged
Definition: WsSiteMapView.h:99
std::string currentFolderPath()
WsSiteMapView(gdwtcore::viewType dlgType, gdWFileView::tbFlags flags=gdWFileView::tbDefault, Wt::WContainerWidget *parent=0)
void init(NodePtr pNode)
std::string m_selectedDirectory
void onTreeExpanded(Wt::WModelIndex idx)
NodePtr m_node
Definition: WsSiteMapView.h:26
gdWFileView::tbFlags m_tbFlags
Definition: WsSiteMapView.h:91
Wt::WStandardItemModel * m_pModelView
Definition: WsSiteMapView.h:93
void doDelete(Wt::StandardButton button)
bool loadTree(Wt::WStandardItem *currentItem, NodePtr pNode, gdWFileView::skipMode skipParentDir=gdWFileView::noSkipParent)
void onTreeSelectionChanged()
Wt::Signal< gdWFileView::signalType, std::string > fileSelected_
Definition: WsSiteMapView.h:72
gdToolbarItem * m_tbiNewFolder
std::string selectedDirectory()
bool loadFile(Wt::WStandardItem *currentItem, const std::string &currentPath, NodePtr curNode)
void doConfirmDelete()
std::string path2SiteMapPath(const std::string &path)
void treeMatchPath(NodePtr pNode)
std::string m_sRootPath
Wt::WMessageBox * m_pMb
gdToolbarItem * m_tbiDelete
bool loadFolder(Wt::WStandardItem *currentItem, const std::string &newPath, NodePtr curNode, bool bEdit=false)
void onDirectoryNameChanged(Wt::WStandardItem *pItem)
gdToolbar * m_pTb
Definition: WsSiteMapView.h:96
gdwtcore::viewType m_viewType
Definition: WsSiteMapView.h:90
std::string selectedFile()
std::string m_sSiteMap
Wt::WMenu * m_pMenu
User class.
void setNode(NodePtr pNode)
gdToolbarItem * m_tbiRename