pause
This commit is contained in:
parent
7a1deaba1d
commit
99553e75b2
@ -14,6 +14,7 @@ void CBasePanel::Init()
|
|||||||
btnConnect_ = new wxButton(this, wxID_ANY, _("Connect"));
|
btnConnect_ = new wxButton(this, wxID_ANY, _("Connect"));
|
||||||
btnDisconnect_ = new wxButton(this, wxID_ANY, _("DisConnect"));
|
btnDisconnect_ = new wxButton(this, wxID_ANY, _("DisConnect"));
|
||||||
dirctrl_ = new CModeDirCtrl(this);
|
dirctrl_ = new CModeDirCtrl(this);
|
||||||
|
dirctrl_->SetRootPath("transm://op");
|
||||||
rbtLocal_ = new wxRadioButton(this, wxID_ANY, _("Local"));
|
rbtLocal_ = new wxRadioButton(this, wxID_ANY, _("Local"));
|
||||||
rbtRemote_ = new wxRadioButton(this, wxID_ANY, _("Remote"));
|
rbtRemote_ = new wxRadioButton(this, wxID_ANY, _("Remote"));
|
||||||
lbState_ = new wxStaticText(this, wxID_ANY, _("State"));
|
lbState_ = new wxStaticText(this, wxID_ANY, _("State"));
|
||||||
|
@ -1,16 +1,112 @@
|
|||||||
#include "modeDirCtrl.h"
|
#include "modeDirCtrl.h"
|
||||||
|
#include <wx/artprov.h>
|
||||||
|
|
||||||
CModeDirCtrl::CModeDirCtrl(wxWindow* parent, wxWindowID id) : wxGenericDirCtrl(parent, id)
|
wxString kTransmScheme1 = "transm:/";
|
||||||
|
wxString kTransmScheme2 = "transm://";
|
||||||
|
|
||||||
|
CModeDirCtrl::CModeDirCtrl(wxWindow* parent, wxWindowID id) : wxTreeCtrl(parent, id), imageList_(new wxImageList(16, 16, true, 2))
|
||||||
{
|
{
|
||||||
wxFileSystem::AddHandler(new CTransmHandler());
|
if (!wxFileSystem::HasHandlerForPath(kTransmScheme2)) {
|
||||||
wxFileSystem::AddHandler(new wxLocalFSHandler());
|
wxFileSystem::AddHandler(new CTransmHandler());
|
||||||
wxFileSystem fs;
|
|
||||||
wxFSFile* f = fs.OpenFile("transm://D:/test.txt");
|
|
||||||
if (f == nullptr) {
|
|
||||||
wxLogError("Cannot open file");
|
|
||||||
}
|
}
|
||||||
|
if (!wxFileSystem::HasHandlerForPath("file://")) {
|
||||||
|
wxFileSystem::AddHandler(new wxLocalFSHandler());
|
||||||
|
}
|
||||||
|
|
||||||
|
imageList_->Add(wxArtProvider::GetBitmap(wxART_FOLDER, wxART_OTHER, wxSize(16, 16)));
|
||||||
|
imageList_->Add(wxArtProvider::GetBitmap(wxART_NORMAL_FILE, wxART_OTHER, wxSize(16, 16)));
|
||||||
|
AssignImageList(imageList_);
|
||||||
|
|
||||||
|
Bind(wxEVT_TREE_ITEM_ACTIVATED, &CModeDirCtrl::OnItemActivated, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CModeDirCtrl::~CModeDirCtrl()
|
CModeDirCtrl::~CModeDirCtrl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CModeDirCtrl::SetRootPath(const wxString& path)
|
||||||
|
{
|
||||||
|
rootPath_ = path;
|
||||||
|
DeleteAllItems();
|
||||||
|
|
||||||
|
wxTreeItemId root = AddRoot(path.AfterLast('/'), -1, -1, new TreeItemData(path));
|
||||||
|
|
||||||
|
SetItemImage(root, 0, wxTreeItemIcon_Normal);
|
||||||
|
|
||||||
|
AddChildren(root);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModeDirCtrl::RefreshCurrent()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModeDirCtrl::BuildTree()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModeDirCtrl::AddChildren(wxTreeItemId parent)
|
||||||
|
{
|
||||||
|
if (!parent.IsOk()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString parentPath = GetFullPath(parent);
|
||||||
|
if (parentPath.IsEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFileSystem fs;
|
||||||
|
fs.ChangePathTo(parentPath);
|
||||||
|
|
||||||
|
Freeze();
|
||||||
|
|
||||||
|
wxTreeItemIdValue cookie;
|
||||||
|
wxTreeItemId child = GetFirstChild(parent, cookie);
|
||||||
|
while (child.IsOk()) {
|
||||||
|
if (GetItemText(child) != "<dummy>") {
|
||||||
|
Delete(child);
|
||||||
|
}
|
||||||
|
child = GetNextChild(parent, cookie);
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString filename = fs.FindFirst("*", wxDIR | wxFILE);
|
||||||
|
while (!filename.empty()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString CModeDirCtrl::GetFullPath(wxTreeItemId item) const
|
||||||
|
{
|
||||||
|
if (!item.IsOk()) {
|
||||||
|
return wxEmptyString;
|
||||||
|
}
|
||||||
|
auto* data = static_cast<TreeItemData*>(GetItemData(item));
|
||||||
|
if (data) {
|
||||||
|
return data->path_;
|
||||||
|
}
|
||||||
|
wxString path;
|
||||||
|
wxTreeItemId parent = GetItemParent(item);
|
||||||
|
if (!parent.IsOk()) {
|
||||||
|
return rootPath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
path = GetFullPath(parent) + "/" + GetItemText(item);
|
||||||
|
path.Replace("//", "/");
|
||||||
|
if (path.StartsWith(kTransmScheme1) && !path.StartsWith(kTransmScheme2)) {
|
||||||
|
path.Replace(kTransmScheme1, kTransmScheme2);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModeDirCtrl::OnItemActivated(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
auto path = GetFullPath(event.GetItem());
|
||||||
|
if (path.IsEmpty())
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CModeDirCtrl::OnItemExpanding(wxTreeEvent& event)
|
||||||
|
{
|
||||||
|
auto item = event.GetItem();
|
||||||
|
}
|
||||||
|
@ -2,17 +2,39 @@
|
|||||||
#define MODEDIRCTRL_H
|
#define MODEDIRCTRL_H
|
||||||
|
|
||||||
#include "transmhandler.h"
|
#include "transmhandler.h"
|
||||||
#include <wx/dirctrl.h>
|
#include <wx/treectrl.h>
|
||||||
#include <wx/wx.h>
|
#include <wx/wx.h>
|
||||||
|
|
||||||
class CModeDirCtrl : public wxGenericDirCtrl
|
class CModeDirCtrl : public wxTreeCtrl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CModeDirCtrl(wxWindow* parent, wxWindowID id = wxID_ANY);
|
CModeDirCtrl(wxWindow* parent, wxWindowID id = wxID_ANY);
|
||||||
~CModeDirCtrl();
|
~CModeDirCtrl() override;
|
||||||
|
|
||||||
|
public:
|
||||||
|
bool SetRootPath(const wxString& path);
|
||||||
|
void RefreshCurrent();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// void OnExpandItem(wxTreeEvent& event) override;
|
class TreeItemData : public wxTreeItemData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit TreeItemData(const wxString& path) : path_(path)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
wxString path_;
|
||||||
|
};
|
||||||
|
|
||||||
|
void BuildTree();
|
||||||
|
void AddChildren(wxTreeItemId parent);
|
||||||
|
wxString GetFullPath(wxTreeItemId item) const;
|
||||||
|
|
||||||
|
void OnItemActivated(wxTreeEvent& event);
|
||||||
|
void OnItemExpanding(wxTreeEvent& event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString rootPath_{};
|
||||||
|
wxImageList* imageList_{};
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MODEDIRCTRL_H
|
#endif // MODEDIRCTRL_H
|
Loading…
x
Reference in New Issue
Block a user