-/////////////////////////////////////////////////////////////////////////////
+//////////////////////////////////////////////////////////////////////////////
// Name: filedlgg.cpp
// Purpose: wxGenericFileDialog
// Author: Robert Roebling
// wxFileData
//-----------------------------------------------------------------------------
-wxFileData::wxFileData( const wxFileData& fileData )
-{
- m_fileName = fileData.GetFileName();
- m_filePath = fileData.GetFilePath();
- m_size = fileData.GetSize();
- m_dateTime = fileData.GetDateTime();
- m_permissions = fileData.GetPermissions();
- m_type = fileData.GetType();
- m_image = GetImageId();
-}
-
wxFileData::wxFileData( const wxString &filePath, const wxString &fileName, fileType type, int image_id )
{
m_fileName = fileName;
ReadData();
}
+void wxFileData::Copy( const wxFileData& fileData )
+{
+ m_fileName = fileData.GetFileName();
+ m_filePath = fileData.GetFilePath();
+ m_size = fileData.GetSize();
+ m_dateTime = fileData.GetDateTime();
+ m_permissions = fileData.GetPermissions();
+ m_type = fileData.GetType();
+ m_image = GetImageId();
+}
+
void wxFileData::ReadData()
{
if (IsDrive())
BEGIN_EVENT_TABLE(wxFileCtrl,wxListCtrl)
EVT_LIST_DELETE_ITEM(-1, wxFileCtrl::OnListDeleteItem)
+ EVT_LIST_DELETE_ALL_ITEMS(-1, wxFileCtrl::OnListDeleteAllItems)
EVT_LIST_END_LABEL_EDIT(-1, wxFileCtrl::OnListEndLabelEdit)
EVT_LIST_COL_CLICK(-1, wxFileCtrl::OnListColClick)
END_EVENT_TABLE()
wxBusyCursor bcur; // this may take a while...
- FreeAllItemsData();
DeleteAllItems();
wxListItem item;
for (n=0; n<count; n++)
{
wxFileData *fd = new wxFileData(paths[n], names[n], wxFileData::is_drive, icons[n]);
- Add(fd, item);
+ if (Add(fd, item) != -1)
item.m_itemId++;
+ else
+ delete fd;
}
}
else
if (p.IsEmpty()) p = wxT("/");
#endif // __UNIX__
wxFileData *fd = new wxFileData(p, wxT(".."), wxFileData::is_dir, wxFileIconsTable::folder);
- Add(fd, item);
+ if (Add(fd, item) != -1)
item.m_itemId++;
+ else
+ delete fd;
}
wxString dirname(m_dirName);
while (cont)
{
wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_dir, wxFileIconsTable::folder);
- Add(fd, item);
+ if (Add(fd, item) != -1)
item.m_itemId++;
+ else
+ delete fd;
+
cont = dir.GetNext(&f);
}
while (cont)
{
wxFileData *fd = new wxFileData(dirPrefix + f, f, wxFileData::is_file, wxFileIconsTable::file);
- Add(fd, item);
+ if (Add(fd, item) != -1)
item.m_itemId++;
+ else
+ delete fd;
+
cont = dir.GetNext(&f);
}
}
EnsureVisible( id );
EditLabel( id );
}
+ else
+ delete fd;
}
void wxFileCtrl::GoToParentDir()
EnsureVisible( 0 );
}
-void wxFileCtrl::FreeItemData(const wxListItem& item)
+void wxFileCtrl::FreeItemData(wxListItem& item)
{
- wxFileData *fd = (wxFileData*)item.m_data;
- delete fd;
+ if ( item.m_data )
+ {
+ wxFileData *fd = (wxFileData*)item.m_data;
+ delete fd;
+
+ item.m_data = 0;
+ }
}
void wxFileCtrl::OnListDeleteItem( wxListEvent &event )
FreeItemData(event.m_item);
}
+void wxFileCtrl::OnListDeleteAllItems( wxListEvent &event )
+{
+ FreeAllItemsData();
+}
+
void wxFileCtrl::FreeAllItemsData()
{
wxListItem item;
wxFileCtrl::~wxFileCtrl()
{
- FreeAllItemsData();
}
//-----------------------------------------------------------------------------
long wxGenericFileDialog::ms_lastViewStyle = wxLC_LIST;
bool wxGenericFileDialog::ms_lastShowHidden = FALSE;
-wxGenericFileDialog::wxGenericFileDialog()
-{
-}
-
wxGenericFileDialog::wxGenericFileDialog(wxWindow *parent,
const wxString& message,
const wxString& defaultDir,
IMPLEMENT_DYNAMIC_CLASS(wxFileDialog, wxGenericFileDialog);
-wxFileDialog::wxFileDialog()
-{
-}
-
-wxFileDialog::wxFileDialog(wxWindow *parent,
- const wxString& message,
- const wxString& defaultDir,
- const wxString& defaultFile,
- const wxString& wildCard,
- long style,
- const wxPoint& pos)
- :wxGenericFileDialog(parent, message, defaultDir, defaultFile, wildCard, style, pos)
-{
-}
-
#endif // USE_GENERIC_FILEDIALOG
#endif // wxUSE_FILEDLG