Move VHDDManager over to using vector. Also fix some variable and function name typos.

This commit is contained in:
Lioncash 2014-03-30 00:13:00 -04:00
parent 479ef45aec
commit b9de74f5c6
2 changed files with 27 additions and 28 deletions

View File

@ -87,7 +87,7 @@ void VHDDExplorer::UpdateList()
{ {
m_list->Freeze(); m_list->Freeze();
m_list->DeleteAllItems(); m_list->DeleteAllItems();
m_entries.Clear(); m_entries.clear();
m_names.Clear(); m_names.Clear();
u64 block; u64 block;
@ -101,7 +101,7 @@ void VHDDExplorer::UpdateList()
m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File"); m_list->SetItem(item, 1, entry.type == vfsHDD_Entry_Dir ? "Dir" : "File");
m_list->SetItem(item, 2, wxString::Format("%lld", entry.size)); m_list->SetItem(item, 2, wxString::Format("%lld", entry.size));
m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format()); m_list->SetItem(item, 3, wxDateTime().Set(time_t(entry.ctime)).Format());
m_entries.AddCpy(entry); m_entries.push_back(entry);
m_names.Add(name); m_names.Add(name);
} }
@ -397,7 +397,7 @@ VHDDManagerDialog::VHDDManagerDialog(wxWindow* parent)
Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnRemove)); Connect(id_remove, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnRemove));
Connect(id_create_hdd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnCreateHDD)); Connect(id_create_hdd, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VHDDManagerDialog::OnCreateHDD));
Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VHDDManagerDialog::OnClose)); Connect(wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VHDDManagerDialog::OnClose));
LoadPathes(); LoadPaths();
UpdateList(); UpdateList();
} }
@ -406,9 +406,9 @@ void VHDDManagerDialog::UpdateList()
m_list->Freeze(); m_list->Freeze();
m_list->DeleteAllItems(); m_list->DeleteAllItems();
for(size_t i=0; i<m_pathes.GetCount(); ++i) for(size_t i=0; i<m_paths.size(); ++i)
{ {
m_list->InsertItem(i, m_pathes[i]); m_list->InsertItem(i, m_paths[i]);
} }
m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER); m_list->SetColumnWidth(0, wxLIST_AUTOSIZE_USEHEADER);
@ -420,7 +420,7 @@ void VHDDManagerDialog::UpdateList()
void VHDDManagerDialog::Open(int sel) void VHDDManagerDialog::Open(int sel)
{ {
VHDDExplorer dial(this, m_pathes[sel]); VHDDExplorer dial(this, m_paths[sel]);
dial.ShowModal(); dial.ShowModal();
} }
@ -439,14 +439,14 @@ void VHDDManagerDialog::AddHDD(wxCommandEvent& event)
return; return;
} }
wxArrayString pathes; wxArrayString paths;
ctrl.GetPaths(pathes); ctrl.GetPaths(paths);
for(size_t i=0; i<pathes.GetCount(); ++i) for(size_t i=0; i<paths.GetCount(); ++i)
{ {
bool skip = false; bool skip = false;
for(size_t j=0; j<m_pathes.GetCount(); ++j) for(size_t j=0; j<m_paths.size(); ++j)
{ {
if(m_pathes[j].CmpNoCase(pathes[i]) == 0) if(m_paths[j].CmpNoCase(paths[i]) == 0)
{ {
skip = true; skip = true;
break; break;
@ -455,7 +455,7 @@ void VHDDManagerDialog::AddHDD(wxCommandEvent& event)
if(!skip) if(!skip)
{ {
m_pathes.Move(new wxString(pathes[i].c_str())); m_paths.emplace_back(paths[i]);
} }
} }
UpdateList(); UpdateList();
@ -483,7 +483,7 @@ void VHDDManagerDialog::OnRemove(wxCommandEvent& event)
{ {
for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs) for(int sel = m_list->GetNextSelected(-1), offs = 0; sel != wxNOT_FOUND; sel = m_list->GetNextSelected(sel), --offs)
{ {
m_pathes.RemoveAt(sel + offs); m_paths.erase(m_paths.begin() + (sel + offs));
} }
UpdateList(); UpdateList();
@ -506,44 +506,42 @@ void VHDDManagerDialog::OnCreateHDD(wxCommandEvent& event)
u64 size, bsize; u64 size, bsize;
dial.GetResult(size, bsize); dial.GetResult(size, bsize);
vfsHDDManager::CreateHDD(ctrl.GetPath(), size, bsize); vfsHDDManager::CreateHDD(ctrl.GetPath(), size, bsize);
m_pathes.AddCpy(ctrl.GetPath()); m_paths.push_back(ctrl.GetPath());
UpdateList(); UpdateList();
} }
} }
void VHDDManagerDialog::OnClose(wxCloseEvent& event) void VHDDManagerDialog::OnClose(wxCloseEvent& event)
{ {
SavePathes(); SavePaths();
event.Skip(); event.Skip();
} }
void VHDDManagerDialog::LoadPathes() void VHDDManagerDialog::LoadPaths()
{ {
IniEntry<int> path_count; IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager"); path_count.Init("path_count", "HDDManager");
int count = 0; int count = 0;
count = path_count.LoadValue(count); count = path_count.LoadValue(count);
m_pathes.SetCount(count); for(size_t i=0; i<count; ++i)
for(size_t i=0; i<m_pathes.GetCount(); ++i)
{ {
IniEntry<wxString> path_entry; IniEntry<wxString> path_entry;
path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); path_entry.Init(wxString::Format("path[%d]", i), "HDDManager");
new (m_pathes + i) wxString(path_entry.LoadValue(wxEmptyString)); m_paths.emplace_back(path_entry.LoadValue(wxEmptyString));
} }
} }
void VHDDManagerDialog::SavePathes() void VHDDManagerDialog::SavePaths()
{ {
IniEntry<int> path_count; IniEntry<int> path_count;
path_count.Init("path_count", "HDDManager"); path_count.Init("path_count", "HDDManager");
path_count.SaveValue(m_pathes.GetCount()); path_count.SaveValue(m_paths.size());
for(size_t i=0; i<m_pathes.GetCount(); ++i) for(size_t i=0; i<m_paths.size(); ++i)
{ {
IniEntry<wxString> path_entry; IniEntry<wxString> path_entry;
path_entry.Init(wxString::Format("path[%d]", i), "HDDManager"); path_entry.Init(wxString::Format("path[%d]", i), "HDDManager");
path_entry.SaveValue(m_pathes[i]); path_entry.SaveValue(m_paths[i]);
} }
} }

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#include <vector>
#include <wx/dnd.h> #include <wx/dnd.h>
#include "Emu/HDD/HDD.h" #include "Emu/HDD/HDD.h"
@ -20,7 +21,7 @@ public:
class VHDDExplorer : public wxDialog class VHDDExplorer : public wxDialog
{ {
Array<vfsHDD_Entry> m_entries; std::vector<vfsHDD_Entry> m_entries;
wxArrayString m_names; wxArrayString m_names;
wxListView* m_list; wxListView* m_list;
vfsHDD* m_hdd; vfsHDD* m_hdd;
@ -65,7 +66,7 @@ public:
class VHDDManagerDialog : public wxDialog class VHDDManagerDialog : public wxDialog
{ {
Array<wxString> m_pathes; std::vector<wxString> m_paths;
wxListView* m_list; wxListView* m_list;
public: public:
@ -82,6 +83,6 @@ public:
void OnCreateHDD(wxCommandEvent& event); void OnCreateHDD(wxCommandEvent& event);
void OnClose(wxCloseEvent& event); void OnClose(wxCloseEvent& event);
void LoadPathes(); void LoadPaths();
void SavePathes(); void SavePaths();
}; };