28
28
#define new DEBUG_NEW
31
class CRemoteListViewDropTarget : public wxDropTarget
31
class CRemoteListViewDropTarget : public CListCtrlDropTarget
34
34
CRemoteListViewDropTarget(CRemoteListView* pRemoteListView)
35
: m_pRemoteListView(pRemoteListView),
35
: CListCtrlDropTarget(pRemoteListView)
36
, m_pRemoteListView(pRemoteListView),
36
37
m_pFileDataObject(new wxFileDataObject()),
37
38
m_pRemoteDataObject(new CRemoteDataObject()),
38
39
m_pDataObject(new wxDataObjectComposite())
144
145
const std::list<CRemoteDataObject::t_fileInfo>& files = m_pRemoteDataObject->GetFiles();
145
for (std::list<CRemoteDataObject::t_fileInfo>::const_iterator iter = files.begin(); iter != files.end(); iter++)
146
for (std::list<CRemoteDataObject::t_fileInfo>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
147
148
const CRemoteDataObject::t_fileInfo& info = *iter;
160
for (std::list<CRemoteDataObject::t_fileInfo>::const_iterator iter = files.begin(); iter != files.end(); iter++)
161
for (std::list<CRemoteDataObject::t_fileInfo>::const_iterator iter = files.begin(); iter != files.end(); ++iter)
162
163
const CRemoteDataObject::t_fileInfo& info = *iter;
163
164
m_pRemoteListView->m_pState->m_pCommandQueue->ProcessCommand(
186
int DisplayDropHighlight(wxPoint point)
188
virtual void DisplayDropHighlight(wxPoint point)
190
DoDisplayDropHighlight(point);
193
int DoDisplayDropHighlight(wxPoint point)
189
196
int hit = m_pRemoteListView->HitTest(point, flags, 0);
229
236
virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def)
238
CListCtrlDropTarget::OnDragOver(x, y, def);
231
240
if (def == wxDragError ||
232
241
def == wxDragNone ||
233
242
def == wxDragCancel)
245
254
const CServer* const pServer = m_pRemoteListView->m_pState->GetServer();
246
255
wxASSERT(pServer);
248
int hit = DisplayDropHighlight(wxPoint(x, y));
257
int hit = DoDisplayDropHighlight(wxPoint(x, y));
249
258
const CDragDropManager* pDragDropManager = CDragDropManager::Get();
251
260
if (hit == -1 && pDragDropManager &&
259
268
virtual void OnLeave()
270
CListCtrlDropTarget::OnLeave();
261
271
ClearDropHighlight();
264
274
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
276
CListCtrlDropTarget::OnEnter(x, y, def);
266
277
return OnDragOver(x, y, def);
327
338
EVT_MENU(XRCID("ID_DOWNLOAD"), CRemoteListView::OnMenuDownload)
328
339
EVT_MENU(XRCID("ID_ADDTOQUEUE"), CRemoteListView::OnMenuDownload)
329
340
EVT_MENU(XRCID("ID_MKDIR"), CRemoteListView::OnMenuMkdir)
341
EVT_MENU(XRCID("ID_NEW_FILE"), CRemoteListView::OnMenuNewfile)
330
342
EVT_MENU(XRCID("ID_DELETE"), CRemoteListView::OnMenuDelete)
331
343
EVT_MENU(XRCID("ID_RENAME"), CRemoteListView::OnMenuRename)
332
344
EVT_MENU(XRCID("ID_CHMOD"), CRemoteListView::OnMenuChmod)
474
486
// Find correct position in index mapping
475
487
std::vector<unsigned int>::iterator start = m_indexMapping.begin();
478
490
CFileListCtrl<CGenericFileData>::CSortComparisonObject compare = GetSortComparisonObject();
479
491
std::vector<unsigned int>::iterator insertPos = std::lower_bound(start, m_indexMapping.end(), i, compare);
480
492
compare.Destroy();
482
494
const int item = insertPos - m_indexMapping.begin();
483
495
m_indexMapping.insert(insertPos, i);
485
for (std::list<unsigned int>::iterator iter = added.begin(); iter != added.end(); iter++)
497
for (std::list<unsigned int>::iterator iter = added.begin(); iter != added.end(); ++iter)
487
499
unsigned int &pos = *iter;
488
500
if (pos >= (unsigned int)item)
573
585
// j is the offset the index has to be adjusted
575
for (std::list<unsigned int>::const_iterator iter = removedItems.begin(); iter != removedItems.end(); iter++, j++)
587
for (std::list<unsigned int>::const_iterator iter = removedItems.begin(); iter != removedItems.end(); ++iter, ++j)
577
589
if (*iter > index)
643
655
wxASSERT(!toRemove);
644
656
wxASSERT(removedIndexes.size() == removed);
645
for (std::list<int>::iterator iter = removedIndexes.begin(); iter != removedIndexes.end(); iter++)
657
for (std::list<int>::iterator iter = removedIndexes.begin(); iter != removedIndexes.end(); ++iter)
647
659
m_indexMapping.erase(m_indexMapping.begin() + *iter);
684
696
wxASSERT(pDirectoryListing->GetCount() == m_pDirectoryListing->GetCount());
685
697
if (pDirectoryListing->GetCount() != m_pDirectoryListing->GetCount())
688
700
m_pDirectoryListing = pDirectoryListing;
690
702
// We don't have to do anything
756
768
if (m_pFilelistStatusBar)
758
770
m_pFilelistStatusBar->UnselectAll();
759
m_pFilelistStatusBar->SetConnected(pDirectoryListing);
771
m_pFilelistStatusBar->SetConnected(pDirectoryListing);
762
774
m_pDirectoryListing = pDirectoryListing;
1404
1416
pMenu->Enable(XRCID("ID_EDIT"), false);
1405
1417
pMenu->Enable(XRCID("ID_GETURL"), false);
1406
1418
pMenu->Enable(XRCID("ID_CONTEXT_REFRESH"), false);
1419
pMenu->Enable(XRCID("ID_NEW_FILE"), false);
1408
1421
else if ((GetItemCount() && GetItemState(0, wxLIST_STATE_SELECTED)))
1688
1701
wxString question;
1689
1702
if (!count_dirs)
1690
question.Printf(wxPLURAL("Really delete %d file?", "Really delete %d files?", count_files), count_files);
1703
question.Printf(wxPLURAL("Really delete %d file from the server?", "Really delete %d files from the server?", count_files), count_files);
1691
1704
else if (!count_files)
1692
question.Printf(wxPLURAL("Really delete %d directory with its contents?", "Really delete %d directories with their contents?", count_dirs), count_dirs);
1705
question.Printf(wxPLURAL("Really delete %d directory with its contents from the server?", "Really delete %d directories with their contents from the server?", count_dirs), count_dirs);
1695
1708
wxString files = wxString::Format(wxPLURAL("%d file", "%d files", count_files), count_files);
1696
1709
wxString dirs = wxString::Format(wxPLURAL("%d directory with its contents", "%d directories with their contents", count_dirs), count_dirs);
1697
question.Printf(_("Really delete %s and %s?"), files.c_str(), dirs.c_str());
1710
question.Printf(_("Really delete %s and %s from the server?"), files.c_str(), dirs.c_str());
1700
1713
if (wxMessageBox(question, _("Confirmation needed"), wxICON_QUESTION | wxYES_NO, this) != wxYES)
2235
2248
// Reselect previous items if neccessary.
2236
2249
// Sorting direction did not change. We just have to scan through items once
2237
2250
unsigned int i = 0;
2238
for (std::list<wxString>::const_iterator iter = selectedNames.begin(); iter != selectedNames.end(); iter++)
2251
for (std::list<wxString>::const_iterator iter = selectedNames.begin(); iter != selectedNames.end(); ++iter)
2240
2253
while (++i < m_indexMapping.size())
3137
3150
m_pState->ChangeRemoteDir(m_pDirectoryListing->path, _T(".."));
3154
void CRemoteListView::OnMenuNewfile(wxCommandEvent& event)
3156
if (!m_pState->IsRemoteIdle())
3163
if (!dlg.Create(this, _("Create empty file"), _("Please enter the name of the file which should be created:")))
3166
if (dlg.ShowModal() != wxID_OK)
3169
if (dlg.GetValue() == _T(""))
3175
wxString newFileName = dlg.GetValue();
3177
// Copied from elsewhere in the source, checks for characters that Windows deems invalid
3178
if ((newFileName.Find('/') != -1) ||
3179
(newFileName.Find('\\') != -1) ||
3180
(newFileName.Find(':') != -1) ||
3181
(newFileName.Find('*') != -1) ||
3182
(newFileName.Find('?') != -1) ||
3183
(newFileName.Find('"') != -1) ||
3184
(newFileName.Find('<') != -1) ||
3185
(newFileName.Find('>') != -1) ||
3186
(newFileName.Find('|') != -1))
3188
wxMessageBox(_("Filename may not contain any of the following characters: / \\ : * ? \" < > |"), _("Invalid filename"), wxICON_EXCLAMATION);
3192
// Check if target file already exists
3193
for (unsigned int i = 0; i < m_pDirectoryListing->GetCount(); i++)
3195
if (newFileName == (*m_pDirectoryListing)[i].name)
3197
wxMessageBox(_("Target filename already exists!"));
3202
CEditHandler* edithandler = CEditHandler::Get(); // Used to get the temporary folder
3204
wxString emptyfile_name = _T("empty_file_yq744zm");
3205
wxString emptyfile = edithandler->GetLocalDirectory() + emptyfile_name;
3207
// Create the empty temporary file
3211
file.Create(emptyfile);
3214
const CServer* pServer = m_pState->GetServer();
3221
CFileTransferCommand *cmd = new CFileTransferCommand(emptyfile, m_pDirectoryListing->path, newFileName, false, CFileTransferCommand::t_transferSettings());
3222
m_pState->m_pCommandQueue->ProcessCommand(cmd);