本文整理汇总了C++中MyClientData类的典型用法代码示例。如果您正苦于以下问题:C++ MyClientData类的具体用法?C++ MyClientData怎么用?C++ MyClientData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyClientData类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetItemData
void SFTPTreeView::OnFileDropped(clCommandEvent& event)
{
wxArrayTreeItemIds items;
m_treeCtrl->GetSelections(items);
wxTreeItemId parenItem;
wxString defaultPath = m_textCtrlQuickJump->GetValue();
if(items.size() == 1) {
// Use the selected folder as the default path
MyClientData* cd = GetItemData(items.Item(0));
if(cd && cd->IsFolder()) {
defaultPath = cd->GetFullPath();
parenItem = items.Item(0);
}
}
SFTPUploadDialog dlg(EventNotifier::Get()->TopFrame());
dlg.GetTextCtrlRemoteFolder()->ChangeValue(defaultPath);
if(dlg.ShowModal() != wxID_OK) return;
const wxString targetFolder = dlg.GetTextCtrlRemoteFolder()->GetValue();
const wxArrayString& files = event.GetStrings();
for(size_t i = 0; i < files.size(); ++i) {
wxFileName localFile(files.Item(i));
wxString remotePath;
remotePath << targetFolder << "/" << localFile.GetFullName();
if(parenItem.IsOk()) {
wxTreeItemId fileItem = DoAddFile(parenItem, remotePath);
if(!fileItem.IsOk()) continue;
}
SFTPWorkerThread::Instance()->Add(new SFTPThreadRequet(m_account, remotePath, localFile.GetFullPath(), 0));
}
}
示例2: CHECK_ITEM_RET
void SFTPTreeView::OnContextMenu(wxTreeListEvent& event)
{
CHECK_ITEM_RET(event.GetItem());
MyClientData* cd = GetItemData(event.GetItem());
wxMenu menu;
if(cd) {
// Just incase, make sure the item is selected
m_treeListCtrl->Select(event.GetItem());
if(!cd->IsFolder()) {
menu.Append(ID_OPEN, _("Open"));
menu.Append(ID_OPEN_WITH_DEFAULT_APP, _("Open with Default Application..."));
menu.AppendSeparator();
menu.Append(ID_OPEN_CONTAINING_FOLDER, _("Download and Open Containing Folder..."));
menu.AppendSeparator();
} else {
menu.Append(ID_NEW, _("Create new directory..."));
menu.Append(ID_NEW_FILE, _("Create new file..."));
menu.AppendSeparator();
menu.Append(ID_REFRESH_FOLDER, _("Refresh"));
menu.AppendSeparator();
}
menu.Append(ID_DELETE, _("Delete"));
#ifdef __WXMAC__
menu.Enable(ID_DELETE, false);
#endif
menu.Append(ID_RENAME, _("Rename"));
}
m_treeListCtrl->PopupMenu(&menu);
}
示例3: MyClientData
wxTreeListItem SFTPTreeView::DoAddFile(const wxTreeListItem& parent, const wxString& path)
{
try {
wxMemoryBuffer memBuffer;
m_sftp->Write(memBuffer, path);
SFTPAttribute::Ptr_t attr = m_sftp->Stat(path);
// Update the UI
MyClientData* newFile = new MyClientData(path);
newFile->SetIsFolder(false);
newFile->SetInitialized(false);
wxTreeListItem child = m_treeListCtrl->AppendItem(
parent,
newFile->GetFullName(),
m_bmpLoader.GetMimeImageId(FileExtManager::GetType(path, FileExtManager::TypeText)),
wxNOT_FOUND,
newFile);
m_treeListCtrl->SetSortColumn(0);
return child;
} catch(clException& e) {
::wxMessageBox(e.What(), "SFTP", wxICON_ERROR | wxOK | wxCENTER);
}
return wxTreeListItem();
}
示例4: MyClientData
wxTreeListItem SFTPTreeView::DoAddFolder(const wxTreeListItem& parent, const wxString& path)
{
try {
m_sftp->CreateDir(path);
SFTPAttribute::Ptr_t attr = m_sftp->Stat(path);
// Update the UI
MyClientData* newCd = new MyClientData(path);
newCd->SetIsFolder(true);
newCd->SetInitialized(false);
wxTreeListItem child = m_treeListCtrl->AppendItem(
parent, newCd->GetFullName(), m_bmpLoader.GetMimeImageId(FileExtManager::TypeFolder), wxNOT_FOUND, newCd);
if(IsTypeColumnShown()) {
m_treeListCtrl->SetItemText(child, GetTypeColumnIndex(), attr->GetTypeAsString());
}
if(IsSizeColumnShown()) {
m_treeListCtrl->SetItemText(child, GetSizeColumnIndex(), wxString() << attr->GetSize());
}
m_treeListCtrl->AppendItem(child, "<dummy>");
m_treeListCtrl->SetSortColumn(0);
return child;
} catch(clException& e) {
::wxMessageBox(e.What(), "SFTP", wxICON_ERROR | wxOK | wxCENTER);
}
return wxTreeListItem();
}
示例5: GetItemData
void SFTPTreeView::OnMenuNewFile(wxCommandEvent& event)
{
wxTreeListItems items;
m_treeListCtrl->GetSelections(items);
if(items.size() != 1) return;
MyClientData* cd = GetItemData(items.at(0));
CHECK_PTR_RET(cd);
if(!cd->IsFolder()) {
return;
}
wxString defaultValue;
static size_t s_untitledCounter = 0;
defaultValue << "Untitled" << ++s_untitledCounter;
wxString new_name = ::wxGetTextFromUser(_("Enter the new file name:"), _("New File"), defaultValue);
if(!new_name.IsEmpty()) {
wxString fullpath = cd->GetFullPath();
fullpath << "/" << new_name;
wxTreeListItem fileItem = DoAddFile(items.at(0), fullpath);
if(fileItem.IsOk()) {
DoOpenFile(fileItem);
}
}
}
示例6: _
void SFTPTreeView::OnMenuDelete(wxCommandEvent& event)
{
wxTreeListItems items;
m_treeListCtrl->GetSelections(items);
if(items.empty()) return;
wxString message;
message << _("Are you sure you want to delete the selected items?");
if(::wxMessageBox(message, "Confirm", wxYES_NO | wxCANCEL | wxICON_QUESTION) != wxYES) {
return;
}
try {
for(size_t i = 0; i < items.size(); ++i) {
MyClientData* cd = GetItemData(items.at(i));
if(cd->IsFolder()) {
m_sftp->RemoveDir(cd->GetFullPath());
} else {
m_sftp->UnlinkFile(cd->GetFullPath());
}
// Remove the selection
m_treeListCtrl->DeleteItem(items.at(i));
}
} catch(clException& e) {
::wxMessageBox(e.What(), "SFTP", wxICON_ERROR | wxOK | wxCENTER);
}
}
示例7: GetSelectionsItemData
void SFTPTreeView::OnSelectionChanged(wxTreeEvent& event)
{
MyClientDataVect_t items = GetSelectionsItemData();
if(items.size() != 1) return;
MyClientData* cd = items.at(0);
if(cd->IsFolder()) { m_textCtrlQuickJump->ChangeValue(cd->GetFullPath()); }
}
示例8: CHECK_ITEM_RET
void SFTPTreeView::OnContextMenu(wxTreeListEvent& event)
{
CHECK_ITEM_RET(event.GetItem());
MyClientData* cd = GetItemData(event.GetItem());
wxMenu menu;
if(cd) {
// Just incase, make sure the item is selected
m_treeListCtrl->Select(event.GetItem());
if(!cd->IsFolder()) {
menu.Append(ID_OPEN, _("Open"));
menu.AppendSeparator();
} else {
menu.Append(ID_NEW, _("Create new directory..."));
menu.Append(ID_NEW_FILE, _("Create new file..."));
menu.AppendSeparator();
menu.Append(ID_REFRESH_FOLDER, _("Refresh"));
menu.AppendSeparator();
}
menu.Append(ID_DELETE, _("Delete"));
#ifdef __WXMAC__
menu.Enable(ID_DELETE, false);
#endif
menu.Append(ID_RENAME, _("Rename"));
}
#if defined(__WXMSW__) || defined(__WXOSX__)
if(cd) {
menu.AppendSeparator();
}
// Append headers column menu items
menu.Append(ID_SHOW_TYPE_COL, _("Show 'Type' column"), "", wxITEM_CHECK);
menu.Append(ID_SHOW_SIZE_COL, _("Show 'Size' column"), "", wxITEM_CHECK);
menu.Check(ID_SHOW_TYPE_COL, IsTypeColumnShown());
menu.Check(ID_SHOW_SIZE_COL, IsSizeColumnShown());
// Due to bug in wxWidgets, don't allow the user to remove columns once the
// tree is populated
menu.Enable(ID_SHOW_TYPE_COL, !IsConnected());
menu.Enable(ID_SHOW_SIZE_COL, !IsConnected());
#endif
m_treeListCtrl->PopupMenu(&menu);
}
示例9: MyClientData
void SFTPTreeView::DoBuildTree(const wxString& initialFolder)
{
m_treeCtrl->DeleteAllItems();
// add the root item
MyClientData* cd = new MyClientData(initialFolder);
cd->SetIsFolder(true);
wxTreeItemId root =
m_treeCtrl->AppendItem(m_treeCtrl->GetRootItem(), initialFolder,
m_bmpLoader->GetMimeImageId(FileExtManager::TypeFolder), wxNOT_FOUND, cd);
m_treeCtrl->AppendItem(root, "<dummy>");
DoExpandItem(root);
}
示例10: GetItemData
bool SFTPTreeView::DoOpenFile(const wxTreeItemId& item)
{
MyClientData* cd = GetItemData(item);
if(!cd || cd->IsFolder()) { return false; }
RemoteFileInfo remoteFile;
remoteFile.SetAccount(m_account);
remoteFile.SetRemoteFile(cd->GetFullPath());
SFTPThreadRequet* req = new SFTPThreadRequet(remoteFile);
SFTPWorkerThread::Instance()->Add(req);
m_plugin->AddRemoteFile(remoteFile);
return true;
}
示例11: GetItemData
void SFTPTreeView::OnMenuOpenWithDefaultApplication(wxCommandEvent& event)
{
wxTreeListItems items;
m_treeListCtrl->GetSelections(items);
if(items.empty()) return;
for(size_t i = 0; i < items.size(); ++i) {
MyClientData* cd = GetItemData(items.at(i));
if(!cd || cd->IsFolder()) {
continue;
}
RemoteFileInfo remoteFile;
remoteFile.SetAccount(m_account);
remoteFile.SetRemoteFile(cd->GetFullPath());
SFTPThreadRequet* req = new SFTPThreadRequet(remoteFile);
req->SetDirection(SFTPThreadRequet::kDownloadAndOpenWithDefaultApp);
SFTPWorkerThread::Instance()->Add(req);
}
}
示例12: Compare
int SFTPItemComparator::Compare(wxTreeListCtrl* treelist, unsigned column, wxTreeListItem first, wxTreeListItem second)
{
// get the item data
MyClientData *cdOne = dynamic_cast<MyClientData *>(treelist->GetItemData(first));
MyClientData *cdTwo = dynamic_cast<MyClientData *>(treelist->GetItemData(second));
if ( column != 0 )
return 0;
if ( !cdOne || !cdTwo )
return 0;
if ( cdOne->IsFolder() && !cdTwo->IsFolder())
return -1;
else if ( !cdOne->IsFolder() && cdTwo->IsFolder() )
return 1;
else
return cdOne->GetFullName() > cdTwo->GetFullName();
}