1
0
mirror of https://github.com/winscp/winscp.git synced 2026-10-24 02:28:55 +03:00
Files
winscp/source/components/DirView.cpp
Martin Prikryl d843cab082 Adding more startup sequence counter steps (Y, Q, V, Z, a) around F
(previous steps added in aee26917)

Source commit: b93e0f99f5dfce22f9bb9e1451ba11040ad05355
2026-04-04 01:24:19 +02:00

133 lines
3.9 KiB
C++

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <Common.h>
#include "DirView.h"
#include "IEDriveInfo.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
__fastcall TDirView::TDirView(TComponent * AOwner) :
TDirViewInt(AOwner)
{
DriveInfoRequire();
}
//---------------------------------------------------------------------------
void __fastcall TDirView::IconUpdateClear()
{
FIconUpdateQueue = TIconUpdateQueue();
FIconUpdateQueueDeferred = TIconUpdateQueue();
FIconUpdateSet.clear();
}
//---------------------------------------------------------------------------
void __fastcall TDirView::IconUpdateEnqueue(TListItem * ListItem)
{
if (FIconUpdateSet.find(ListItem->Index) == FIconUpdateSet.end())
{
FIconUpdateSet.insert(ListItem->Index);
TIconUpdateSchedule Schedule { .Index = ListItem->Index };
FIconUpdateQueue.push(Schedule);
DebugAssert(FIconUpdateSet.size() == FIconUpdateQueue.size() + FIconUpdateQueueDeferred.size());
}
StartIconUpdateThread();
}
//---------------------------------------------------------------------------
int __fastcall TDirView::IconUpdatePeek()
{
int Result;
if (!FIconUpdateQueue.empty())
{
Result = FIconUpdateQueue.front().Index;
}
else if (!FIconUpdateQueueDeferred.empty())
{
Result = FIconUpdateQueueDeferred.front().Index;
}
else
{
Result = -1;
}
return Result;
}
//---------------------------------------------------------------------------
bool __fastcall TDirView::IconUpdateDeprioritize(Dirviewint::TFileRec * ItemData, int Index)
{
bool Result = !FIconUpdateQueue.empty();
if (Result)
{
DebugAssert(!ThumbnailNeeded(ItemData));
if (ItemData->IconEmpty)
{
TIconUpdateSchedule Schedule = FIconUpdateQueue.front();
FIconUpdateQueue.pop();
FIconUpdateQueueDeferred.push(Schedule);
}
else
{
IconUpdateDequeue(Index);
}
}
return Result;
}
//---------------------------------------------------------------------------
void __fastcall TDirView::IconUpdateDequeue(int Index)
{
if (!FIconUpdateQueue.empty())
{
FIconUpdateQueue.pop();
}
else
{
FIconUpdateQueueDeferred.pop();
}
FIconUpdateSet.erase(Index);
DebugAssert(FIconUpdateSet.size() == FIconUpdateQueue.size() + FIconUpdateQueueDeferred.size());
}
//---------------------------------------------------------------------------
void __fastcall TDirView::PathChanged()
{
TDirViewInt::PathChanged();
// make sure to use PathName as Path maybe just X: what
// ExpandFileName resolves to current working directory
// on the drive, not to root path
UnicodeString Expanded = ExpandFileName(PathName);
FLastPaths[DriveInfo->GetDriveKey(Expanded)] = Expanded;
}
//---------------------------------------------------------------------------
bool __fastcall TDirView::TryGetLastPath(UnicodeString Drive, UnicodeString & Path)
{
auto I = FLastPaths.find(Drive);
bool Result = (I != FLastPaths.end());
if (Result)
{
Path = I->second;
#ifndef DESIGN_ONLY
if (!DirectoryExists(ApiPath(Path)))
{
if (DriveInfo->IsRealDrive(Drive))
{
Path = FORMAT(L"%s:", (Drive));
}
else
{
Path = Drive;
}
}
#endif
}
return Result;
}
//---------------------------------------------------------------------------
void __fastcall TDirView::CreateWnd()
{
#ifndef DESIGN_ONLY
UnicodeString StartupSequenceTag = Name.SubString(1, 1);
AddStartupSequence(L"Z" + StartupSequenceTag);
#endif
TDirViewInt::CreateWnd();
#ifndef DESIGN_ONLY
AddStartupSequence(L"a" + StartupSequenceTag);
#endif
}