* 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.
|
||||
*/
|
||||
|
||||
#include <fs_attr.h>
|
||||
|
||||
#include "WidgetAttributeText.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <fs_attr.h>
|
||||
#include <parsedate.h>
|
||||
|
||||
#include <Alert.h>
|
||||
@@ -60,8 +64,6 @@ All rights reserved.
|
||||
#include "SettingsViews.h"
|
||||
#include "Utilities.h"
|
||||
#include "ViewState.h"
|
||||
#include "WidgetAttributeText.h"
|
||||
|
||||
|
||||
|
||||
#undef B_TRANSLATE_CONTEXT
|
||||
@@ -70,135 +72,6 @@ All rights reserved.
|
||||
|
||||
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[] = {
|
||||
"%.2f %s",
|
||||
"%.1f %s",
|
||||
@@ -208,6 +81,9 @@ const char *kSizeFormats[] = {
|
||||
};
|
||||
|
||||
|
||||
bool NameAttributeText::sSortFolderNamesFirst = false;
|
||||
|
||||
|
||||
template <class View>
|
||||
float
|
||||
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
|
||||
WidgetAttributeText::TruncFileSize(BString *result, int64 value,
|
||||
const BPoseView *view, float width)
|
||||
TruncStringBase(BString* result, const char* str, int32 length,
|
||||
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>
|
||||
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
|
||||
WidgetAttributeText::TruncTime(BString* result, int64 value,
|
||||
const BPoseView* view, float width)
|
||||
@@ -352,8 +361,8 @@ WidgetAttributeText::CommitEditedText(BTextView *)
|
||||
|
||||
status_t
|
||||
WidgetAttributeText::AttrAsString(const Model* model, BString* result,
|
||||
const char *attrName, int32 attrType,
|
||||
float width, BView *view, int64 *resultingValue)
|
||||
const char* attrName, int32 attrType, float width, BView* view,
|
||||
int64* resultingValue)
|
||||
{
|
||||
int64 value;
|
||||
|
||||
@@ -436,7 +445,8 @@ WidgetAttributeText::SetDirty(bool value)
|
||||
|
||||
StringAttributeText::StringAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: WidgetAttributeText(model, column),
|
||||
:
|
||||
WidgetAttributeText(model, column),
|
||||
fValueDirty(true)
|
||||
{
|
||||
}
|
||||
@@ -508,13 +518,15 @@ StringAttributeText::CommitEditedText(BTextView *textView)
|
||||
ASSERT(fColumn->Editable());
|
||||
const char* text = textView->Text();
|
||||
|
||||
if (fFullValueText == text)
|
||||
if (fFullValueText == text) {
|
||||
// no change
|
||||
return false;
|
||||
}
|
||||
|
||||
if (textView->TextLength() == 0)
|
||||
if (textView->TextLength() == 0) {
|
||||
// cannot do an empty name
|
||||
return false;
|
||||
}
|
||||
|
||||
// cause re-truncation
|
||||
fDirty = true;
|
||||
@@ -534,7 +546,8 @@ StringAttributeText::CommitEditedText(BTextView *textView)
|
||||
|
||||
ScalarAttributeText::ScalarAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: WidgetAttributeText(model, column),
|
||||
:
|
||||
WidgetAttributeText(model, column),
|
||||
fValueDirty(true)
|
||||
{
|
||||
}
|
||||
@@ -591,7 +604,8 @@ ScalarAttributeText::Compare(WidgetAttributeText &attr, BPoseView *)
|
||||
|
||||
|
||||
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,
|
||||
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)
|
||||
: StringAttributeText(model, column)
|
||||
:
|
||||
StringAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -668,7 +684,8 @@ KindAttributeText::ReadValue(BString *result)
|
||||
|
||||
|
||||
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)
|
||||
return fModel->CompareFolderNamesFirst(attr.TargetModel());
|
||||
|
||||
return NaturalCompare(fFullValueText.String(), compareTo->ValueAsText(view));
|
||||
return NaturalCompare(fFullValueText.String(),
|
||||
compareTo->ValueAsText(view));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
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();
|
||||
|
||||
fValueDirty = false;
|
||||
@@ -790,7 +769,7 @@ NameAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
removeExisting = true;
|
||||
}
|
||||
|
||||
// ToDo:
|
||||
// TODO:
|
||||
// use model-flavor specific virtuals for all of these special
|
||||
// renamings
|
||||
status_t result;
|
||||
@@ -821,7 +800,6 @@ NameAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
return result == B_OK;
|
||||
}
|
||||
|
||||
bool NameAttributeText::sSortFolderNamesFirst = false;
|
||||
|
||||
void
|
||||
NameAttributeText::SetSortFolderNamesFirst(bool enabled)
|
||||
@@ -830,13 +808,16 @@ NameAttributeText::SetSortFolderNamesFirst(bool enabled)
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
// #pragma mark - owner/group
|
||||
|
||||
|
||||
#ifdef OWNER_GROUP_ATTRIBUTES
|
||||
|
||||
|
||||
OwnerAttributeText::OwnerAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: StringAttributeText(model, column)
|
||||
:
|
||||
StringAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -862,7 +843,8 @@ OwnerAttributeText::ReadValue(BString *result)
|
||||
|
||||
GroupAttributeText::GroupAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: StringAttributeText(model, column)
|
||||
:
|
||||
StringAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -885,10 +867,13 @@ GroupAttributeText::ReadValue(BString *result)
|
||||
fValueDirty = false;
|
||||
}
|
||||
|
||||
#endif /* OWNER_GROUP_ATTRIBUTES */
|
||||
|
||||
#endif // OWNER_GROUP_ATTRIBUTES
|
||||
|
||||
|
||||
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)
|
||||
: 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)
|
||||
: ScalarAttributeText(model, column)
|
||||
:
|
||||
ScalarAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1018,7 +1005,8 @@ TimeAttributeText::CheckSettingsChanged(void)
|
||||
|
||||
CreationTimeAttributeText::CreationTimeAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: TimeAttributeText(model, column)
|
||||
:
|
||||
TimeAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1031,9 +1019,11 @@ CreationTimeAttributeText::ReadValue()
|
||||
return fModel->StatBuf()->st_crtime;
|
||||
}
|
||||
|
||||
|
||||
ModificationTimeAttributeText::ModificationTimeAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: TimeAttributeText(model, column)
|
||||
:
|
||||
TimeAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1052,7 +1042,8 @@ ModificationTimeAttributeText::ReadValue()
|
||||
|
||||
GenericAttributeText::GenericAttributeText(const Model* model,
|
||||
const BColumn* column)
|
||||
: StringAttributeText(model, column)
|
||||
:
|
||||
StringAttributeText(model, column)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -1234,18 +1225,20 @@ GenericAttributeText::FitValue(BString *result, const BPoseView *view)
|
||||
return;
|
||||
|
||||
case B_OFF_T_TYPE:
|
||||
// as a side effect update the fFullValueText to the string representation
|
||||
// of value
|
||||
// As a side effect update the fFullValueText to the string
|
||||
// representation of value
|
||||
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;
|
||||
return;
|
||||
|
||||
case B_TIME_TYPE:
|
||||
// as a side effect update the fFullValueText to the string representation
|
||||
// of value
|
||||
// As a side effect update the fFullValueText to the string
|
||||
// representation of value
|
||||
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;
|
||||
return;
|
||||
|
||||
@@ -1503,8 +1496,8 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
|
||||
switch (type) {
|
||||
case B_STRING_TYPE:
|
||||
size = fModel->WriteAttr(columnName,
|
||||
type, 0, textView->Text(), (size_t)(textView->TextLength() + 1));
|
||||
size = fModel->WriteAttr(columnName, type, 0, textView->Text(),
|
||||
(size_t)(textView->TextLength() + 1));
|
||||
break;
|
||||
|
||||
case B_BOOL_TYPE:
|
||||
@@ -1546,10 +1539,13 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
if (sscanf(textView->Text(), "%f", &floatVal) == 1) {
|
||||
fValueIsDefined = true;
|
||||
fValue.floatt = floatVal;
|
||||
size = fModel->WriteAttr(columnName, type, 0, &floatVal, sizeof(float));
|
||||
} else
|
||||
// If the value was already defined, it's on disk. Otherwise not.
|
||||
size = fModel->WriteAttr(columnName, type, 0, &floatVal,
|
||||
sizeof(float));
|
||||
} else {
|
||||
// If the value was already defined, it's on disk.
|
||||
// Otherwise not.
|
||||
return fValueIsDefined;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1560,10 +1556,13 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
if (sscanf(textView->Text(), "%lf", &doubleVal) == 1) {
|
||||
fValueIsDefined = true;
|
||||
fValue.doublet = doubleVal;
|
||||
size = fModel->WriteAttr(columnName, type, 0, &doubleVal, sizeof(double));
|
||||
} else
|
||||
// If the value was already defined, it's on disk. Otherwise not.
|
||||
size = fModel->WriteAttr(columnName, type, 0, &doubleVal,
|
||||
sizeof(double));
|
||||
} else {
|
||||
// If the value was already defined, it's on disk.
|
||||
// Otherwise not.
|
||||
return fValueIsDefined;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1649,7 +1648,8 @@ GenericAttributeText::CommitEditedTextFlavor(BTextView *textView)
|
||||
|
||||
OpenWithRelationAttributeText::OpenWithRelationAttributeText(const Model* model,
|
||||
const BColumn* column, const BPoseView* view)
|
||||
: ScalarAttributeText(model, column),
|
||||
:
|
||||
ScalarAttributeText(model, column),
|
||||
fPoseView(view)
|
||||
{
|
||||
}
|
||||
@@ -1660,9 +1660,9 @@ OpenWithRelationAttributeText::ReadValue()
|
||||
{
|
||||
fValueDirty = false;
|
||||
|
||||
const OpenWithPoseView *view = dynamic_cast<const OpenWithPoseView *>(fPoseView);
|
||||
|
||||
if (view) {
|
||||
const OpenWithPoseView* view
|
||||
= dynamic_cast<const OpenWithPoseView*>(fPoseView);
|
||||
if (view != NULL) {
|
||||
fValue = view->OpenWithRelation(fModel);
|
||||
fValueIsDefined = true;
|
||||
}
|
||||
@@ -1703,7 +1703,8 @@ OpenWithRelationAttributeText::FitValue(BString *result, const BPoseView *view)
|
||||
|
||||
VersionAttributeText::VersionAttributeText(const Model* model,
|
||||
const BColumn* column, bool app)
|
||||
: StringAttributeText(model, column),
|
||||
:
|
||||
StringAttributeText(model, column),
|
||||
fAppVersion(app)
|
||||
{
|
||||
}
|
||||
@@ -1720,8 +1721,8 @@ VersionAttributeText::ReadValue(BString *result)
|
||||
BAppFileInfo info(file);
|
||||
version_info version;
|
||||
if (info.InitCheck() == B_OK
|
||||
&& info.GetVersionInfo(&version,
|
||||
fAppVersion ? B_APP_VERSION_KIND : B_SYSTEM_VERSION_KIND) == B_OK) {
|
||||
&& info.GetVersionInfo(&version, fAppVersion
|
||||
? B_APP_VERSION_KIND : B_SYSTEM_VERSION_KIND) == B_OK) {
|
||||
*result = version.short_info;
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user