void StatGetterThread::onStart()
{
    setLabel("Retrieving files count..");
    emit showLabel();
    emit setProgressRange(0, 0);
    emit setProgressValue(0);
    emit showProgressBar();

    FillPreAnalysisTree();
    const size_t totalValue = preAnalysisTree_.size();

    setLabel("Calculating statistics..");
    emit setProgressRange(0, totalValue);
    emit setProgressValue(0);

    FillStatTreeByPath();
    GetSubdirsCount();

    emit setProgressValue(totalValue);

    emit hideLabel();
    emit hideProgressBar();

    emit finished();
}
Exemple #2
0
int CItem::CompareSibling(const CTreeListItem *tlib, int subitem) const
{ 
	CItem *other = (CItem *)tlib;

	int r=0;
	switch (subitem)
	{
	case COL_NAME:
		if (GetType() == IT_DRIVE)
		{
			ASSERT(other->GetType() == IT_DRIVE);
			r = signum(GetPath().CompareNoCase(other->GetPath()));
		}
		else
		{
			r = signum(m_name.CompareNoCase(other->m_name));
		}
		break;

	case COL_SUBTREEPERCENTAGE:
		if (MustShowReadJobs())
			r = signum(m_readJobs - other->m_readJobs);
		else
			r = signum(GetFraction() - other->GetFraction());
		break;

	case COL_PERCENTAGE:
		r = signum(GetFraction() - other->GetFraction());
		break;

	case COL_SUBTREETOTAL:
		r = signum(GetSize() - other->GetSize());
		break;

	case COL_ITEMS:
		r = signum(GetItemsCount() - other->GetItemsCount());
		break;

	case COL_FILES:
		r = signum(GetFilesCount() - other->GetFilesCount());
		break;

	case COL_SUBDIRS:
		r = signum(GetSubdirsCount() - other->GetSubdirsCount());
		break;

	case COL_LASTCHANGE:
		{
			if (m_lastChange < other->m_lastChange)
				return -1;
			else if (m_lastChange == other->m_lastChange)
				return 0;
			else 
				return 1;
		}
		break;
	case COL_ATTRIBUTES:
		r = signum(GetSortAttributes() - other->GetSortAttributes());
		break;

	default:
		ASSERT(false);
		break;
	}
	return r;
}
Exemple #3
0
CString CItem::GetText(int subitem) const
{
	CString s;
	switch (subitem)
	{
	case COL_NAME:
		s = m_name;
		break;

	case COL_SUBTREEPERCENTAGE:
		if (IsDone())
		{
			ASSERT(m_readJobs == 0);
			//s = "ok";
		}
		else
		{
			if (m_readJobs == 1)
				s.LoadString(IDS_ONEREADJOB);
			else
				s.FormatMessage(IDS_sREADJOBS, FormatCount(m_readJobs));
		}
		break;

	case COL_PERCENTAGE:
		if (GetOptions()->IsShowTimeSpent() && MustShowReadJobs() || IsRootItem())
		{
			s.Format(_T("[%s s]"), FormatMilliseconds(GetTicksWorked()));
		}
		else
		{
			s.Format(_T("%s%%"), FormatDouble(GetFraction() * 100));
		}
		break;

	case COL_SUBTREETOTAL:
		s = FormatBytes(GetSize());
		break;

	case COL_ITEMS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetItemsCount());
		break;

	case COL_FILES:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetFilesCount());
		break;

	case COL_SUBDIRS:
		if (GetType() != IT_FILE && GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
			s = FormatCount(GetSubdirsCount());
		break;

	case COL_LASTCHANGE:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN)
		{
			s = FormatFileTime(m_lastChange);
		}
		break;

	case COL_ATTRIBUTES:
		if (GetType() != IT_FREESPACE && GetType() != IT_UNKNOWN && GetType() != IT_MYCOMPUTER && GetType() != IT_FILESFOLDER)
		{
			s = FormatAttributes(GetAttributes());
		}
		break;

	default:
		ASSERT(0);
		break;
	}
	return s;
}
Exemple #4
0
// Return: false if deleted
bool CItem::StartRefresh() 
{
	ASSERT(GetType() != IT_FREESPACE);
	ASSERT(GetType() != IT_UNKNOWN);

	m_ticksWorked = 0;

	// Special case IT_MYCOMPUTER
	if (GetType() == IT_MYCOMPUTER)
	{
		ZeroMemory(&m_lastChange, sizeof(m_lastChange));

		for (int i=0; i < GetChildrenCount(); i++)
			GetChild(i)->StartRefresh();

		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY || GetType() == IT_FILESFOLDER);

	bool wasExpanded = IsVisible() && IsExpanded();
	int oldScrollPosition = 0;
	if (IsVisible())
		oldScrollPosition = GetScrollPosition();

	UncacheImage();

	// Upward clear data
	UpdateLastChange();

	UpwardSetUndone();

	UpwardAddReadJobs(-GetReadJobs());
	ASSERT(GetReadJobs() == 0);

	if (GetType() == IT_FILE)
		GetParent()->UpwardAddFiles(-1);
	else
		UpwardAddFiles(-GetFilesCount());
	ASSERT(GetFilesCount() == 0);

	if (GetType() == IT_DIRECTORY || GetType() == IT_DRIVE)
		UpwardAddSubdirs(-GetSubdirsCount());
	ASSERT(GetSubdirsCount() == 0);

	UpwardAddSize(-GetSize());
	ASSERT(GetSize() == 0);

	RemoveAllChildren();
	UpwardRecalcLastChange();

	// Special case IT_FILESFOLDER
	if (GetType() == IT_FILESFOLDER)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetFindPattern());
		while (b)
		{
			b = finder.FindNextFile();
			if (finder.IsDirectory())
				continue;

			FILEINFO fi;
			fi.name = finder.GetFileName();
			fi.attributes = finder.GetAttributes();
			// Retrieve file size
			fi.length = finder.GetCompressedLength();
			finder.GetLastWriteTime(&fi.lastWriteTime);

			AddFile(fi);
			UpwardAddFiles(1);
		}
		SetDone();

		if (wasExpanded)
			GetTreeListControl()->ExpandItem(this);
		return true;
	}
	ASSERT(GetType() == IT_FILE || GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	// The item may have been deleted.
	bool deleted = false;
	if (GetType() == IT_DRIVE)
		deleted = !DriveExists(GetPath());
	else if (GetType() == IT_FILE)
		deleted = !FileExists(GetPath());
	else if (GetType() == IT_DIRECTORY)
		deleted = !FolderExists(GetPath());

	if (deleted)
	{
		if (GetParent() == NULL)
		{
			GetDocument()->UnlinkRoot();
		}
		else
		{
			GetParent()->UpwardRecalcLastChange();
			GetParent()->RemoveChild(GetParent()->FindChildIndex(this)); // --> delete this
		}
		return false;
	}

	// Case IT_FILE
	if (GetType() == IT_FILE)
	{
		CFileFindWDS finder;
		BOOL b = finder.FindFile(GetPath());
		if (b)
		{
			finder.FindNextFile();
			if (!finder.IsDirectory())
			{
				FILEINFO fi;
				fi.name = finder.GetFileName();
				fi.attributes = finder.GetAttributes();
				// Retrieve file size
				fi.length = finder.GetCompressedLength();
				finder.GetLastWriteTime(&fi.lastWriteTime);

				SetLastChange(fi.lastWriteTime);

				UpwardAddSize(fi.length);
				UpwardUpdateLastChange(GetLastChange());
				GetParent()->UpwardAddFiles(1);
			}
		}
		SetDone();
		return true;
	}

	ASSERT(GetType() == IT_DRIVE || GetType() == IT_DIRECTORY);

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsMountPoint(GetPath()) && !GetOptions()->IsFollowMountPoints())
		return true;

	if (GetType() == IT_DIRECTORY && !IsRootItem() && GetApp()->IsJunctionPoint(GetPath()) && !GetOptions()->IsFollowJunctionPoints())
		return true;

	// Initiate re-read
	SetReadJobDone(false);

	// Re-create <free space> and <unknown>
	if (GetType() == IT_DRIVE)
	{
		if (GetDocument()->OptionShowFreeSpace())
			CreateFreeSpaceItem();
		if (GetDocument()->OptionShowUnknown())
			CreateUnknownItem();
	}

	DoSomeWork(0);

	if (wasExpanded)
		GetTreeListControl()->ExpandItem(this);

	if (IsVisible())
		SetScrollPosition(oldScrollPosition);

	return true;
}