DiskUsage: remove path monitoring and "outdated view" notification
Was unreliable, too many files to monitor (would exceed too easily the 4096 files limit).
This commit is contained in:
parent
08282eb476
commit
a4ef1e81ce
@ -61,7 +61,6 @@ extern bool helpFileWasFound;
|
||||
#define kScanRefresh 'gSRF'
|
||||
#define kScanProgress 'gSPR'
|
||||
#define kScanDone 'gSDN'
|
||||
#define kOutdatedMsg 'gOUT'
|
||||
|
||||
#define deg2rad(x) (2.0 * M_PI * (x) / 360.0)
|
||||
#define rad2deg(x) (360.0 * (x) / (2.0 * M_PI))
|
||||
|
@ -135,8 +135,7 @@ PieView::PieView(BVolume* volume)
|
||||
fVolume(volume),
|
||||
fMouseOverInfo(),
|
||||
fClicked(false),
|
||||
fDragging(false),
|
||||
fOutdated(false)
|
||||
fDragging(false)
|
||||
{
|
||||
fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false);
|
||||
fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL),
|
||||
@ -188,7 +187,6 @@ PieView::MessageReceived(BMessage* message)
|
||||
else
|
||||
_ShowVolume(fVolume);
|
||||
|
||||
fOutdated = false;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
@ -200,15 +198,6 @@ PieView::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case kOutdatedMsg:
|
||||
{
|
||||
if (!fScanner->IsBusy()) {
|
||||
fOutdated = true;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BView::MessageReceived(message);
|
||||
break;
|
||||
@ -250,11 +239,9 @@ PieView::MouseUp(BPoint where)
|
||||
if (info != NULL) {
|
||||
if (info == fScanner->CurrentDir()) {
|
||||
fScanner->ChangeDir(info->parent);
|
||||
fOutdated = fScanner->IsOutdated();
|
||||
Invalidate();
|
||||
} else if (info->children.size() > 0) {
|
||||
fScanner->ChangeDir(info);
|
||||
fOutdated = fScanner->IsOutdated();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
@ -415,21 +402,6 @@ PieView::_DrawPieChart(BRect updateRect)
|
||||
}
|
||||
_DrawDirectory(pieRect, currentDir, 0.0, 0.0,
|
||||
colorIdx % kBasePieColorCount, 0);
|
||||
|
||||
if (fOutdated) {
|
||||
|
||||
BRect b = Bounds();
|
||||
|
||||
float strWidth = StringWidth(B_TRANSLATE("Outdated view"));
|
||||
float bx = (b.Width() - strWidth - kSmallHMargin);
|
||||
|
||||
struct font_height fh;
|
||||
be_plain_font->GetHeight(&fh);
|
||||
|
||||
float by = (b.Height() - ceil(fh.descent) - kSmallVMargin);
|
||||
SetHighColor(0x00, 0x00, 0x00);
|
||||
DrawString(B_TRANSLATE("Outdated view"), BPoint(bx, by));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,8 +91,7 @@ private:
|
||||
bool fClicked;
|
||||
bool fDragging;
|
||||
BPoint fDragStart;
|
||||
FileInfo* fClickedFile;
|
||||
bool fOutdated;
|
||||
FileInfo* fClickedFile;
|
||||
};
|
||||
|
||||
#endif // PIE_VIEW_H
|
||||
|
@ -15,7 +15,6 @@
|
||||
|
||||
#include <Catalog.h>
|
||||
#include <Directory.h>
|
||||
#include <PathMonitor.h>
|
||||
|
||||
#include "DiskUsage.h"
|
||||
|
||||
@ -36,9 +35,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
|
||||
fDesiredPath(),
|
||||
fTask(),
|
||||
fBusy(false),
|
||||
fQuitRequested(false),
|
||||
fIsWatching(false),
|
||||
fModifiedEntries()
|
||||
fQuitRequested(false)
|
||||
{
|
||||
Run();
|
||||
}
|
||||
@ -46,17 +43,7 @@ Scanner::Scanner(BVolume *v, BHandler *handler)
|
||||
|
||||
Scanner::~Scanner()
|
||||
{
|
||||
if (fIsWatching) {
|
||||
BPrivate::BPathMonitor::StopWatching(BMessenger(this, this));
|
||||
fIsWatching = false;
|
||||
}
|
||||
delete fSnapshot;
|
||||
|
||||
while (fModifiedEntries.size() != 0) {
|
||||
entry_ref* entry = *fModifiedEntries.begin();
|
||||
delete entry;
|
||||
fModifiedEntries.erase(fModifiedEntries.begin());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -73,38 +60,6 @@ Scanner::MessageReceived(BMessage* message)
|
||||
break;
|
||||
}
|
||||
|
||||
case B_PATH_MONITOR:
|
||||
{
|
||||
dev_t device;
|
||||
ino_t directory;
|
||||
const char* name = "";
|
||||
const char* path;
|
||||
|
||||
if (((message->FindInt32("device", &device) != B_OK)
|
||||
|| (message->FindInt64("directory", &directory) != B_OK)
|
||||
|| (message->FindString("name", &name) != B_OK))
|
||||
&& ((message->FindString("path", &path) != B_OK)
|
||||
|| (message->FindInt32("device", &device) != B_OK)))
|
||||
return;
|
||||
|
||||
entry_ref* reportedEntry;
|
||||
if (strlen(name) > 0)
|
||||
reportedEntry = new entry_ref(device, directory, name);
|
||||
else {
|
||||
BEntry entry(path);
|
||||
reportedEntry = new entry_ref();
|
||||
entry.GetRef(reportedEntry);
|
||||
}
|
||||
|
||||
fModifiedEntries.push_back(reportedEntry);
|
||||
|
||||
if (IsOutdated()) {
|
||||
BMessage msg(kOutdatedMsg);
|
||||
fListener.SendMessage(&msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
BLooper::MessageReceived(message);
|
||||
break;
|
||||
@ -120,12 +75,6 @@ Scanner::Refresh(FileInfo* startInfo)
|
||||
|
||||
fBusy = true;
|
||||
|
||||
while (fModifiedEntries.size() != 0) {
|
||||
entry_ref* entry = *fModifiedEntries.begin();
|
||||
delete entry;
|
||||
fModifiedEntries.erase(fModifiedEntries.begin());
|
||||
}
|
||||
|
||||
// Remember the current directory, if any, so we can return to it after
|
||||
// the scanning is done.
|
||||
if (fSnapshot != NULL && fSnapshot->currentDir != NULL)
|
||||
@ -165,27 +114,6 @@ Scanner::RequestQuit()
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Scanner::IsOutdated()
|
||||
{
|
||||
FileInfo* currentDir = (fSnapshot->currentDir != NULL ?
|
||||
fSnapshot->currentDir : fSnapshot->rootDir);
|
||||
|
||||
BDirectory currentDirectory(&(currentDir->ref));
|
||||
|
||||
bool isOutdated = currentDirectory.InitCheck() != B_OK;
|
||||
|
||||
vector<entry_ref*>::iterator i = fModifiedEntries.begin();
|
||||
while (!isOutdated && i != fModifiedEntries.end()) {
|
||||
BEntry entry(*i);
|
||||
isOutdated = _DirectoryContains(currentDir, *i)
|
||||
|| currentDirectory.Contains(&entry);
|
||||
i++;
|
||||
}
|
||||
return isOutdated;
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark - private
|
||||
|
||||
|
||||
@ -260,16 +188,6 @@ Scanner::_RunScan(FileInfo* startInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (!fIsWatching) {
|
||||
string path;
|
||||
fSnapshot->rootDir->GetPath(path);
|
||||
|
||||
BPrivate::BPathMonitor::StartWatching(path.c_str(),
|
||||
B_WATCH_ALL | B_WATCH_RECURSIVELY, BMessenger(this, this));
|
||||
|
||||
fIsWatching = true;
|
||||
}
|
||||
|
||||
fBusy = false;
|
||||
_ChangeToDesired();
|
||||
fListener.SendMessage(&fDoneMessage);
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <Looper.h>
|
||||
#include <Message.h>
|
||||
@ -50,7 +49,6 @@ public:
|
||||
dev_t Device() const
|
||||
{ return fVolume->Device(); }
|
||||
void RequestQuit();
|
||||
bool IsOutdated();
|
||||
|
||||
private:
|
||||
void _RunScan(FileInfo *startInfo);
|
||||
@ -73,10 +71,6 @@ private:
|
||||
string fTask;
|
||||
bool fBusy;
|
||||
bool fQuitRequested;
|
||||
|
||||
bool fIsWatching;
|
||||
|
||||
std::vector<entry_ref*> fModifiedEntries;
|
||||
};
|
||||
|
||||
#endif // SCANNER_H
|
||||
|
Loading…
Reference in New Issue
Block a user