more copy loop control methods
added a size view git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@14268 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -5,8 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "InstallerCopyLoopControl.h"
|
#include "InstallerCopyLoopControl.h"
|
||||||
|
|
||||||
InstallerCopyLoopControl::InstallerCopyLoopControl()
|
InstallerCopyLoopControl::InstallerCopyLoopControl(InstallerWindow *window)
|
||||||
: CopyLoopControl()
|
: CopyLoopControl(),
|
||||||
|
fWindow(window)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -14,3 +15,69 @@ InstallerCopyLoopControl::InstallerCopyLoopControl()
|
|||||||
InstallerCopyLoopControl::~InstallerCopyLoopControl(void)
|
InstallerCopyLoopControl::~InstallerCopyLoopControl(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::FileError(const char *message, const char *name, status_t error,
|
||||||
|
bool allowContinue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InstallerCopyLoopControl::UpdateStatus(const char *name, entry_ref ref, int32 count,
|
||||||
|
bool optional)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::CheckUserCanceled()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
InstallerCopyLoopControl::OverwriteMode
|
||||||
|
InstallerCopyLoopControl::OverwriteOnConflict(const BEntry *srcEntry,
|
||||||
|
const char *destName, const BDirectory *destDir, bool srcIsDir,
|
||||||
|
bool dstIsDir)
|
||||||
|
{
|
||||||
|
return kReplace;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::SkipEntry(const BEntry *, bool file)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
InstallerCopyLoopControl::ChecksumChunk(const char *block, size_t size)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::ChecksumFile(const entry_ref *ref)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::SkipAttribute(const char *attributeName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
InstallerCopyLoopControl::PreserveAttribute(const char *attributeName)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,14 +8,35 @@
|
|||||||
#define _INSTALLERCOPYLOOPCONTROL_H
|
#define _INSTALLERCOPYLOOPCONTROL_H
|
||||||
|
|
||||||
#include "FSUtils.h"
|
#include "FSUtils.h"
|
||||||
|
#include "InstallerWindow.h"
|
||||||
|
|
||||||
class InstallerCopyLoopControl : public CopyLoopControl
|
class InstallerCopyLoopControl : public CopyLoopControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InstallerCopyLoopControl();
|
InstallerCopyLoopControl(InstallerWindow *window);
|
||||||
~InstallerCopyLoopControl(void);
|
~InstallerCopyLoopControl(void);
|
||||||
|
|
||||||
|
virtual bool FileError(const char *message, const char *name, status_t error,
|
||||||
|
bool allowContinue);
|
||||||
|
|
||||||
|
virtual void UpdateStatus(const char *name, entry_ref ref, int32 count,
|
||||||
|
bool optional = false);
|
||||||
|
|
||||||
|
virtual bool CheckUserCanceled();
|
||||||
|
|
||||||
|
virtual OverwriteMode OverwriteOnConflict(const BEntry *srcEntry,
|
||||||
|
const char *destName, const BDirectory *destDir, bool srcIsDir,
|
||||||
|
bool dstIsDir);
|
||||||
|
|
||||||
|
virtual bool SkipEntry(const BEntry *, bool file);
|
||||||
|
|
||||||
|
virtual void ChecksumChunk(const char *block, size_t size);
|
||||||
|
virtual bool ChecksumFile(const entry_ref *);
|
||||||
|
virtual bool SkipAttribute(const char *attributeName);
|
||||||
|
virtual bool PreserveAttribute(const char *attributeName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
InstallerWindow *fWindow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ const uint32 SETUP_MESSAGE = 'iSEP';
|
|||||||
const uint32 START_SCAN = 'iSSC';
|
const uint32 START_SCAN = 'iSSC';
|
||||||
const uint32 SRC_PARTITION = 'iSPT';
|
const uint32 SRC_PARTITION = 'iSPT';
|
||||||
const uint32 DST_PARTITION = 'iDPT';
|
const uint32 DST_PARTITION = 'iDPT';
|
||||||
|
const uint32 PACKAGE_CHECKBOX = 'iPCB';
|
||||||
|
|
||||||
InstallerWindow::InstallerWindow(BRect frame_rect)
|
InstallerWindow::InstallerWindow(BRect frame_rect)
|
||||||
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
: BWindow(frame_rect, "Installer", B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
|
||||||
@@ -84,7 +85,14 @@ InstallerWindow::InstallerWindow(BRect frame_rect)
|
|||||||
fDestMenuField->SetDivider(70.0);
|
fDestMenuField->SetDivider(70.0);
|
||||||
fDestMenuField->SetAlignment(B_ALIGN_RIGHT);
|
fDestMenuField->SetAlignment(B_ALIGN_RIGHT);
|
||||||
fBackBox->AddChild(fDestMenuField);
|
fBackBox->AddChild(fDestMenuField);
|
||||||
|
|
||||||
|
BRect sizeRect = fBackBox->Bounds();
|
||||||
|
sizeRect.top = sizeRect.bottom - 15;
|
||||||
|
sizeRect.left = sizeRect.right - 100;
|
||||||
|
fSizeView = new BStringView(sizeRect, "size_view", "Disk space required : 0.0 KB");
|
||||||
|
fSizeView->SetAlignment(B_ALIGN_RIGHT);
|
||||||
|
fBackBox->AddChild(fSizeView);
|
||||||
|
|
||||||
// finish creating window
|
// finish creating window
|
||||||
Show();
|
Show();
|
||||||
|
|
||||||
@@ -118,6 +126,14 @@ InstallerWindow::MessageReceived(BMessage *msg)
|
|||||||
case SETUP_MESSAGE:
|
case SETUP_MESSAGE:
|
||||||
LaunchDriveSetup();
|
LaunchDriveSetup();
|
||||||
break;
|
break;
|
||||||
|
case PACKAGE_CHECKBOX: {
|
||||||
|
char buffer[15];
|
||||||
|
fPackagesView->GetTotalSizeAsString(buffer);
|
||||||
|
char string[255];
|
||||||
|
sprintf(string, "Disk space required: %s", buffer);
|
||||||
|
fSizeView->SetText(string);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case B_SOME_APP_LAUNCHED:
|
case B_SOME_APP_LAUNCHED:
|
||||||
case B_SOME_APP_QUIT:
|
case B_SOME_APP_QUIT:
|
||||||
{
|
{
|
||||||
@@ -236,7 +252,7 @@ InstallerWindow::PublishPackages()
|
|||||||
}
|
}
|
||||||
packages.SortItems(ComparePackages);
|
packages.SortItems(ComparePackages);
|
||||||
|
|
||||||
fPackagesView->AddPackages(packages);
|
fPackagesView->AddPackages(packages, new BMessage(PACKAGE_CHECKBOX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ private:
|
|||||||
BMenuField* fSrcMenuField, *fDestMenuField;
|
BMenuField* fSrcMenuField, *fDestMenuField;
|
||||||
PackagesView *fPackagesView;
|
PackagesView *fPackagesView;
|
||||||
BScrollView *fPackagesScrollView;
|
BScrollView *fPackagesScrollView;
|
||||||
|
BStringView *fSizeView;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _InstallerWindow_h */
|
#endif /* _InstallerWindow_h */
|
||||||
|
|||||||
@@ -13,6 +13,23 @@
|
|||||||
|
|
||||||
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
#define ICON_ATTRIBUTE "INSTALLER PACKAGE: ICON"
|
||||||
|
|
||||||
|
static void
|
||||||
|
SizeAsString(int32 size, char *string)
|
||||||
|
{
|
||||||
|
float kb = size / 1024.0;
|
||||||
|
if (kb < 1.0) {
|
||||||
|
sprintf(string, "%ld B", size);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
float mb = kb / 1024.0;
|
||||||
|
if (mb < 1.0) {
|
||||||
|
sprintf(string, "%3.1f KB", kb);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sprintf(string, "%3.1f MB", mb);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Package::Package()
|
Package::Package()
|
||||||
: Group(),
|
: Group(),
|
||||||
fName(NULL),
|
fName(NULL),
|
||||||
@@ -83,18 +100,7 @@ err:
|
|||||||
void
|
void
|
||||||
Package::GetSizeAsString(char *string)
|
Package::GetSizeAsString(char *string)
|
||||||
{
|
{
|
||||||
float kb = fSize / 1024.0;
|
SizeAsString(fSize, string);
|
||||||
if (kb < 1.0) {
|
|
||||||
sprintf(string, "%ld B", fSize);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float mb = kb / 1024.0;
|
|
||||||
if (mb < 1.0) {
|
|
||||||
sprintf(string, "%3.1f KB", kb);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sprintf(string, "%3.1f MB", mb);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -126,7 +132,7 @@ void
|
|||||||
PackageCheckBox::Draw(BRect update)
|
PackageCheckBox::Draw(BRect update)
|
||||||
{
|
{
|
||||||
BCheckBox::Draw(update);
|
BCheckBox::Draw(update);
|
||||||
char string[255];
|
char string[15];
|
||||||
fPackage.GetSizeAsString(string);
|
fPackage.GetSizeAsString(string);
|
||||||
float width = StringWidth(string);
|
float width = StringWidth(string);
|
||||||
DrawString(string, BPoint(Bounds().right - width - 8, 11));
|
DrawString(string, BPoint(Bounds().right - width - 8, 11));
|
||||||
@@ -152,7 +158,6 @@ GroupView::~GroupView()
|
|||||||
PackagesView::PackagesView(BRect rect, const char* name)
|
PackagesView::PackagesView(BRect rect, const char* name)
|
||||||
: BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS)
|
: BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW|B_FRAME_EVENTS)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -170,7 +175,7 @@ PackagesView::Clean()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PackagesView::AddPackages(BList &packages)
|
PackagesView::AddPackages(BList &packages, BMessage *msg)
|
||||||
{
|
{
|
||||||
int32 count = packages.CountItems();
|
int32 count = packages.CountItems();
|
||||||
BRect rect = Bounds();
|
BRect rect = Bounds();
|
||||||
@@ -193,6 +198,7 @@ PackagesView::AddPackages(BList &packages)
|
|||||||
PackageCheckBox *checkBox = new PackageCheckBox(rect, *package);
|
PackageCheckBox *checkBox = new PackageCheckBox(rect, *package);
|
||||||
checkBox->SetValue(package->OnByDefault() ? B_CONTROL_ON : B_CONTROL_OFF);
|
checkBox->SetValue(package->OnByDefault() ? B_CONTROL_ON : B_CONTROL_OFF);
|
||||||
checkBox->SetEnabled(!package->AlwaysOn());
|
checkBox->SetEnabled(!package->AlwaysOn());
|
||||||
|
checkBox->SetMessage(msg);
|
||||||
AddChild(checkBox);
|
AddChild(checkBox);
|
||||||
rect.OffsetBy(0, 20);
|
rect.OffsetBy(0, 20);
|
||||||
}
|
}
|
||||||
@@ -212,3 +218,10 @@ PackagesView::AddPackages(BList &packages)
|
|||||||
|
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
PackagesView::GetTotalSizeAsString(char *string)
|
||||||
|
{
|
||||||
|
SizeAsString(0, string);
|
||||||
|
}
|
||||||
|
|||||||
@@ -76,7 +76,8 @@ public:
|
|||||||
PackagesView(BRect rect, const char* name);
|
PackagesView(BRect rect, const char* name);
|
||||||
virtual ~PackagesView();
|
virtual ~PackagesView();
|
||||||
void Clean();
|
void Clean();
|
||||||
void AddPackages(BList &list);
|
void AddPackages(BList &list, BMessage *msg);
|
||||||
|
void GetTotalSizeAsString(char *string);
|
||||||
private:
|
private:
|
||||||
BList fViews;
|
BList fViews;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user