* Cleanup, no functional change.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38854 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -32,10 +32,14 @@ names are registered trademarks or trademarks of their respective holders.
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <fs_attr.h>
|
|
||||||
|
#include "WidgetAttributeText.h"
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
|
||||||
|
#include <fs_attr.h>
|
||||||
#include <parsedate.h>
|
#include <parsedate.h>
|
||||||
|
|
||||||
#include <Alert.h>
|
#include <Alert.h>
|
||||||
@@ -60,8 +64,6 @@ All rights reserved.
|
|||||||
#include "SettingsViews.h"
|
#include "SettingsViews.h"
|
||||||
#include "Utilities.h"
|
#include "Utilities.h"
|
||||||
#include "ViewState.h"
|
#include "ViewState.h"
|
||||||
#include "WidgetAttributeText.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#undef B_TRANSLATE_CONTEXT
|
#undef B_TRANSLATE_CONTEXT
|
||||||
@@ -70,135 +72,6 @@ All rights reserved.
|
|||||||
|
|
||||||
const int32 kGenericReadBufferSize = 1024;
|
const int32 kGenericReadBufferSize = 1024;
|
||||||
|
|
||||||
template <class View>
|
|
||||||
float
|
|
||||||
TruncStringBase(BString *result, const char *str, int32 length,
|
|
||||||
const View *view, float width, uint32 truncMode = B_TRUNCATE_MIDDLE)
|
|
||||||
{
|
|
||||||
// we are using a template version of this call to make sure
|
|
||||||
// the right StringWidth gets picked up for BView x BPoseView
|
|
||||||
// for max speed and flexibility
|
|
||||||
|
|
||||||
// a standard ellipsis inserting fitting algorithm
|
|
||||||
if (view->StringWidth(str, length) <= width)
|
|
||||||
*result = str;
|
|
||||||
else {
|
|
||||||
const char *srcstr[1];
|
|
||||||
char *results[1];
|
|
||||||
|
|
||||||
srcstr[0] = str;
|
|
||||||
results[0] = result->LockBuffer(length + 3);
|
|
||||||
|
|
||||||
BFont font;
|
|
||||||
view->GetFont(&font);
|
|
||||||
|
|
||||||
font.GetTruncatedStrings(srcstr, 1, truncMode, width, results);
|
|
||||||
result->UnlockBuffer();
|
|
||||||
}
|
|
||||||
return view->StringWidth(result->String(), result->Length());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetAttributeText *
|
|
||||||
WidgetAttributeText::NewWidgetText(const Model *model,
|
|
||||||
const BColumn *column, const BPoseView *view)
|
|
||||||
{
|
|
||||||
// call this to make the right WidgetAttributeText type for a
|
|
||||||
// given column
|
|
||||||
|
|
||||||
const char *attrName = column->AttrName();
|
|
||||||
|
|
||||||
if (strcmp(attrName, kAttrPath) == 0)
|
|
||||||
return new PathAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrMIMEType) == 0)
|
|
||||||
return new KindAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrStatName) == 0)
|
|
||||||
return new NameAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrStatSize) == 0)
|
|
||||||
return new SizeAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrStatModified) == 0)
|
|
||||||
return new ModificationTimeAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrStatCreated) == 0)
|
|
||||||
return new CreationTimeAttributeText(model, column);
|
|
||||||
#ifdef OWNER_GROUP_ATTRIBUTES
|
|
||||||
else if (strcmp(attrName, kAttrStatOwner) == 0)
|
|
||||||
return new OwnerAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrStatGroup) == 0)
|
|
||||||
return new GroupAttributeText(model, column);
|
|
||||||
#endif
|
|
||||||
else if (strcmp(attrName, kAttrStatMode) == 0)
|
|
||||||
return new ModeAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrOpenWithRelation) == 0)
|
|
||||||
return new OpenWithRelationAttributeText(model, column, view);
|
|
||||||
else if (strcmp(attrName, kAttrAppVersion) == 0)
|
|
||||||
return new AppShortVersionAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrSystemVersion) == 0)
|
|
||||||
return new SystemShortVersionAttributeText(model, column);
|
|
||||||
else if (strcmp(attrName, kAttrOriginalPath) == 0)
|
|
||||||
return new OriginalPathAttributeText(model, column);
|
|
||||||
|
|
||||||
return new GenericAttributeText(model, column);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetAttributeText::WidgetAttributeText(const Model *model,
|
|
||||||
const BColumn *column)
|
|
||||||
:
|
|
||||||
fModel(const_cast<Model *>(model)),
|
|
||||||
fColumn(column),
|
|
||||||
fDirty(true),
|
|
||||||
fValueIsDefined(false)
|
|
||||||
{
|
|
||||||
ASSERT(fColumn);
|
|
||||||
ASSERT(fColumn->Width() > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WidgetAttributeText::~WidgetAttributeText()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char *
|
|
||||||
WidgetAttributeText::FittingText(const BPoseView *view)
|
|
||||||
{
|
|
||||||
if (fDirty || fColumn->Width() != fOldWidth || CheckSettingsChanged()
|
|
||||||
|| !fValueIsDefined )
|
|
||||||
CheckViewChanged(view);
|
|
||||||
|
|
||||||
ASSERT(!fDirty);
|
|
||||||
return fText.String();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
WidgetAttributeText::CheckViewChanged(const BPoseView *view)
|
|
||||||
{
|
|
||||||
BString newText;
|
|
||||||
FitValue(&newText, view);
|
|
||||||
if (newText == fText)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
fText = newText;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool
|
|
||||||
WidgetAttributeText::CheckSettingsChanged()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
float
|
|
||||||
WidgetAttributeText::TruncString(BString *result, const char *str,
|
|
||||||
int32 length, const BPoseView *view, float width, uint32 truncMode)
|
|
||||||
{
|
|
||||||
return TruncStringBase(result, str, length, view, width, truncMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char* kSizeFormats[] = {
|
const char* kSizeFormats[] = {
|
||||||
"%.2f %s",
|
"%.2f %s",
|
||||||
"%.1f %s",
|
"%.1f %s",
|
||||||
@@ -208,6 +81,9 @@ const char *kSizeFormats[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
bool NameAttributeText::sSortFolderNamesFirst = false;
|
||||||
|
|
||||||
|
|
||||||
template <class View>
|
template <class View>
|
||||||
float
|
float
|
||||||
TruncFileSizeBase(BString* result, int64 value, const View* view, float width)
|
TruncFileSizeBase(BString* result, int64 value, const View* view, float width)
|
||||||
@@ -276,12 +152,34 @@ TruncFileSizeBase(BString *result, int64 value, const View *view, float width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template <class View>
|
||||||
float
|
float
|
||||||
WidgetAttributeText::TruncFileSize(BString *result, int64 value,
|
TruncStringBase(BString* result, const char* str, int32 length,
|
||||||
const BPoseView *view, float width)
|
const View* view, float width, uint32 truncMode = B_TRUNCATE_MIDDLE)
|
||||||
{
|
{
|
||||||
return TruncFileSizeBase(result, value, view, width);
|
// we are using a template version of this call to make sure
|
||||||
|
// the right StringWidth gets picked up for BView x BPoseView
|
||||||
|
// for max speed and flexibility
|
||||||
|
|
||||||
|
// a standard ellipsis inserting fitting algorithm
|
||||||
|
if (view->StringWidth(str, length) <= width)
|
||||||
|
*result = str;
|
||||||
|
else {
|
||||||
|
const char* srcstr[1];
|
||||||
|
char* results[1];
|
||||||
|
|
||||||
|
srcstr[0] = str;
|
||||||
|
results[0] = result->LockBuffer(length + 3);
|
||||||
|
|
||||||
|
BFont font;
|
||||||
|
view->GetFont(&font);
|
||||||
|
|
||||||
|
font.GetTruncatedStrings(srcstr, 1, truncMode, width, results);
|
||||||
|
result->UnlockBuffer();
|
||||||
}
|
}
|
||||||
|
return view->StringWidth(result->String(), result->Length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <class View>
|
template <class View>
|
||||||
float
|
float
|
||||||
@@ -311,6 +209,117 @@ TruncTimeBase(BString *result, int64 value, const View *view, float width)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - WidgetAttributeText base class
|
||||||
|
|
||||||
|
|
||||||
|
WidgetAttributeText*
|
||||||
|
WidgetAttributeText::NewWidgetText(const Model* model,
|
||||||
|
const BColumn* column, const BPoseView* view)
|
||||||
|
{
|
||||||
|
// call this to make the right WidgetAttributeText type for a
|
||||||
|
// given column
|
||||||
|
|
||||||
|
const char* attrName = column->AttrName();
|
||||||
|
|
||||||
|
if (strcmp(attrName, kAttrPath) == 0)
|
||||||
|
return new PathAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrMIMEType) == 0)
|
||||||
|
return new KindAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrStatName) == 0)
|
||||||
|
return new NameAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrStatSize) == 0)
|
||||||
|
return new SizeAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrStatModified) == 0)
|
||||||
|
return new ModificationTimeAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrStatCreated) == 0)
|
||||||
|
return new CreationTimeAttributeText(model, column);
|
||||||
|
#ifdef OWNER_GROUP_ATTRIBUTES
|
||||||
|
if (strcmp(attrName, kAttrStatOwner) == 0)
|
||||||
|
return new OwnerAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrStatGroup) == 0)
|
||||||
|
return new GroupAttributeText(model, column);
|
||||||
|
#endif
|
||||||
|
if (strcmp(attrName, kAttrStatMode) == 0)
|
||||||
|
return new ModeAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrOpenWithRelation) == 0)
|
||||||
|
return new OpenWithRelationAttributeText(model, column, view);
|
||||||
|
if (strcmp(attrName, kAttrAppVersion) == 0)
|
||||||
|
return new AppShortVersionAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrSystemVersion) == 0)
|
||||||
|
return new SystemShortVersionAttributeText(model, column);
|
||||||
|
if (strcmp(attrName, kAttrOriginalPath) == 0)
|
||||||
|
return new OriginalPathAttributeText(model, column);
|
||||||
|
|
||||||
|
return new GenericAttributeText(model, column);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WidgetAttributeText::WidgetAttributeText(const Model* model,
|
||||||
|
const BColumn* column)
|
||||||
|
:
|
||||||
|
fModel(const_cast<Model*>(model)),
|
||||||
|
fColumn(column),
|
||||||
|
fDirty(true),
|
||||||
|
fValueIsDefined(false)
|
||||||
|
{
|
||||||
|
ASSERT(fColumn);
|
||||||
|
ASSERT(fColumn->Width() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
WidgetAttributeText::~WidgetAttributeText()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char*
|
||||||
|
WidgetAttributeText::FittingText(const BPoseView* view)
|
||||||
|
{
|
||||||
|
if (fDirty || fColumn->Width() != fOldWidth || CheckSettingsChanged()
|
||||||
|
|| !fValueIsDefined )
|
||||||
|
CheckViewChanged(view);
|
||||||
|
|
||||||
|
ASSERT(!fDirty);
|
||||||
|
return fText.String();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
WidgetAttributeText::CheckViewChanged(const BPoseView* view)
|
||||||
|
{
|
||||||
|
BString newText;
|
||||||
|
FitValue(&newText, view);
|
||||||
|
if (newText == fText)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
fText = newText;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool
|
||||||
|
WidgetAttributeText::CheckSettingsChanged()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
WidgetAttributeText::TruncString(BString* result, const char* str,
|
||||||
|
int32 length, const BPoseView* view, float width, uint32 truncMode)
|
||||||
|
{
|
||||||
|
return TruncStringBase(result, str, length, view, width, truncMode);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float
|
||||||
|
WidgetAttributeText::TruncFileSize(BString* result, int64 value,
|
||||||
|
const BPoseView* view, float width)
|
||||||
|
{
|
||||||
|
return TruncFileSizeBase(result, value, view, width);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float
|
float
|
||||||
WidgetAttributeText::TruncTime(BString* result, int64 value,
|
WidgetAttributeText::TruncTime(BString* result, int64 value,
|
||||||
const BPoseView* view, float width)
|
const BPoseView* view, float width)
|
||||||
@@ -352,8 +361,8 @@ WidgetAttributeText::CommitEditedText(BTextView *)
|
|||||||
|
|
||||||
status_t
|
status_t
|
||||||
WidgetAttributeText::AttrAsString(const Model* model, BString* result,
|
WidgetAttributeText::AttrAsString(const Model* model, BString* result,
|
||||||
const char *attrName, int32 attrType,
|
const char* attrName, int32 attrType, float width, BView* view,
|
||||||
float width, BView *view, int64 *resultingValue)
|
int64* resultingValue)
|
||||||
{
|
{
|
||||||
int64 value;
|
int64 value;
|
||||||
|
|
||||||
@@ -436,7 +445,8 @@ WidgetAttributeText::SetDirty(bool value)
|
|||||||
|
|
||||||
StringAttributeText::StringAttributeText(const Model* model,
|
StringAttributeText::StringAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: WidgetAttributeText(model, column),
|
:
|
||||||
|
WidgetAttributeText(model, column),
|
||||||
fValueDirty(true)
|
fValueDirty(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -508,13 +518,15 @@ StringAttributeText::CommitEditedText(BTextView *textView)
|
|||||||
ASSERT(fColumn->Editable());
|
ASSERT(fColumn->Editable());
|
||||||
const char* text = textView->Text();
|
const char* text = textView->Text();
|
||||||
|
|
||||||
if (fFullValueText == text)
|
if (fFullValueText == text) {
|
||||||
// no change
|
// no change
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (textView->TextLength() == 0)
|
if (textView->TextLength() == 0) {
|
||||||
// cannot do an empty name
|
// cannot do an empty name
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// cause re-truncation
|
// cause re-truncation
|
||||||
fDirty = true;
|
fDirty = true;
|
||||||
@@ -534,7 +546,8 @@ StringAttributeText::CommitEditedText(BTextView *textView)
|
|||||||
|
|
||||||
ScalarAttributeText::ScalarAttributeText(const Model* model,
|
ScalarAttributeText::ScalarAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: WidgetAttributeText(model, column),
|
:
|
||||||
|
WidgetAttributeText(model, column),
|
||||||
fValueDirty(true)
|
fValueDirty(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -591,7 +604,8 @@ ScalarAttributeText::Compare(WidgetAttributeText &attr, BPoseView *)
|
|||||||
|
|
||||||
|
|
||||||
PathAttributeText::PathAttributeText(const Model* model, const BColumn* column)
|
PathAttributeText::PathAttributeText(const Model* model, const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -617,7 +631,8 @@ PathAttributeText::ReadValue(BString *result)
|
|||||||
|
|
||||||
OriginalPathAttributeText::OriginalPathAttributeText(const Model* model,
|
OriginalPathAttributeText::OriginalPathAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -641,7 +656,8 @@ OriginalPathAttributeText::ReadValue(BString *result)
|
|||||||
|
|
||||||
|
|
||||||
KindAttributeText::KindAttributeText(const Model* model, const BColumn* column)
|
KindAttributeText::KindAttributeText(const Model* model, const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,7 +684,8 @@ KindAttributeText::ReadValue(BString *result)
|
|||||||
|
|
||||||
|
|
||||||
NameAttributeText::NameAttributeText(const Model* model, const BColumn* column)
|
NameAttributeText::NameAttributeText(const Model* model, const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -686,52 +703,14 @@ NameAttributeText::Compare(WidgetAttributeText &attr, BPoseView *view)
|
|||||||
if (NameAttributeText::sSortFolderNamesFirst)
|
if (NameAttributeText::sSortFolderNamesFirst)
|
||||||
return fModel->CompareFolderNamesFirst(attr.TargetModel());
|
return fModel->CompareFolderNamesFirst(attr.TargetModel());
|
||||||
|
|
||||||
return NaturalCompare(fFullValueText.String(), compareTo->ValueAsText(view));
|
return NaturalCompare(fFullValueText.String(),
|
||||||
|
compareTo->ValueAsText(view));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NameAttributeText::ReadValue(BString* result)
|
NameAttributeText::ReadValue(BString* result)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
|
||||||
// x86 support :-)
|
|
||||||
if ((modifiers() & B_CAPS_LOCK) != 0) {
|
|
||||||
if (fModel->IsVolume()) {
|
|
||||||
BVolumeRoster roster;
|
|
||||||
roster.Rewind();
|
|
||||||
BVolume volume;
|
|
||||||
char device = 'A';
|
|
||||||
while (roster.GetNextVolume(&volume) == B_OK) {
|
|
||||||
char name[256];
|
|
||||||
if (volume.GetName(name) == B_OK
|
|
||||||
&& strcmp(name, fModel->Name()) == 0) {
|
|
||||||
*result += device;
|
|
||||||
*result += ':';
|
|
||||||
fValueDirty = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
device++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const char *modelName = fModel->Name();
|
|
||||||
bool hasDot = strstr(".", modelName) != 0;
|
|
||||||
for (int32 index = 0; index < 8; index++) {
|
|
||||||
if (!modelName[index] || modelName[index] == '.')
|
|
||||||
break;
|
|
||||||
*result += toupper(modelName[index]);
|
|
||||||
}
|
|
||||||
if (hasDot) {
|
|
||||||
modelName = strstr(".", modelName);
|
|
||||||
for (int32 index = 0; index < 4; index++) {
|
|
||||||
if (!modelName[index])
|
|
||||||
break;
|
|
||||||
*result += toupper(modelName[index]);
|
|
||||||
}
|
|
||||||
} else if (fModel->IsExecutable())
|
|
||||||
*result += ".EXE";
|
|
||||||
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
*result = fModel->Name();
|
*result = fModel->Name();
|
||||||
|
|
||||||
fValueDirty = false;
|
fValueDirty = false;
|
||||||
@@ -790,7 +769,7 @@ NameAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
removeExisting = true;
|
removeExisting = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo:
|
// TODO:
|
||||||
// use model-flavor specific virtuals for all of these special
|
// use model-flavor specific virtuals for all of these special
|
||||||
// renamings
|
// renamings
|
||||||
status_t result;
|
status_t result;
|
||||||
@@ -821,7 +800,6 @@ NameAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
return result == B_OK;
|
return result == B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NameAttributeText::sSortFolderNamesFirst = false;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
NameAttributeText::SetSortFolderNamesFirst(bool enabled)
|
NameAttributeText::SetSortFolderNamesFirst(bool enabled)
|
||||||
@@ -830,13 +808,16 @@ NameAttributeText::SetSortFolderNamesFirst(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - owner/group
|
||||||
|
|
||||||
|
|
||||||
#ifdef OWNER_GROUP_ATTRIBUTES
|
#ifdef OWNER_GROUP_ATTRIBUTES
|
||||||
|
|
||||||
|
|
||||||
OwnerAttributeText::OwnerAttributeText(const Model* model,
|
OwnerAttributeText::OwnerAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -862,7 +843,8 @@ OwnerAttributeText::ReadValue(BString *result)
|
|||||||
|
|
||||||
GroupAttributeText::GroupAttributeText(const Model* model,
|
GroupAttributeText::GroupAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -885,10 +867,13 @@ GroupAttributeText::ReadValue(BString *result)
|
|||||||
fValueDirty = false;
|
fValueDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* OWNER_GROUP_ATTRIBUTES */
|
|
||||||
|
#endif // OWNER_GROUP_ATTRIBUTES
|
||||||
|
|
||||||
|
|
||||||
ModeAttributeText::ModeAttributeText(const Model* model, const BColumn* column)
|
ModeAttributeText::ModeAttributeText(const Model* model, const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -929,7 +914,8 @@ ModeAttributeText::ReadValue(BString *result)
|
|||||||
|
|
||||||
|
|
||||||
SizeAttributeText::SizeAttributeText(const Model* model, const BColumn* column)
|
SizeAttributeText::SizeAttributeText(const Model* model, const BColumn* column)
|
||||||
: ScalarAttributeText(model, column)
|
:
|
||||||
|
ScalarAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -979,11 +965,12 @@ SizeAttributeText::PreferredWidth(const BPoseView *pose) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark - time related
|
||||||
|
|
||||||
|
|
||||||
TimeAttributeText::TimeAttributeText(const Model* model, const BColumn* column)
|
TimeAttributeText::TimeAttributeText(const Model* model, const BColumn* column)
|
||||||
: ScalarAttributeText(model, column)
|
:
|
||||||
|
ScalarAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1018,7 +1005,8 @@ TimeAttributeText::CheckSettingsChanged(void)
|
|||||||
|
|
||||||
CreationTimeAttributeText::CreationTimeAttributeText(const Model* model,
|
CreationTimeAttributeText::CreationTimeAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: TimeAttributeText(model, column)
|
:
|
||||||
|
TimeAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,9 +1019,11 @@ CreationTimeAttributeText::ReadValue()
|
|||||||
return fModel->StatBuf()->st_crtime;
|
return fModel->StatBuf()->st_crtime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ModificationTimeAttributeText::ModificationTimeAttributeText(const Model* model,
|
ModificationTimeAttributeText::ModificationTimeAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: TimeAttributeText(model, column)
|
:
|
||||||
|
TimeAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1052,7 +1042,8 @@ ModificationTimeAttributeText::ReadValue()
|
|||||||
|
|
||||||
GenericAttributeText::GenericAttributeText(const Model* model,
|
GenericAttributeText::GenericAttributeText(const Model* model,
|
||||||
const BColumn* column)
|
const BColumn* column)
|
||||||
: StringAttributeText(model, column)
|
:
|
||||||
|
StringAttributeText(model, column)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1234,18 +1225,20 @@ GenericAttributeText::FitValue(BString *result, const BPoseView *view)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case B_OFF_T_TYPE:
|
case B_OFF_T_TYPE:
|
||||||
// as a side effect update the fFullValueText to the string representation
|
// As a side effect update the fFullValueText to the string
|
||||||
// of value
|
// representation of value
|
||||||
TruncFileSize(&fFullValueText, fValue.off_tt, view, 100000);
|
TruncFileSize(&fFullValueText, fValue.off_tt, view, 100000);
|
||||||
fTruncatedWidth = TruncFileSize(result, fValue.off_tt, view, fOldWidth);
|
fTruncatedWidth = TruncFileSize(result, fValue.off_tt, view,
|
||||||
|
fOldWidth);
|
||||||
fDirty = false;
|
fDirty = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case B_TIME_TYPE:
|
case B_TIME_TYPE:
|
||||||
// as a side effect update the fFullValueText to the string representation
|
// As a side effect update the fFullValueText to the string
|
||||||
// of value
|
// representation of value
|
||||||
TruncTime(&fFullValueText, fValue.time_tt, view, 100000);
|
TruncTime(&fFullValueText, fValue.time_tt, view, 100000);
|
||||||
fTruncatedWidth = TruncTime(result, fValue.time_tt, view, fOldWidth);
|
fTruncatedWidth = TruncTime(result, fValue.time_tt, view,
|
||||||
|
fOldWidth);
|
||||||
fDirty = false;
|
fDirty = false;
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -1503,8 +1496,8 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case B_STRING_TYPE:
|
case B_STRING_TYPE:
|
||||||
size = fModel->WriteAttr(columnName,
|
size = fModel->WriteAttr(columnName, type, 0, textView->Text(),
|
||||||
type, 0, textView->Text(), (size_t)(textView->TextLength() + 1));
|
(size_t)(textView->TextLength() + 1));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case B_BOOL_TYPE:
|
case B_BOOL_TYPE:
|
||||||
@@ -1546,10 +1539,13 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
if (sscanf(textView->Text(), "%f", &floatVal) == 1) {
|
if (sscanf(textView->Text(), "%f", &floatVal) == 1) {
|
||||||
fValueIsDefined = true;
|
fValueIsDefined = true;
|
||||||
fValue.floatt = floatVal;
|
fValue.floatt = floatVal;
|
||||||
size = fModel->WriteAttr(columnName, type, 0, &floatVal, sizeof(float));
|
size = fModel->WriteAttr(columnName, type, 0, &floatVal,
|
||||||
} else
|
sizeof(float));
|
||||||
// If the value was already defined, it's on disk. Otherwise not.
|
} else {
|
||||||
|
// If the value was already defined, it's on disk.
|
||||||
|
// Otherwise not.
|
||||||
return fValueIsDefined;
|
return fValueIsDefined;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1560,10 +1556,13 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
if (sscanf(textView->Text(), "%lf", &doubleVal) == 1) {
|
if (sscanf(textView->Text(), "%lf", &doubleVal) == 1) {
|
||||||
fValueIsDefined = true;
|
fValueIsDefined = true;
|
||||||
fValue.doublet = doubleVal;
|
fValue.doublet = doubleVal;
|
||||||
size = fModel->WriteAttr(columnName, type, 0, &doubleVal, sizeof(double));
|
size = fModel->WriteAttr(columnName, type, 0, &doubleVal,
|
||||||
} else
|
sizeof(double));
|
||||||
// If the value was already defined, it's on disk. Otherwise not.
|
} else {
|
||||||
|
// If the value was already defined, it's on disk.
|
||||||
|
// Otherwise not.
|
||||||
return fValueIsDefined;
|
return fValueIsDefined;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1649,7 +1648,8 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
|||||||
|
|
||||||
OpenWithRelationAttributeText::OpenWithRelationAttributeText(const Model* model,
|
OpenWithRelationAttributeText::OpenWithRelationAttributeText(const Model* model,
|
||||||
const BColumn* column, const BPoseView* view)
|
const BColumn* column, const BPoseView* view)
|
||||||
: ScalarAttributeText(model, column),
|
:
|
||||||
|
ScalarAttributeText(model, column),
|
||||||
fPoseView(view)
|
fPoseView(view)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1660,9 +1660,9 @@ OpenWithRelationAttributeText::ReadValue()
|
|||||||
{
|
{
|
||||||
fValueDirty = false;
|
fValueDirty = false;
|
||||||
|
|
||||||
const OpenWithPoseView *view = dynamic_cast<const OpenWithPoseView *>(fPoseView);
|
const OpenWithPoseView* view
|
||||||
|
= dynamic_cast<const OpenWithPoseView*>(fPoseView);
|
||||||
if (view) {
|
if (view != NULL) {
|
||||||
fValue = view->OpenWithRelation(fModel);
|
fValue = view->OpenWithRelation(fModel);
|
||||||
fValueIsDefined = true;
|
fValueIsDefined = true;
|
||||||
}
|
}
|
||||||
@@ -1703,7 +1703,8 @@ OpenWithRelationAttributeText::FitValue(BString *result, const BPoseView *view)
|
|||||||
|
|
||||||
VersionAttributeText::VersionAttributeText(const Model* model,
|
VersionAttributeText::VersionAttributeText(const Model* model,
|
||||||
const BColumn* column, bool app)
|
const BColumn* column, bool app)
|
||||||
: StringAttributeText(model, column),
|
:
|
||||||
|
StringAttributeText(model, column),
|
||||||
fAppVersion(app)
|
fAppVersion(app)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1720,8 +1721,8 @@ VersionAttributeText::ReadValue(BString *result)
|
|||||||
BAppFileInfo info(file);
|
BAppFileInfo info(file);
|
||||||
version_info version;
|
version_info version;
|
||||||
if (info.InitCheck() == B_OK
|
if (info.InitCheck() == B_OK
|
||||||
&& info.GetVersionInfo(&version,
|
&& info.GetVersionInfo(&version, fAppVersion
|
||||||
fAppVersion ? B_APP_VERSION_KIND : B_SYSTEM_VERSION_KIND) == B_OK) {
|
? B_APP_VERSION_KIND : B_SYSTEM_VERSION_KIND) == B_OK) {
|
||||||
*result = version.short_info;
|
*result = version.short_info;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user