No changes, just some cleanup in wxGenericDirCtrl code.

Use GetItemData() helper to only write a cast to wxDirItemData in this
function instead of repeating it many times.

See #14790.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72841 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-11-01 17:15:03 +00:00
parent efafcdca4a
commit 0d6f66f45c
2 changed files with 12 additions and 6 deletions

View File

@@ -192,6 +192,7 @@ protected:
private:
void PopulateNode(wxTreeItemId node);
wxDirItemData* GetItemData(wxTreeItemId itemId);
bool m_showHidden;
wxTreeItemId m_rootId;

View File

@@ -666,7 +666,7 @@ void wxGenericDirCtrl::OnEndEditItem(wxTreeEvent &event)
}
wxTreeItemId treeid = event.GetItem();
wxDirItemData *data = (wxDirItemData*)m_treeCtrl->GetItemData( treeid );
wxDirItemData *data = GetItemData( treeid );
wxASSERT( data );
wxString new_name( wxPathOnly( data->m_path ) );
@@ -716,7 +716,7 @@ void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId)
{
wxTreeItemId child;
wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(parentId);
wxDirItemData *data = GetItemData(parentId);
if (!data->m_isExpanded)
return;
@@ -731,7 +731,7 @@ void wxGenericDirCtrl::CollapseDir(wxTreeItemId parentId)
void wxGenericDirCtrl::PopulateNode(wxTreeItemId parentId)
{
wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(parentId);
wxDirItemData *data = GetItemData(parentId);
if (data->m_isExpanded)
return;
@@ -922,7 +922,7 @@ wxTreeItemId wxGenericDirCtrl::FindChild(wxTreeItemId parentId, const wxString&
wxTreeItemId childId = m_treeCtrl->GetFirstChild(parentId, cookie);
while (childId.IsOk())
{
wxDirItemData* data = (wxDirItemData*) m_treeCtrl->GetItemData(childId);
wxDirItemData* data = GetItemData(childId);
if (data && !data->m_path.empty())
{
@@ -973,7 +973,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path)
if (!lastId.IsOk())
return false;
wxDirItemData *data = (wxDirItemData *) m_treeCtrl->GetItemData(lastId);
wxDirItemData *data = GetItemData(lastId);
if (data->m_isDir)
{
m_treeCtrl->Expand(lastId);
@@ -986,7 +986,7 @@ bool wxGenericDirCtrl::ExpandPath(const wxString& path)
bool selectedChild = false;
while (childId.IsOk())
{
data = (wxDirItemData*) m_treeCtrl->GetItemData(childId);
data = GetItemData(childId);
if (data && data->m_path != wxEmptyString && !data->m_isDir)
{
@@ -1038,6 +1038,11 @@ bool wxGenericDirCtrl::CollapsePath(const wxString& path)
return true;
}
wxDirItemData* wxGenericDirCtrl::GetItemData(wxTreeItemId itemId)
{
return static_cast<wxDirItemData*>(m_treeCtrl->GetItemData(itemId));
}
wxString wxGenericDirCtrl::GetPath(wxTreeItemId itemId) const
{
const wxDirItemData*