/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t M a g i c k R e s o u r c e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListMagickResourceInfo() lists the resource info to a file. % % The format of the ListMagickResourceInfo method is: % % MagickBooleanType ListMagickResourceInfo(FILE *file, % ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: Return any errors or warnings in this structure. % % */ MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *exception) { char area_limit[MaxTextExtent], disk_limit[MaxTextExtent], file_limit[MaxTextExtent], map_limit[MaxTextExtent], memory_limit[MaxTextExtent]; if (file == (const FILE *) NULL) file=stdout; AcquireSemaphoreInfo(&resource_semaphore); FormatSize(MegabytesToBytes(resource_info.area_limit),area_limit); FormatSize(GigabytesToBytes(resource_info.disk_limit),disk_limit); FormatSize((MagickSizeType) resource_info.file_limit,file_limit); FormatSize(MegabytesToBytes(resource_info.map_limit),map_limit); FormatSize(MegabytesToBytes(resource_info.memory_limit),memory_limit); (void) fprintf(file,"File Area Memory Map Disk\n"); (void) fprintf(file,"------------------------------------------------\n"); (void) fprintf(file,"%4s %10s %10s %10s %10s\n",file_limit,area_limit, memory_limit,map_limit,disk_limit); (void) fflush(file); RelinquishSemaphoreInfo(resource_semaphore); return(MagickTrue); }
void ZoneViewWindow::Update(const Zone &zone) { SizeBuffer buf[5]; QString self; FormatSize(buf[0], zone.numBytes); FormatSize(buf[1], zone.overhead); FormatSize(buf[2], zone.small); FormatSize(buf[3], zone.large); FormatSize(buf[4], zone.high); self.sprintf("Self: B(%s), O(%s), A(%d), S(%s), L(%s), H(%s)", buf[0], buf[1], (int)zone.count.get(), buf[2], buf[3], buf[4]); QString total; FormatSize(buf[0], zone.totalBytes); FormatSize(buf[1], zone.totalOverhead); FormatSize(buf[2], zone.totalSmall); FormatSize(buf[3], zone.totalLarge); FormatSize(buf[4], zone.totalHigh); total.sprintf("Total: B(%s), O(%s), A(%d), S(%s), L(%s), H(%s)", buf[0], buf[1], (int)zone.totalCount.get(), buf[2], buf[3], buf[4]); QString title = "<" + QString(zone.name) + ">: " + total + "|" + self; QTreeWidgetItem *item; ZoneMap::iterator it = m_items.find(&zone); if (it == m_items.end()) { QTreeWidgetItem *parent = 0; if (zone.parent) { it = m_items.find(zone.parent); RAD_ASSERT(it != m_items.end()); parent = it->second; } item = new QTreeWidgetItem(QStringList(title)); if (parent) parent->addChild(item); else m_tree->addTopLevelItem(item); m_items[&zone] = item; } else { item = it->second; item->setData(0, Qt::DisplayRole, title); } for (Zone *z = zone.head; z; z = z->next) Update(*z); }
void CRemoteFileDialog::OnChangeView(UINT nCmdID) { int nView = VIEWS[nCmdID - ID_VIEW_SMALLICON]; int nPrevView = (m_lcFiles.GetStyle() & LVS_TYPEMASK); m_lcFiles.ModifyStyle(nPrevView, nView); if (!m_bInitReport && nView == LVS_REPORT) { // add all the other column info that has not been added yet // because the header control was not created int nItem = m_lcFiles.GetItemCount(); while (nItem--) { int nID = m_lcFiles.GetItemData(nItem); FILEITEM fi; VERIFY(m_mapItems.Lookup(nID, fi)); if (fi.nType == RFDT_FILE) { m_lcFiles.SetItemText(nItem, 1, FormatSize(fi.dwSize)); m_lcFiles.SetItemText(nItem, 2, FormatDate(fi.dLastMod)); } } m_bInitReport = TRUE; } }
int CRemoteFileDialog::AddFileItem(LPCTSTR szFileName, int nType, UINT nUniqueID, DWORD dwFileSize, const FILETIME* pLastMod, int nImage) { if (nImage == -1) { nImage = CSysImageList().GetFileImageIndex(szFileName); } int nItem = m_lcFiles.InsertItem(LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM, 0, szFileName, 0, 0, nImage, nUniqueID); // add to map FILEITEM fi; fi.sFilename = szFileName; fi.nType = nType; fi.dwSize = dwFileSize; if (pLastMod) { FILETIME ftLocal; FileTimeToLocalFileTime(pLastMod, &ftLocal); fi.dLastMod = COleDateTime(ftLocal); } m_mapItems[nUniqueID] = fi; // add size and date item if a file if (nType == RFDT_FILE && m_bInitReport) { m_lcFiles.SetItemText(nItem, 1, FormatSize(fi.dwSize)); m_lcFiles.SetItemText(nItem, 2, FormatDate(fi.dLastMod)); } return nItem; }
EDA_GRAPHIC_TEXT_CTRL::EDA_GRAPHIC_TEXT_CTRL( wxWindow* parent, const wxString& Title, const wxString& TextToEdit, int textsize, EDA_UNITS_T user_unit, wxBoxSizer* BoxSizer, int framelen ) { m_UserUnit = user_unit; m_Title = NULL; m_Title = new wxStaticText( parent, -1, Title ); BoxSizer->Add( m_Title, 0, wxGROW | wxLEFT | wxRIGHT | wxTOP, 5 ); m_FrameText = new wxTextCtrl( parent, -1, TextToEdit ); BoxSizer->Add( m_FrameText, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); if( !Title.IsEmpty() ) { wxString msg; msg.Printf( _( "Size%s" ), GetChars( ReturnUnitSymbol( m_UserUnit ) ) ); wxStaticText* text = new wxStaticText( parent, -1, msg ); BoxSizer->Add( text, 0, wxGROW | wxLEFT | wxRIGHT, 5 ); } wxString value = FormatSize( m_UserUnit, textsize ); m_FrameSize = new wxTextCtrl( parent, -1, value, wxDefaultPosition, wxSize( 70, -1 ) ); BoxSizer->Add( m_FrameSize, 0, wxGROW | wxLEFT | wxRIGHT | wxBOTTOM, 5 ); }
void BaseExecutionContext::debuggerInfo(InfoVec &info) { if (m_maxMemory <= 0) { Add(info, "Max Memory", "(unlimited)"); } else { Add(info, "Max Memory", FormatSize(m_maxMemory)); } Add(info, "Max Time", FormatTime(m_maxTime * 1000)); }
wxString Internat::FormatSize(wxLongLong size) { /* wxLongLong contains no built-in conversion to double */ double dSize = size.GetHi() * pow(2.0, 32); // 2 ^ 32 dSize += size.GetLo(); return FormatSize(dSize); }
DirectoriesPrefs::DirectoriesPrefs(wxWindow * parent): PrefsPanel(parent) { mTempDir = gPrefs->Read("/Directories/TempDir", ""); mOldTempDir = mTempDir; topSizer = new wxBoxSizer( wxVERTICAL ); wxStaticBoxSizer *tempDirSizer = new wxStaticBoxSizer( new wxStaticBox(this, -1, _("Temp. Directory")), wxVERTICAL ); wxFlexGridSizer *tempDirGridSizer = new wxFlexGridSizer( 0, 3, 0, 0 ); mTempDirLabel = new wxStaticText( this, -1, _("Location:"), wxDefaultPosition, wxDefaultSize, wxALIGN_RIGHT ); /* Order is important here: mFreeSpace must be allocated before mTempDirText, so that the handler doesn't try to operate on mFreeSpace before it exists! */ mFreeSpace = new wxStaticText( this, -1, FormatSize(GetFreeDiskSpace((char *) (const char *) mTempDir)), wxDefaultPosition, wxDefaultSize, 0 ); mTempDirText = NULL; mTempDirText = new wxTextCtrl( this, TempDirID, mTempDir, wxDefaultPosition, wxSize(160, -1), 0 ); mFreeSpaceLabel = new wxStaticText( this, -1, _("Free Space:"), wxDefaultPosition, wxDefaultSize, 0 ); wxButton *chooseButton = new wxButton(this, ChooseButtonID, _("Choose...")); tempDirGridSizer->Add( mTempDirLabel, 0, wxALIGN_LEFT|wxALL|wxALIGN_CENTER_VERTICAL, 2 ); tempDirGridSizer->Add( mTempDirText, 1, wxGROW|wxALL|wxALIGN_CENTER_VERTICAL, 2 ); tempDirGridSizer->Add( chooseButton, 0, wxALL|wxALIGN_CENTER_VERTICAL, 2 ); tempDirGridSizer->Add( mFreeSpaceLabel, 0, wxALIGN_LEFT|wxALL|wxALIGN_CENTER_VERTICAL, 2 ); tempDirGridSizer->Add( mFreeSpace, 0, wxGROW|wxALL|wxALIGN_CENTER_VERTICAL, 2 ); tempDirGridSizer->AddGrowableCol(1); tempDirSizer->Add( tempDirGridSizer, 0, wxGROW|wxALL, 2 ); topSizer->Add( tempDirSizer, 0, wxGROW|wxALL, 5 ); outSizer = new wxBoxSizer( wxVERTICAL ); outSizer->Add(topSizer, 0, wxGROW|wxALL, TOP_LEVEL_BORDER); SetAutoLayout(true); SetSizer(outSizer); outSizer->Fit(this); outSizer->SetSizeHints(this); }
void Transport::debuggerInfo(InfoVec &info) { Add(info, "Thread Type", getThreadTypeName()); Add(info, "URL", getCommand()); Add(info, "HTTP", getHTTPVersion()); Add(info, "Method", getMethodName()); if (getMethod() == Method::POST) { int size; getPostData(size); Add(info, "Post Data", FormatSize(size)); } }
int CFileBrowserListCtrl::CalcMinColumnWidth(int Col) { enum { BORDER = 6, // minimal spacing; less causes abbreviated text SLACK = 3 // prevents widest item from touching right edge }; CWaitCursor wc; // iterating all items can be slow, especially for file type CClientDC dc(this); HGDIOBJ PrevFont = dc.SelectObject(GetFont()); // must use list control's font int width = 0; CSize sz; CFileInfo FileInfo; CString str; int items = m_DirList.GetCount(); for (int i = 0; i < items; i++) { const CDirItem& item = m_DirList.GetItem(i); switch (Col) { case COL_NAME: str = item.GetName(); break; case COL_SIZE: if (item.IsDir()) continue; FormatSize(item.GetLength(), str); break; case COL_TYPE: // slow if we have many unique file types that aren't cached m_FileInfoCache.GetFileInfo(GetFolder(), item, FileInfo); str = FileInfo.GetTypeName(); break; case COL_MODIFIED: if (item.GetLastWrite() == 0) continue; FormatTime(item.GetLastWrite(), str); break; default: ASSERT(0); } GetTextExtentPoint32(dc.m_hDC, str, str.GetLength(), &sz); if (sz.cx > width) width = sz.cx; } dc.SelectObject(PrevFont); // restore DC's previous font // 25feb09: GetItemRect can fail e.g. if list is empty, in which case we // must avoid adding garbage to column width CRect IconRect; if (GetItemRect(0, IconRect, LVIR_ICON)) width += IconRect.Width(); else // can't get item rect, fall back to system metrics width += GetSystemMetrics(m_ViewType == VTP_ICON ? SM_CXICON : SM_CXSMICON); width += BORDER + SLACK; return(width); }
void COptionsPageSizeFormatting::UpdateExamples() { XRCCTRL(*this, "ID_EXAMPLE1", wxStaticText)->SetLabel(FormatSize(12)); XRCCTRL(*this, "ID_EXAMPLE2", wxStaticText)->SetLabel(FormatSize(100)); XRCCTRL(*this, "ID_EXAMPLE3", wxStaticText)->SetLabel(FormatSize(1234)); XRCCTRL(*this, "ID_EXAMPLE4", wxStaticText)->SetLabel(FormatSize(1058817)); XRCCTRL(*this, "ID_EXAMPLE5", wxStaticText)->SetLabel(FormatSize(123456789)); XRCCTRL(*this, "ID_EXAMPLE6", wxStaticText)->SetLabel(FormatSize(wxLongLong(0x39E9, 0x4F995A72))); GetSizer()->Layout(); }
void CTaskProgressWnd::OnThreadUpdate(PTaskProgress pTaskProgress) { // Обновим надписи на форме в соответствии с прогрессом выполнения задачи SetDlgItemText(m_hWindow, IDC_PROCEED_FOLDERS, FormatC(TEXT("Обработано папок: %d"), pTaskProgress->dwProceedFolders)); SetDlgItemText(m_hWindow, IDC_PROCEED_FILES, FormatC(TEXT("Обработано файлов: %d"), pTaskProgress->dwProceedFiles)); SetDlgItemText(m_hWindow, IDC_INCLUDED_FILES, FormatC(TEXT("Скопировано файлов: %d"), pTaskProgress->dwIncludedFiles)); SetDlgItemText(m_hWindow, IDC_EXCLUDED_FILES, FormatC(TEXT("Пропущено файлов: %d"), pTaskProgress->dwExcludedFiles)); SetDlgItemText(m_hWindow, IDC_ERRORS, FormatC(TEXT("Ошибок: %d"), pTaskProgress->dwErrors)); SetDlgItemText(m_hWindow, IDC_FINISHED_BYTES, FormatC(TEXT("Скопировано: %s"), FormatSize(pTaskProgress->i64FinishedBytes).C())); // Отобразим процент выполнения в виде progress bar SendDlgItemMessage(m_hWindow, IDC_PROGRESS, PBM_SETPOS, pTaskProgress->bPercents, 0); // Если это последнее обновление информации - запомним кол-во скопированных байт для статистики if (pTaskProgress->bLastInfo) m_pTask->GetPTaskInfo()->i64FinishedBytes += pTaskProgress->i64FinishedBytes; }
void CFileBrowserListCtrl::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult) { NMLVDISPINFO* pDispInfo = (NMLVDISPINFO*)pNMHDR; LVITEM& ListItem = pDispInfo->item; int ItemIdx = ListItem.iItem; if (ItemIdx < m_DirList.GetCount()) { const CDirItem& DirItem = m_DirList.GetItem(ItemIdx); if (ItemIdx != m_CachedItemIdx) { // if item isn't cached m_FileInfoCache.GetFileInfo(GetFolder(), DirItem, m_MRUFileInfo); m_CachedItemIdx = ItemIdx; } if (ListItem.mask & LVIF_TEXT) { switch (ListItem.iSubItem) { case COL_NAME: _tcscpy(ListItem.pszText, DirItem.GetName()); break; case COL_SIZE: if (!DirItem.IsDir()) { CString s; if (FormatSize(DirItem.GetLength(), s)) _tcscpy(ListItem.pszText, s); } break; case COL_TYPE: _tcscpy(ListItem.pszText, m_MRUFileInfo.GetTypeName()); break; case COL_MODIFIED: if (DirItem.GetLastWrite() > 0) { CString s; if (FormatTime(DirItem.GetLastWrite(), s)) _tcscpy(ListItem.pszText, s); } break; default: ASSERT(0); } } if (ListItem.mask & LVIF_IMAGE) { ListItem.iImage = m_MRUFileInfo.GetIconIdx(); } } *pResult = 0; }
void DirectoriesPrefs::UpdateFreeSpace(wxCommandEvent &event) { static wxLongLong space; static wxString tempDir; static char tmp[200]; tempDir = event.GetString(); #ifndef __WXMAC__ // the mac GetFreeDiskSpace routine does this automatically /* Try to be smart: if the directory doesn't exist, go up the * directory path until one is, because that's the volume that * the new directory would be created on */ while(!wxDirExists(tempDir) && tempDir.Find(wxFILE_SEP_PATH) != -1) tempDir = tempDir.BeforeLast(wxFILE_SEP_PATH); #endif strncpy(tmp, tempDir.c_str(), 200); space = GetFreeDiskSpace(tmp); mFreeSpace->SetLabel(FormatSize(space)); }
void MythUIFileBrowser::PathSelected(MythUIButtonListItem *item) { if (!item) return; if (m_previewImage) m_previewImage->Reset(); MFileInfo finfo = item->GetData().value<MFileInfo>(); if (finfo.isParentDir()) { if (m_infoText) m_infoText->Reset(); if (m_filenameText) m_filenameText->Reset(); if (m_fullpathText) m_fullpathText->Reset(); } else { if (IsImage(finfo.suffix()) && m_previewImage) { m_previewImage->SetFilename(finfo.absoluteFilePath()); m_previewTimer->start(250); } if (m_infoText) m_infoText->SetText(FormatSize(finfo.size())); if (m_filenameText) m_filenameText->SetText(finfo.fileName()); if (m_fullpathText) m_fullpathText->SetText(finfo.absoluteFilePath()); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e l i n q u i s h M a g i c k R e s o u r c e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % RelinquishMagickResource() relinquishes resources of the specified type. % % The format of the RelinquishMagickResource() method is: % % void RelinquishMagickResource(const ResourceType type, % const MagickSizeType size) % % A description of each parameter follows: % % o type: The type of resource. % % o size: The size of the resource. % % */ MagickExport void RelinquishMagickResource(const ResourceType type, const MagickSizeType size) { char resource_current[MaxTextExtent], resource_limit[MaxTextExtent], resource_request[MaxTextExtent]; FormatSize(size,resource_request); AcquireSemaphoreInfo(&resource_semaphore); switch (type) { case AreaResource: { resource_info.area=size; FormatSize((MagickSizeType) resource_info.area,resource_current); FormatSize(MegabytesToBytes(resource_info.area_limit),resource_limit); break; } case MemoryResource: { resource_info.memory-=size; FormatSize((MagickSizeType) resource_info.memory,resource_current); FormatSize(MegabytesToBytes(resource_info.memory_limit),resource_limit); break; } case MapResource: { resource_info.map-=size; FormatSize((MagickSizeType) resource_info.map,resource_current); FormatSize(MegabytesToBytes(resource_info.map_limit),resource_limit); break; } case DiskResource: { resource_info.disk-=size; FormatSize((MagickSizeType) resource_info.disk,resource_current); FormatSize(GigabytesToBytes(resource_info.disk_limit),resource_limit); break; } case FileResource: { resource_info.file-=size; FormatSize((MagickSizeType) resource_info.file,resource_current); FormatSize((MagickSizeType) resource_info.file_limit,resource_limit); break; } default: break; } RelinquishSemaphoreInfo(resource_semaphore); (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s", MagickOptionToMnemonic(MagickResourceOptions,(long) type),resource_request, resource_current,resource_limit); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e M a g i c k R e s o u r c e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireMagickResource() acquires resources of the specified type. % MagickFalse is returned if the specified resource is exhausted otherwise % MagickTrue. % % The format of the AcquireMagickResource() method is: % % MagickBooleanType AcquireMagickResource(const ResourceType type, % const MagickSizeType size) % % A description of each parameter follows: % % o type: The type of resource. % % o size: The number of bytes needed from for this resource. % % */ MagickExport MagickBooleanType AcquireMagickResource(const ResourceType type, const MagickSizeType size) { char resource_current[MaxTextExtent], resource_limit[MaxTextExtent], resource_request[MaxTextExtent]; MagickBooleanType status; MagickSizeType limit; status=MagickFalse; FormatSize(size,resource_request); AcquireSemaphoreInfo(&resource_semaphore); switch (type) { case AreaResource: { resource_info.area=(MagickOffsetType) size; limit=MegabytesToBytes(resource_info.area_limit); status=(resource_info.area_limit == ResourceInfinity) || (size < limit) ? MagickTrue : MagickFalse; FormatSize((MagickSizeType) resource_info.area,resource_current); FormatSize(MegabytesToBytes(resource_info.area_limit),resource_limit); break; } case MemoryResource: { resource_info.memory+=size; limit=MegabytesToBytes(resource_info.memory_limit); status=(resource_info.memory_limit == ResourceInfinity) || ((MagickSizeType) resource_info.memory < limit) ? MagickTrue : MagickFalse; FormatSize((MagickSizeType) resource_info.memory,resource_current); FormatSize(MegabytesToBytes(resource_info.memory_limit),resource_limit); break; } case MapResource: { resource_info.map+=size; limit=MegabytesToBytes(resource_info.map_limit); status=(resource_info.map_limit == ResourceInfinity) || ((MagickSizeType) resource_info.map < limit) ? MagickTrue : MagickFalse; FormatSize((MagickSizeType) resource_info.map,resource_current); FormatSize(MegabytesToBytes(resource_info.map_limit),resource_limit); break; } case DiskResource: { resource_info.disk+=size; limit=GigabytesToBytes(resource_info.disk_limit); status=(resource_info.disk_limit == ResourceInfinity) || ((MagickSizeType) resource_info.disk < limit) ? MagickTrue : MagickFalse; FormatSize((MagickSizeType) resource_info.disk,resource_current); FormatSize(GigabytesToBytes(resource_info.disk_limit),resource_limit); break; } case FileResource: { resource_info.file+=size; limit=resource_info.file_limit; status=(resource_info.file_limit == ResourceInfinity) || ((MagickSizeType) resource_info.file < limit) ? MagickTrue : MagickFalse; FormatSize((MagickSizeType) resource_info.file,resource_current); FormatSize((MagickSizeType) resource_info.file_limit,resource_limit); break; } default: break; } RelinquishSemaphoreInfo(resource_semaphore); (void) LogMagickEvent(ResourceEvent,GetMagickModule(),"%s: %s/%s/%s", MagickOptionToMnemonic(MagickResourceOptions,(long) type),resource_request, resource_current,resource_limit); return(status); }
void CFilelistStatusBar::UpdateText() { wxString text; if (m_count_selected_files || m_count_selected_dirs) { if (!m_count_selected_files) text = wxString::Format(wxPLURAL("Selected %d directory.", "Selected %d directories.", m_count_selected_dirs), m_count_selected_dirs); else if (!m_count_selected_dirs) { const wxString size = FormatSize(m_total_selected_size, true); if (m_unknown_selected_size) text = wxString::Format(wxPLURAL("Selected %d file. Total size: At least %s", "Selected %d files. Total size: At least %s", m_count_selected_files), m_count_selected_files, size.c_str()); else text = wxString::Format(wxPLURAL("Selected %d file. Total size: %s", "Selected %d files. Total size: %s", m_count_selected_files), m_count_selected_files, size.c_str()); } else { const wxString files = wxString::Format(wxPLURAL("%d file", "%d files", m_count_selected_files), m_count_selected_files); const wxString dirs = wxString::Format(wxPLURAL("%d directory", "%d directories", m_count_selected_dirs), m_count_selected_dirs); const wxString size = FormatSize(m_total_selected_size, true); if (m_unknown_selected_size) text = wxString::Format(_("Selected %s and %s. Total size: At least %s"), files.c_str(), dirs.c_str(), size.c_str()); else text = wxString::Format(_("Selected %s and %s. Total size: %s"), files.c_str(), dirs.c_str(), size.c_str()); } } else if (m_count_files || m_count_dirs) { if (!m_count_files) text = wxString::Format(wxPLURAL("%d directory", "%d directories", m_count_dirs), m_count_dirs); else if (!m_count_dirs) { const wxString size = FormatSize(m_total_size, true); if (m_unknown_size) text = wxString::Format(wxPLURAL("%d file. Total size: At least %s", "%d files. Total size: At least %s", m_count_files), m_count_files, size.c_str()); else text = wxString::Format(wxPLURAL("%d file. Total size: %s", "%d files. Total size: %s", m_count_files), m_count_files, size.c_str()); } else { const wxString files = wxString::Format(wxPLURAL("%d file", "%d files", m_count_files), m_count_files); const wxString dirs = wxString::Format(wxPLURAL("%d directory", "%d directories", m_count_dirs), m_count_dirs); const wxString size = FormatSize(m_total_size, true); if (m_unknown_size) text = wxString::Format(_("%s and %s. Total size: At least %s"), files.c_str(), dirs.c_str(), size.c_str()); else text = wxString::Format(_("%s and %s. Total size: %s"), files.c_str(), dirs.c_str(), size.c_str()); } if (m_hidden) { text += ' '; text += wxString::Format(wxPLURAL("(%d object filtered)", "(%d objects filtered)", m_hidden), m_hidden); } } else { text = _("Empty directory."); if (m_hidden) { text += ' '; text += wxString::Format(wxPLURAL("(%d object filtered)", "(%d objects filtered)", m_hidden), m_hidden); } } SetStatusText(text); }
QwtText label(double value) const { return FormatSize(value); }
void VirtualListCtrlFT::OnGetdispinfo(NMHDR* pNMHDR, LRESULT* pResult) { LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR; LVITEM* pItem= &(pDispInfo->item); int index=pItem->iItem; // Valid text buffer? if (pItem->mask & LVIF_TEXT) { switch(pItem->iSubItem) { case SUB_REMOTE_IP: { unsigned int ip4=(v_data[index].m_remote_ip>>24)&0xFF; unsigned int ip3=(v_data[index].m_remote_ip>>16)&0xFF; unsigned int ip2=(v_data[index].m_remote_ip>>8)&0xFF; unsigned int ip1=(v_data[index].m_remote_ip>>0)&0xFF; sprintf(pItem->pszText,"%u.%u.%u.%u",ip1,ip2,ip3,ip4); break; } case SUB_MODULE: { _itoa(v_data[index].m_mod,pItem->pszText,10); break; } case SUB_SOCKET: { _itoa(v_data[index].m_sock,pItem->pszText,10); break; } case SUB_FILENAME: { strcpy(pItem->pszText,v_data[index].m_filename.c_str()); break; } case SUB_RANGE: { sprintf(pItem->pszText,"%s : %s",FormatSize(v_data[index].m_start).c_str(),FormatSize(v_data[index].m_end).c_str()); break; } case SUB_TOTAL_SIZE: { sprintf(pItem->pszText,"%s",FormatSize(v_data[index].m_total_size).c_str()); break; } case SUB_SENT: { sprintf(pItem->pszText,"%s / %s",FormatSize(v_data[index].m_num_sent).c_str(),FormatSize(v_data[index].m_end-v_data[index].m_start).c_str()); break; } case SUB_ELAPSED: { strcpy(pItem->pszText,FormatElapsed(v_data[index].m_time_elapsed).c_str()); break; } } } // Valid Image? if(pItem->mask & LVIF_IMAGE) { pItem->iImage=-1; } // Indent? if(pItem->mask & LVIF_INDENT) { pItem->iIndent=0; // always set the indent to 0 } // if(pItem->mask & LVIF_PARAM) { pItem->lParam=0; // always set the lParam to 0, since I don't know what it's for. Maybe it's the data. } // Always set the state to 0. because I don't know what else to do right now. if(pItem->mask & LVIF_STATE) { pItem->state=0; } *pResult = 0; }
//----------------------------------------------------------------------------- //! //----------------------------------------------------------------------------- void tFilepathSelector::UpdateList() { m_FilePathList.clear(); m_FriendlyFilepathList.clear(); m_DisplayList.clear(); m_pListWidget->clear(); // First add the NONE option, No need to translate (appears in settings.ini) m_FilePathList << "None"; m_FriendlyFilepathList << "None"; m_DisplayList << "None"; int currentRow = 0; // setCurrentRow to the currentFile // Add files from all locations for (int i = 0; i < m_PathAndDirNameList.size(); ++i) { tPathAndDirname pathAndDirname = m_PathAndDirNameList.at(i); QDir directory(pathAndDirname.Path(), "", m_SortFlags, m_Filters); directory.setNameFilters(m_NameFilters); QFileInfoList fileInfoList = directory.entryInfoList(); for (int j = 0; j < fileInfoList.size(); ++j) { QFileInfo fileInfo = fileInfoList.at(j); // Add the real filepath string to our list m_FilePathList.append(fileInfo.filePath()); // Add the user displayed filepath e.g. "Sonar.sl2 (factory)" const QString dirname = pathAndDirname.DirName(); QString friendlyFilepath; if (dirname.isEmpty()) { friendlyFilepath = fileInfo.fileName(); m_FriendlyFilepathList.append(friendlyFilepath); } else { friendlyFilepath = QString("%1 (%2)").arg(fileInfo.fileName()).arg(dirname); m_FriendlyFilepathList.append(friendlyFilepath); // compare currentFile to path and set currentRow if there is an exact match if (friendlyFilepath.compare(m_CurrentFile) == 0) { currentRow = j + 1; } } if (m_ShowFileSize) { QString item = QString("%1 (%2)").arg(friendlyFilepath).arg(FormatSize(fileInfo.size())); m_DisplayList << item; } else { m_DisplayList << friendlyFilepath; } } } m_pListWidget->addItems(m_DisplayList); if (m_CurrentFile.isEmpty()) { m_pListWidget->setCurrentRow(0); } else { m_pListWidget->setCurrentRow(currentRow); } }
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); switch (column) { case 0: if (pFolderItem->Download()) return pFolderItem->GetIndent() + pFolderItem->GetLocalFile(); break; 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: if (!pFolderItem->Download()) { if (pFolderItem->GetRemoteFile() == _T("")) return pFolderItem->GetRemotePath().GetPath(); else return pFolderItem->GetRemotePath().FormatFilename(pFolderItem->GetRemoteFile()); } break; case 4: switch (pFolderItem->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 pFolderItem->m_statusMessage; default: break; } } break; default: break; } return _T(""); }
bool CViewTransfers::SynchronizeCacheItem(wxInt32 iRowIndex, wxInt32 iColumnIndex) { wxString strDocumentText = wxEmptyString; wxString strDocumentText2 = wxEmptyString; float fDocumentFloat = 0.0; double fDocumentDouble = 0.0, fDocumentDouble2 = 0.0; CTransfer* transfer; bool bNeedRefresh = false; strDocumentText.Empty(); if (GetTransferCacheAtIndex(transfer, m_iSortedIndexes[iRowIndex])) { return false; } switch(iColumnIndex) { case COLUMN_PROJECT: GetDocProjectName(m_iSortedIndexes[iRowIndex], strDocumentText); GetDocProjectURL(m_iSortedIndexes[iRowIndex], strDocumentText2); if (!strDocumentText.IsSameAs(transfer->m_strProjectName) || !strDocumentText2.IsSameAs(transfer->m_strProjectURL)) { transfer->m_strProjectName = strDocumentText; transfer->m_strProjectURL = strDocumentText2; bNeedRefresh = true; } break; case COLUMN_FILE: GetDocFileName(m_iSortedIndexes[iRowIndex], strDocumentText); if (!strDocumentText.IsSameAs(transfer->m_strFileName)) { transfer->m_strFileName = strDocumentText; bNeedRefresh = true; } break; case COLUMN_PROGRESS: GetDocProgress(m_iSortedIndexes[iRowIndex], fDocumentFloat); if (fDocumentFloat != transfer->m_fProgress) { transfer->m_fProgress = fDocumentFloat; FormatProgress(fDocumentFloat, transfer->m_strProgress); bNeedRefresh = true; } break; case COLUMN_SIZE: GetDocBytesXferred(m_iSortedIndexes[iRowIndex], fDocumentDouble); GetDocTotalBytes(m_iSortedIndexes[iRowIndex], fDocumentDouble2); if (( fDocumentDouble != transfer->m_fBytesXferred) || (fDocumentDouble2 != transfer->m_fTotalBytes) ) { transfer->m_fBytesXferred = fDocumentDouble; transfer->m_fTotalBytes = fDocumentDouble2; FormatSize(fDocumentDouble, fDocumentDouble2, transfer->m_strSize); bNeedRefresh = true; } break; case COLUMN_TIME: GetDocTime(m_iSortedIndexes[iRowIndex], fDocumentDouble); if (fDocumentDouble != transfer->m_dTime) { transfer->m_dTime = fDocumentDouble; FormatTime(fDocumentDouble, transfer->m_strTime); bNeedRefresh = true; } break; case COLUMN_SPEED: GetDocSpeed(m_iSortedIndexes[iRowIndex], fDocumentDouble); if (fDocumentDouble != transfer->m_dSpeed) { transfer->m_dSpeed = fDocumentDouble; FormatSpeed(fDocumentDouble, transfer->m_strSpeed); bNeedRefresh = true; } break; case COLUMN_STATUS: GetDocStatus(m_iSortedIndexes[iRowIndex], strDocumentText); if (!strDocumentText.IsSameAs(transfer->m_strStatus)) { transfer->m_strStatus = strDocumentText; return true; } break; } return bNeedRefresh; }
void CViewTransfersGrid::OnListRender( wxTimerEvent& WXUNUSED(event) ) { wxInt32 docCount = GetDocCount(); // We haven't connected up to the CC yet, there is nothing to display, make sure // everything is deleted. if ( docCount <= 0 ) { if ( m_pGridPane->GetNumberRows() ) { m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows()); } return; } // Right-size the grid so that the number of rows matches // the document state. if(docCount != m_pGridPane->GetNumberRows()) { if (docCount > m_pGridPane->GetNumberRows()) { m_pGridPane->AppendRows(docCount - m_pGridPane->GetNumberRows()); } else { m_pGridPane->DeleteRows(0, m_pGridPane->GetNumberRows() - docCount); m_bForceUpdateSelection = true; } wxASSERT(docCount == m_pGridPane->GetNumberRows()); } m_bIgnoreUIEvents = true; m_pGridPane->SaveSelection(); m_bIgnoreUIEvents = false; //update cell values wxString strBuffer; int iMax = m_pGridPane->GetNumberRows(); for(int iRow = 0; iRow < iMax; iRow++) { FormatProjectName(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_PROJECT) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_PROJECT, strBuffer); } FormatFileName(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_FILE) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_FILE, strBuffer); } FormatProgress(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_PROGRESS) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_PROGRESS, strBuffer); m_pGridPane->SetCellAlignment(iRow, COLUMN_PROGRESS, wxALIGN_CENTRE, wxALIGN_CENTRE); } FormatSize(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_SIZE) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_SIZE, strBuffer); } FormatTime(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_TIME) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_TIME, strBuffer); } FormatSpeed(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_SPEED) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_SPEED, strBuffer); } strBuffer = wxEmptyString; FormatStatus(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_STATUS) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_STATUS, strBuffer); } FormatProjectURL(iRow, strBuffer); if (m_pGridPane->GetCellValue(iRow, COLUMN_HIDDEN_URL) != strBuffer) { m_pGridPane->SetCellValue(iRow, COLUMN_HIDDEN_URL, strBuffer); } } m_pGridPane->SortData(); m_bIgnoreUIEvents = true; m_pGridPane->RestoreSelection(); m_bIgnoreUIEvents = false; UpdateSelection(); }
void EDA_GRAPHIC_TEXT_CTRL::SetValue( int textSize ) { wxString value = FormatSize( m_UserUnit, textSize ); m_FrameSize->SetValue( value ); }
void HTTPINFO::print(std::ostream & s) { s << "State: " << GetString(state) << std::endl << "Total size: " << FormatSize(totalsize) << std::endl << "Downloaded: " << FormatSize(downloaded) << std::endl << "Speed: " << FormatSpeed(speed) << std::endl << "Error: " << (error.empty() ? "none" : error) << std::endl; }
void MythUIFileBrowser::updateLocalFileList() { QDir d; d.setPath(m_subDirectory); d.setNameFilters(m_nameFilter); d.setFilter(m_typeFilter); d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); if (!d.exists()) { LOG(VB_GENERAL, LOG_ERR, "MythUIFileBrowser: current directory does not exist!"); m_locationEdit->SetText("/"); m_subDirectory = "/"; d.setPath("/"); } QFileInfoList list = d.entryInfoList(); bool showBackButton = false; if (list.isEmpty()) { MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, tr("Parent Directory")); item->DisplayState("upfolder", "nodetype"); } else { QFileInfoList::const_iterator it = list.begin(); const QFileInfo *fi; while (it != list.end()) { fi = &(*it); MFileInfo finfo(fi->filePath()); if (finfo.fileName() == ".") { ++it; continue; } QString displayName = finfo.fileName(); QString type; if (displayName == "..") { if (m_subDirectory.endsWith("/")) { ++it; continue; } displayName = tr("Parent"); type = "upfolder"; showBackButton = true; } else if (finfo.isDir()) { type = "folder"; } else if (finfo.isExecutable()) { type = "executable"; } else if (finfo.isFile()) { type = "file"; } MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, displayName, qVariantFromValue(finfo)); if (IsImage(finfo.suffix())) { item->SetImage(finfo.absoluteFilePath()); type = "image"; } item->SetText(FormatSize(finfo.size()), "filesize"); item->SetText(finfo.absoluteFilePath(), "fullpath"); item->DisplayState(type, "nodetype"); ++it; } } if (m_backButton) m_backButton->SetEnabled(showBackButton); m_locationEdit->SetText(m_subDirectory); }
void MythUIFileBrowser::updateRemoteFileList() { QStringList sgdirlist; QString sgdir; QStringList slist; if (!m_baseDirectory.endsWith("/")) m_baseDirectory.append("/"); QString dirURL = QString("%1%2").arg(m_baseDirectory) .arg(m_subDirectory); if (!GetRemoteFileList(m_baseDirectory, sgdir, sgdirlist)) { LOG(VB_GENERAL, LOG_ERR, "GetRemoteFileList failed to get " "Storage Group dirs"); return; } if ((sgdirlist.size() == 1) && (sgdirlist[0].startsWith("sgdir::"))) { QStringList tokens = sgdirlist[0].split("::"); m_storageGroupDir = tokens[1]; } if (!GetRemoteFileList(dirURL, m_storageGroupDir, slist)) { LOG(VB_GENERAL, LOG_ERR, QString("GetRemoteFileList failed for '%1' in '%2' SG dir") .arg(dirURL).arg(m_storageGroupDir)); return; } m_locationEdit->SetText(dirURL); QString displayName; QString dataName; QString type; if ((sgdirlist.size() > 1 && !m_storageGroupDir.isEmpty()) || (!m_subDirectory.isEmpty())) { displayName = tr("Parent"); type = "upfolder"; m_parentDir = m_baseDirectory; if (!m_subDirectory.isEmpty()) { m_parentDir += "/" + m_subDirectory; int pos = m_parentDir.lastIndexOf('/'); if (pos > 0) m_parentDir = m_parentDir.left(pos); } MFileInfo finfo(m_parentDir, m_storageGroupDir, true); m_parentSGDir = m_storageGroupDir; if (m_subDirectory.isEmpty() && m_parentDir == m_baseDirectory) { finfo.setSGDir(""); m_parentSGDir = ""; } MythUIButtonListItem *item = new MythUIButtonListItem( m_fileList, displayName, qVariantFromValue(finfo)); item->SetText(QString("0"), "filesize"); item->SetText(m_parentDir, "fullpath"); item->DisplayState(type, "nodetype"); if (m_backButton) m_backButton->SetEnabled(true); } else { if (m_backButton) m_backButton->SetEnabled(false); } QStringList::const_iterator it = slist.begin(); while (it != slist.end()) { QStringList tokens = (*it).split("::"); if (tokens.size() < 2) { LOG(VB_GENERAL, LOG_ERR, QString("failed to parse '%1'.").arg(*it)); ++it; continue; } displayName = tokens[1]; if (tokens[0] == "sgdir") dataName = m_baseDirectory; else if (m_subDirectory.isEmpty()) dataName = QString("%1%2").arg(m_baseDirectory) .arg(displayName); else dataName = QString("%1%2/%3").arg(m_baseDirectory) .arg(m_subDirectory).arg(displayName); MFileInfo finfo(dataName, m_storageGroupDir); if ((tokens[0] == "dir") && (m_typeFilter & (QDir::Dirs | QDir::AllDirs))) { type = "folder"; finfo.setIsDir(true); finfo.setSGDir(m_storageGroupDir); finfo.setSize(0); } else if ((tokens[0] == "sgdir") && (m_typeFilter & (QDir::Dirs | QDir::AllDirs))) { type = "folder"; finfo.setIsDir(true); finfo.setSGDir(displayName); finfo.setSize(0); } else if ((tokens[0] == "file") && (m_typeFilter & QDir::Files)) { finfo.setIsDir(false); finfo.setSize(tokens[2].toInt()); if (IsImage(finfo.suffix())) type = "image"; else type = "file"; } else { // unknown type or filtered out ++it; continue; } MythUIButtonListItem *item = new MythUIButtonListItem(m_fileList, displayName, qVariantFromValue(finfo)); if (finfo.size()) item->SetText(FormatSize(finfo.size()), "filesize"); if (type == "image") item->SetImage(dataName); item->SetText(dataName, "fullpath"); item->DisplayState(type, "nodetype"); ++it; } }
void CFileExistsDlg::CreateControls() { wxXmlResource::Get()->LoadDialog(this, GetParent(), _T("ID_FILEEXISTSDLG")); m_pAction1 = wxDynamicCast(FindWindow(XRCID("ID_ACTION1")), wxRadioButton); m_pAction2 = wxDynamicCast(FindWindow(XRCID("ID_ACTION2")), wxRadioButton); m_pAction3 = wxDynamicCast(FindWindow(XRCID("ID_ACTION3")), wxRadioButton); m_pAction4 = wxDynamicCast(FindWindow(XRCID("ID_ACTION4")), wxRadioButton); m_pAction5 = wxDynamicCast(FindWindow(XRCID("ID_ACTION5")), wxRadioButton); m_pAction6 = wxDynamicCast(FindWindow(XRCID("ID_ACTION6")), wxRadioButton); m_pAction7 = wxDynamicCast(FindWindow(XRCID("ID_ACTION7")), wxRadioButton); wxString localFile = m_pNotification->localFile; wxString remoteFile = m_pNotification->remotePath.FormatFilename(m_pNotification->remoteFile); localFile = GetPathEllipsis(localFile, FindWindow(XRCID("ID_FILE1_NAME"))); remoteFile = GetPathEllipsis(remoteFile, FindWindow(XRCID("ID_FILE2_NAME"))); localFile.Replace(_T("&"), _T("&&")); remoteFile.Replace(_T("&"), _T("&&")); const bool thousands_separator = COptions::Get()->GetOptionVal(OPTION_SIZE_USETHOUSANDSEP) != 0; wxString localSize; if (m_pNotification->localSize != -1) localSize = FormatSize(m_pNotification->localSize, false, 0, thousands_separator, 0) + _T(" ") + _("bytes"); else localSize = _("Size unknown"); wxString remoteSize; if (m_pNotification->remoteSize != -1) remoteSize = FormatSize(m_pNotification->remoteSize, false, 0, thousands_separator, 0) + _T(" ") + _("bytes"); else remoteSize = _("Size unknown"); if (m_pNotification->download) { wxStaticText *pStatText; pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_NAME"))); if (pStatText) pStatText->SetLabel(localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_SIZE"))); if (pStatText) pStatText->SetLabel(localSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_TIME"))); if (pStatText) { if (m_pNotification->localTime.IsValid()) pStatText->SetLabel(m_pNotification->localTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE1_ICON"), m_pNotification->localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_NAME"))); if (pStatText) pStatText->SetLabel(remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_SIZE"))); if (pStatText) pStatText->SetLabel(remoteSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_TIME"))); if (pStatText) { if (m_pNotification->remoteTime.IsValid()) pStatText->SetLabel(m_pNotification->remoteTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE2_ICON"), m_pNotification->remoteFile); wxCheckBox *pCheckBox = reinterpret_cast<wxCheckBox *>(FindWindow(XRCID("ID_UPDOWNONLY"))); if (pCheckBox) pCheckBox->SetLabel(_("A&pply only to downloads")); } else { wxWindow *pStatText; pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_NAME"))); if (pStatText) pStatText->SetLabel(remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_SIZE"))); if (pStatText) pStatText->SetLabel(remoteSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE1_TIME"))); if (pStatText) { if (m_pNotification->remoteTime.IsValid()) pStatText->SetLabel(m_pNotification->remoteTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE1_ICON"), m_pNotification->remoteFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_NAME"))); if (pStatText) pStatText->SetLabel(localFile); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_SIZE"))); if (pStatText) pStatText->SetLabel(localSize); pStatText = reinterpret_cast<wxStaticText *>(FindWindow(XRCID("ID_FILE2_TIME"))); if (pStatText) { if (m_pNotification->localTime.IsValid()) pStatText->SetLabel(m_pNotification->localTime.Format()); else pStatText->SetLabel(_("Date/time unknown")); } LoadIcon(XRCID("ID_FILE2_ICON"), m_pNotification->localFile); wxCheckBox *pCheckBox = reinterpret_cast<wxCheckBox *>(FindWindow(XRCID("ID_UPDOWNONLY"))); if (pCheckBox) pCheckBox->SetLabel(_("A&pply only to uploads")); } }
// CFileOpenDlg::EnumFiles // // Enumerates all files in a folder // void CFileOpenDlg::EnumFiles(LPCTSTR pszPath, LPCTSTR pszFilter) { WIN32_FIND_DATA fd; HANDLE hFind; BOOL bFind; CString strSearch(pszPath), strFile; int i = 0, iItem; COleDateTime odt; CDateTimeFormat dtf; CWaitCursor wait; // // Flush the list // m_listFile.DeleteAllItems(); m_cont.clear(); // // Fill in the list // strSearch += pszFilter; hFind = FindFirstFile(strSearch, &fd); bFind = (hFind != INVALID_HANDLE_VALUE); // // Disable painting the list // m_listFile.SetRedraw(FALSE); while(bFind) { if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && !(fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)) { strFile = pszPath; strFile += fd.cFileName; iItem = m_listFile.InsertItem(i, fd.cFileName, GetIconIndex(strFile)); if(iItem != -1) { // // Format size according to locale // m_listFile.SetItemText(iItem, 1, FormatSize(fd.nFileSizeLow)); // // Format date according to locale // odt = fd.ftLastWriteTime; dtf.SetDateTime(odt); dtf.SetFormat(m_strDateFormat); m_listFile.SetItemText(iItem, 2, dtf.GetString()); m_listFile.SetItemData(iItem, i); m_cont.push_back(fd); } i++; } bFind = FindNextFile(hFind, &fd); } DoSortList(); // // Enable painting the list // m_listFile.SetRedraw(TRUE); }