本文整理汇总了C++中CFileItem::Download方法的典型用法代码示例。如果您正苦于以下问题:C++ CFileItem::Download方法的具体用法?C++ CFileItem::Download怎么用?C++ CFileItem::Download使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFileItem
的用法示例。
在下文中一共展示了CFileItem::Download方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIdleChild
CFileItem* CServerItem::GetIdleChild(bool immediateOnly, enum TransferDirection direction)
{
int i = 0;
for (i = (PRIORITY_COUNT - 1); i >= 0; i--)
{
std::list<CFileItem*>& fileList = m_fileList[1][i];
for (std::list<CFileItem*>::iterator iter = fileList.begin(); iter != fileList.end(); iter++)
{
CFileItem* item = *iter;
if (item->IsActive())
continue;
if (direction == both)
return item;
if (direction == download)
{
if (item->Download())
return item;
}
else if (!item->Download())
return item;
}
}
if (immediateOnly)
return 0;
for (i = (PRIORITY_COUNT - 1); i >= 0; i--)
{
std::list<CFileItem*>& fileList = m_fileList[0][i];
for (std::list<CFileItem*>::iterator iter = fileList.begin(); iter != fileList.end(); iter++)
{
CFileItem* item = *iter;
if (item->IsActive())
continue;
if (direction == both)
return item;
if (direction == download)
{
if (item->Download())
return item;
}
else if (!item->Download())
return item;
}
}
return 0;
}
示例2: SetDefaultFileExistsAction
void CServerItem::SetDefaultFileExistsAction(CFileExistsNotification::OverwriteAction action, const TransferDirection direction)
{
for (auto iter = m_children.begin() + m_removed_at_front; iter != m_children.end(); ++iter) {
CQueueItem *pItem = *iter;
if (pItem->GetType() == QueueItemType::File) {
CFileItem* pFileItem = ((CFileItem *)pItem);
if (direction == TransferDirection::upload && pFileItem->Download())
continue;
else if (direction == TransferDirection::download && !pFileItem->Download())
continue;
pFileItem->m_defaultFileExistsAction = action;
}
}
}
示例3: SetDefaultFileExistsAction
void CServerItem::SetDefaultFileExistsAction(enum CFileExistsNotification::OverwriteAction action, const enum TransferDirection direction)
{
for (std::vector<CQueueItem*>::iterator iter = m_children.begin() + m_removed_at_front; iter != m_children.end(); iter++)
{
CQueueItem *pItem = *iter;
if (pItem->GetType() == QueueItemType_File)
{
CFileItem* pFileItem = ((CFileItem *)pItem);
if (direction == upload && pFileItem->Download())
continue;
else if (direction == download && !pFileItem->Download())
continue;
pFileItem->m_defaultFileExistsAction = action;
}
else if (pItem->GetType() == QueueItemType_FolderScan)
{
if (direction == download)
continue;
((CFolderScanItem *)pItem)->m_defaultFileExistsAction = action;
}
}
}
示例4: SaveLocalPath
bool CQueueStorage::Impl::SaveFile(wxLongLong server, const CFileItem& file)
{
if (file.m_edit != CEditHandler::none)
return true;
Bind(insertFileQuery_, file_table_column_names::source_file, file.GetSourceFile());
auto const& targetFile = file.GetTargetFile();
if (targetFile)
Bind(insertFileQuery_, file_table_column_names::target_file, *targetFile);
else
BindNull(insertFileQuery_, file_table_column_names::target_file);
int64_t localPathId = SaveLocalPath(file.GetLocalPath());
int64_t remotePathId = SaveRemotePath(file.GetRemotePath());
if (localPathId == -1 || remotePathId == -1)
return false;
Bind(insertFileQuery_, file_table_column_names::local_path, localPathId);
Bind(insertFileQuery_, file_table_column_names::remote_path, remotePathId);
Bind(insertFileQuery_, file_table_column_names::download, file.Download() ? 1 : 0);
if (file.GetSize() != -1)
Bind(insertFileQuery_, file_table_column_names::size, file.GetSize());
else
BindNull(insertFileQuery_, file_table_column_names::size);
if (file.m_errorCount)
Bind(insertFileQuery_, file_table_column_names::error_count, file.m_errorCount);
else
BindNull(insertFileQuery_, file_table_column_names::error_count);
Bind(insertFileQuery_, file_table_column_names::priority, static_cast<int>(file.GetPriority()));
Bind(insertFileQuery_, file_table_column_names::ascii_file, file.Ascii() ? 1 : 0);
if (file.m_defaultFileExistsAction != CFileExistsNotification::unknown)
Bind(insertFileQuery_, file_table_column_names::default_exists_action, file.m_defaultFileExistsAction);
else
BindNull(insertFileQuery_, file_table_column_names::default_exists_action);
int res;
do {
res = sqlite3_step(insertFileQuery_);
} while (res == SQLITE_BUSY);
sqlite3_reset(insertFileQuery_);
return res == SQLITE_DONE;
}
示例5: OnRequeueSelected
void CQueueViewFailed::OnRequeueSelected(wxCommandEvent& event)
{
#ifndef __WXMSW__
// GetNextItem is O(n) if nothing is selected, GetSelectedItemCount() is O(1)
if (!GetSelectedItemCount())
return;
#endif
bool failedToRequeueAll = false;
std::list<CQueueItem*> selectedItems;
long item = -1;
long skipTo = -1;
while (true)
{
item = GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (item == -1)
break;
SetItemState(item, 0, wxLIST_STATE_SELECTED);
if (item < skipTo)
continue;
CQueueItem* pItem = GetQueueItem(item);
if (pItem->GetType() == QueueItemType_Server)
skipTo = item + pItem->GetChildrenCount(true) + 1;
selectedItems.push_back(GetQueueItem(item));
}
if (selectedItems.empty())
return;
CQueueView* pQueueView = m_pQueue->GetQueueView();
while (!selectedItems.empty())
{
CQueueItem* pItem = selectedItems.front();
selectedItems.pop_front();
if (pItem->GetType() == QueueItemType_Server)
{
CServerItem* pOldServerItem = (CServerItem*)pItem;
CServerItem* pServerItem = pQueueView->CreateServerItem(pOldServerItem->GetServer());
unsigned int childrenCount = pOldServerItem->GetChildrenCount(false);
for (unsigned int i = 0; i < childrenCount; i++)
{
CFileItem* pFileItem = (CFileItem*)pItem->GetChild(i, false);
pFileItem->m_errorCount = 0;
pFileItem->m_statusMessage.Clear();
if (!pFileItem->Download() && !wxFileName::FileExists(pFileItem->GetLocalFile()))
{
failedToRequeueAll = true;
RemoveItem(pItem, true, false, false);
continue;
}
if (pFileItem->m_edit == CEditHandler::remote)
{
CEditHandler* pEditHandler = CEditHandler::Get();
if (!pEditHandler)
{
failedToRequeueAll = true;
delete pFileItem;
continue;
}
enum CEditHandler::fileState state = pEditHandler->GetFileState(pFileItem->GetRemoteFile(), pFileItem->GetRemotePath(), pServerItem->GetServer());
if (state == CEditHandler::unknown)
{
wxASSERT(pFileItem->Download());
wxString file = pFileItem->GetRemoteFile();
if (!pEditHandler->AddFile(CEditHandler::remote, file, pFileItem->GetRemotePath(), pServerItem->GetServer()))
{
failedToRequeueAll = true;
delete pFileItem;
continue;
}
pFileItem->SetLocalFile(file);
}
else if (state == CEditHandler::upload_and_remove_failed)
{
wxASSERT(!pFileItem->Download());
if (!pEditHandler->UploadFile(pFileItem->GetRemoteFile(), pFileItem->GetRemotePath(), pServerItem->GetServer(), true))
failedToRequeueAll = true;
delete pFileItem;
continue;
}
else
{
failedToRequeueAll = true;
delete pFileItem;
continue;
}
}
pFileItem->SetParent(pServerItem);
pQueueView->InsertItem(pServerItem, pFileItem);
}
m_fileCount -= childrenCount;
m_itemCount -= childrenCount + 1;
//.........这里部分代码省略.........
示例6: OnGetItemText
wxString CQueueViewBase::OnGetItemText(long item, long column) const
{
CQueueViewBase* pThis = const_cast<CQueueViewBase*>(this);
CQueueItem* pItem = pThis->GetQueueItem(item);
if (!pItem)
return _T("");
switch (pItem->GetType())
{
case QueueItemType_Server:
{
CServerItem* pServerItem = reinterpret_cast<CServerItem*>(pItem);
if (!column)
return pServerItem->GetName();
}
break;
case QueueItemType_File:
{
CFileItem* pFileItem = reinterpret_cast<CFileItem*>(pItem);
switch (column)
{
case 0:
return pFileItem->GetIndent() + pFileItem->GetLocalFile();
case 1:
if (pFileItem->Download())
if (pFileItem->Queued())
return _T("<--");
else
return _T("<<--");
else
if (pFileItem->Queued())
return _T("-->");
else
return _T("-->>");
break;
case 2:
return pFileItem->GetRemotePath().FormatFilename(pFileItem->GetRemoteFile());
case 3:
{
const wxLongLong& size = pFileItem->GetSize();
if (size >= 0)
return FormatSize(size);
else
return _T("?");
}
case 4:
switch (pFileItem->GetPriority())
{
case 0:
return _("Lowest");
case 1:
return _("Low");
default:
case 2:
return _("Normal");
case 3:
return _("High");
case 4:
return _("Highest");
}
break;
case 5:
return pFileItem->m_statusMessage;
default:
break;
}
}
break;
case QueueItemType_FolderScan:
{
CFolderScanItem* pFolderItem = reinterpret_cast<CFolderScanItem*>(pItem);
switch (column)
{
case 0:
return _T(" ") + pFolderItem->GetLocalPath();
case 1:
if (pFolderItem->Download())
if (pFolderItem->Queued())
return _T("<--");
else
return _T("<<--");
else
if (pFolderItem->Queued())
return _T("-->");
else
return _T("-->>");
break;
case 2:
return pFolderItem->GetRemotePath().GetPath();
case 5:
return pFolderItem->m_statusMessage;
default:
break;
}
}
break;
case QueueItemType_Folder:
{
CFileItem* pFolderItem = reinterpret_cast<CFolderItem*>(pItem);
//.........这里部分代码省略.........
示例7: OnGetItemText
wxString CQueueViewBase::OnGetItemText(CQueueItem* pItem, ColumnId column) const
{
switch (pItem->GetType())
{
case QueueItemType::Server:
{
CServerItem* pServerItem = reinterpret_cast<CServerItem*>(pItem);
if (!column)
return pServerItem->GetName();
}
break;
case QueueItemType::File:
{
CFileItem* pFileItem = reinterpret_cast<CFileItem*>(pItem);
switch (column)
{
case colLocalName:
return pFileItem->GetIndent() + pFileItem->GetLocalPath().GetPath() + pFileItem->GetLocalFile();
case colDirection:
if (pFileItem->Download())
if (pFileItem->queued())
return _T("<--");
else
return _T("<<--");
else
if (pFileItem->queued())
return _T("-->");
else
return _T("-->>");
break;
case colRemoteName:
return pFileItem->GetRemotePath().FormatFilename(pFileItem->GetRemoteFile());
case colSize:
{
const wxLongLong& size = pFileItem->GetSize();
if (size >= 0)
return CSizeFormat::Format(size);
else
return _T("?");
}
case colPriority:
switch (pFileItem->GetPriority())
{
case QueuePriority::lowest:
return _("Lowest");
case QueuePriority::low:
return _("Low");
default:
case QueuePriority::normal:
return _("Normal");
case QueuePriority::high:
return _("High");
case QueuePriority::highest:
return _("Highest");
}
break;
case colTransferStatus:
case colErrorReason:
return pFileItem->m_statusMessage;
case colTime:
return CTimeFormat::FormatDateTime(pItem->GetTime());
default:
break;
}
}
break;
case QueueItemType::FolderScan:
{
CFolderScanItem* pFolderItem = reinterpret_cast<CFolderScanItem*>(pItem);
switch (column)
{
case colLocalName:
return _T(" ") + pFolderItem->GetLocalPath().GetPath();
case colDirection:
if (pFolderItem->Download())
if (pFolderItem->queued())
return _T("<--");
else
return _T("<<--");
else
if (pFolderItem->queued())
return _T("-->");
else
return _T("-->>");
break;
case colRemoteName:
return pFolderItem->GetRemotePath().GetPath();
case colTransferStatus:
case colErrorReason:
return pFolderItem->m_statusMessage;
case colTime:
return CTimeFormat::FormatDateTime(pItem->GetTime());
default:
break;
}
}
break;
case QueueItemType::Folder:
{
CFileItem* pFolderItem = reinterpret_cast<CFolderItem*>(pItem);
//.........这里部分代码省略.........