stop:暂停开发。

This commit is contained in:
taynpg 2025-05-13 21:49:26 +08:00
parent 4ca6ded5b6
commit e8774bee10
4 changed files with 72 additions and 8 deletions

View File

@ -31,7 +31,7 @@ struct DirFileInfo {
} else if (size >= KB) { } else if (size >= KB) {
return wxString::Format("%.2f KB", static_cast<double>(size) / KB); return wxString::Format("%.2f KB", static_cast<double>(size) / KB);
} else { } else {
return wxString::Format("%llu B", size); return wxT("");
} }
} }

View File

@ -2,6 +2,27 @@
#include "LogControl.h" #include "LogControl.h"
#include <ClientCore.h> #include <ClientCore.h>
#include <InfoCommunicate.hpp> #include <InfoCommunicate.hpp>
#include <wx/renderer.h>
class ButtonCellRenderer : public wxGridCellRenderer
{
public:
void Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected) override
{
wxRendererNative::Get().DrawPushButton(&grid, dc, rect, wxCONTROL_PRESSED);
dc.DrawText(grid.GetCellValue(row, col), rect.x + 5, rect.y + (rect.height - dc.GetCharHeight()) / 2);
}
wxSize GetBestSize(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, int row, int col) override
{
return wxSize(80, 25); // 按钮默认大小
}
wxGridCellRenderer* Clone() const override
{
return new ButtonCellRenderer;
}
};
RemoteControl::RemoteControl(wxWindow* parent, std::shared_ptr<ClientCore>& clientCore) : wxPanel(parent), clientCore_(clientCore) RemoteControl::RemoteControl(wxWindow* parent, std::shared_ptr<ClientCore>& clientCore) : wxPanel(parent), clientCore_(clientCore)
{ {
@ -17,6 +38,7 @@ RemoteControl::~RemoteControl()
void RemoteControl::Init() void RemoteControl::Init()
{ {
grid_ = new wxGrid(this, wxID_ANY); grid_ = new wxGrid(this, wxID_ANY);
grid_->EnableEditing(false);
auto* topSizer = new wxBoxSizer(wxVERTICAL); auto* topSizer = new wxBoxSizer(wxVERTICAL);
auto* dirSizer = new wxBoxSizer(wxHORIZONTAL); auto* dirSizer = new wxBoxSizer(wxHORIZONTAL);
@ -47,6 +69,11 @@ void RemoteControl::Init()
topSizer->Add(bottomSizer, 1, wxEXPAND | wxCENTER); topSizer->Add(bottomSizer, 1, wxEXPAND | wxCENTER);
SetSizer(topSizer); SetSizer(topSizer);
Layout(); Layout();
idDown_ = wxNewId();
menuOperateFile_ = new wxMenu();
menuOperateFile_->Append(idDown_, _("Download"));
} }
void RemoteControl::BindEvent() void RemoteControl::BindEvent()
@ -62,15 +89,21 @@ void RemoteControl::BindEvent()
grid_->DeleteRows(0, grid_->GetNumberRows()); grid_->DeleteRows(0, grid_->GetNumberRows());
} }
for (auto& dirInfo : dirInfoVec.vec) { for (auto& dirInfo : dirInfoVec.vec) {
grid_->AppendRows(); if (!grid_->AppendRows()) {
continue;
}
auto rowIndex = grid_->GetNumberRows() - 1;
auto wxPath = wxString(dirInfo.fullPath.c_str()); auto wxPath = wxString(dirInfo.fullPath.c_str());
grid_->SetCellValue(grid_->GetNumberRows() - 1, 0, wxPath); grid_->SetCellValue(rowIndex, 0, wxPath);
grid_->SetCellValue(grid_->GetNumberRows() - 1, 1, DirFileInfo::GetFileSize(dirInfo.size)); grid_->SetCellValue(rowIndex, 1, DirFileInfo::GetFileSize(dirInfo.size));
grid_->SetCellValue(grid_->GetNumberRows() - 1, 2, DirFileInfo::GetFileTypeName(dirInfo.type)); grid_->SetCellValue(rowIndex, 2, DirFileInfo::GetFileTypeName(dirInfo.type));
grid_->SetCellValue(grid_->GetNumberRows() - 1, 3, DirFileInfo::GetStrTime(dirInfo.lastModifyTime)); grid_->SetCellValue(rowIndex, 3, DirFileInfo::GetStrTime(dirInfo.lastModifyTime));
grid_->SetCellValue(grid_->GetNumberRows() - 1, 4, wxString::Format("%o", dirInfo.permission)); grid_->SetCellValue(rowIndex, 4, wxString::Format("%o", dirInfo.permission));
grid_->DisableRowResize(rowIndex);
} }
}); });
grid_->Bind(wxEVT_GRID_LABEL_RIGHT_CLICK, &RemoteControl::OnRightClick, this);
} }
void RemoteControl::AskHome(wxCommandEvent& event) void RemoteControl::AskHome(wxCommandEvent& event)
@ -109,9 +142,26 @@ void RemoteControl::GetDirContent(wxCommandEvent& event)
} }
} }
void RemoteControl::OnRightClick(wxGridEvent& event)
{
if (event.GetRow() < 0 || event.GetCol() != -1) {
return;
}
wxArrayInt selectedRows = grid_->GetSelectedRows();
if (selectedRows.GetCount() < 1) {
return;
}
grid_->PopupMenu(menuOperateFile_, event.GetPosition());
}
void RemoteControl::SetGrid() void RemoteControl::SetGrid()
{ {
grid_->CreateGrid(10, 5); grid_->CreateGrid(10, 6);
for (int i = 0; i < 10; ++i) {
grid_->DisableRowResize(i);
}
grid_->SetColLabelValue(0, _("FullPath")); grid_->SetColLabelValue(0, _("FullPath"));
grid_->SetColLabelValue(1, _("FileSize")); grid_->SetColLabelValue(1, _("FileSize"));
grid_->SetColLabelValue(2, _("FileType")); grid_->SetColLabelValue(2, _("FileType"));
@ -123,6 +173,9 @@ void RemoteControl::SetGrid()
grid_->SetColSize(2, 100); grid_->SetColSize(2, 100);
grid_->SetColSize(3, 150); grid_->SetColSize(3, 150);
grid_->SetColSize(4, 100); grid_->SetColSize(4, 100);
grid_->SetCellRenderer(0, 5, new ButtonCellRenderer());
grid_->SetCellValue(0, 5, _("Download"));
} }
void RemoteControl::setRemoteID(const wxString& id) void RemoteControl::setRemoteID(const wxString& id)

View File

@ -27,6 +27,7 @@ private:
private: private:
void AskHome(wxCommandEvent& event); void AskHome(wxCommandEvent& event);
void GetDirContent(wxCommandEvent& event); void GetDirContent(wxCommandEvent& event);
void OnRightClick(wxGridEvent& event);
public: public:
wxGrid* grid_; wxGrid* grid_;
@ -37,6 +38,11 @@ public:
wxButton* btnUpLevel_; wxButton* btnUpLevel_;
wxButton* btnRefresh_; wxButton* btnRefresh_;
wxMenu* menuOperateFile_;
private:
wxWindowID idDown_;
private: private:
LogControl* logControl_; LogControl* logControl_;
std::shared_ptr<ClientCore> clientCore_; std::shared_ptr<ClientCore> clientCore_;

View File

@ -22,6 +22,11 @@ void TaskControl::Init()
void TaskControl::SetGrid() void TaskControl::SetGrid()
{ {
grid_->CreateGrid(10, 5); grid_->CreateGrid(10, 5);
for (int i = 0; i < 10; ++i) {
grid_->DisableRowResize(i);
}
grid_->SetColLabelValue(0, _("id")); grid_->SetColLabelValue(0, _("id"));
grid_->SetColLabelValue(1, _("LocalPurpose")); grid_->SetColLabelValue(1, _("LocalPurpose"));
grid_->SetColLabelValue(2, _("LocalType")); grid_->SetColLabelValue(2, _("LocalType"));