* Only those controls are updated now, that were actually changed, including
references from other types. * Since the MimeTypeListView now listens to changes automatically, it's no longer necessary to update the MimeTypeListView manually anymore. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16364 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -881,13 +881,25 @@ FileTypesWindow::_UpdatePreferredApps(BMimeType* type)
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
FileTypesWindow::_SetType(BMimeType* type, bool forceUpdate)
|
FileTypesWindow::_UpdateIcon(BMimeType* type)
|
||||||
|
{
|
||||||
|
fIconView->SetTo(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
FileTypesWindow::_SetType(BMimeType* type, int32 forceUpdate)
|
||||||
{
|
{
|
||||||
bool enabled = type != NULL;
|
bool enabled = type != NULL;
|
||||||
|
|
||||||
|
// update controls
|
||||||
|
|
||||||
if (type != NULL) {
|
if (type != NULL) {
|
||||||
if (fCurrentType == *type && !forceUpdate)
|
if (fCurrentType == *type) {
|
||||||
return;
|
if (!forceUpdate)
|
||||||
|
return;
|
||||||
|
} else
|
||||||
|
forceUpdate = B_EVERYTHING_CHANGED;
|
||||||
|
|
||||||
if (&fCurrentType != type)
|
if (&fCurrentType != type)
|
||||||
fCurrentType.SetTo(type->Type());
|
fCurrentType.SetTo(type->Type());
|
||||||
@@ -895,13 +907,18 @@ FileTypesWindow::_SetType(BMimeType* type, bool forceUpdate)
|
|||||||
fInternalNameControl->SetText(type->Type());
|
fInternalNameControl->SetText(type->Type());
|
||||||
|
|
||||||
char description[B_MIME_TYPE_LENGTH];
|
char description[B_MIME_TYPE_LENGTH];
|
||||||
if (type->GetShortDescription(description) != B_OK)
|
|
||||||
description[0] = '\0';
|
|
||||||
fTypeNameControl->SetText(description);
|
|
||||||
|
|
||||||
if (type->GetLongDescription(description) != B_OK)
|
if ((forceUpdate & B_SHORT_DESCRIPTION_CHANGED) != 0) {
|
||||||
description[0] = '\0';
|
if (type->GetShortDescription(description) != B_OK)
|
||||||
fDescriptionControl->SetText(description);
|
description[0] = '\0';
|
||||||
|
fTypeNameControl->SetText(description);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((forceUpdate & B_LONG_DESCRIPTION_CHANGED) != 0) {
|
||||||
|
if (type->GetLongDescription(description) != B_OK)
|
||||||
|
description[0] = '\0';
|
||||||
|
fDescriptionControl->SetText(description);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
fCurrentType.Unset();
|
fCurrentType.Unset();
|
||||||
fInternalNameControl->SetText(NULL);
|
fInternalNameControl->SetText(NULL);
|
||||||
@@ -909,10 +926,19 @@ FileTypesWindow::_SetType(BMimeType* type, bool forceUpdate)
|
|||||||
fDescriptionControl->SetText(NULL);
|
fDescriptionControl->SetText(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
_UpdateExtensions(type);
|
if ((forceUpdate & B_FILE_EXTENSIONS_CHANGED) != 0)
|
||||||
_UpdatePreferredApps(type);
|
_UpdateExtensions(type);
|
||||||
fIconView->SetTo(type);
|
|
||||||
fAttributeListView->SetTo(type);
|
if ((forceUpdate & B_PREFERRED_APP_CHANGED) != 0)
|
||||||
|
_UpdatePreferredApps(type);
|
||||||
|
|
||||||
|
if ((forceUpdate & (B_ICON_CHANGED | B_PREFERRED_APP_CHANGED)) != 0)
|
||||||
|
_UpdateIcon(type);
|
||||||
|
|
||||||
|
if ((forceUpdate & B_ATTR_INFO_CHANGED) != 0)
|
||||||
|
fAttributeListView->SetTo(type);
|
||||||
|
|
||||||
|
// enable/disable controls
|
||||||
|
|
||||||
fIconView->SetEnabled(enabled);
|
fIconView->SetEnabled(enabled);
|
||||||
|
|
||||||
@@ -980,11 +1006,6 @@ FileTypesWindow::MessageReceived(BMessage* message)
|
|||||||
case kMsgTypeEntered:
|
case kMsgTypeEntered:
|
||||||
{
|
{
|
||||||
fCurrentType.SetShortDescription(fTypeNameControl->Text());
|
fCurrentType.SetShortDescription(fTypeNameControl->Text());
|
||||||
|
|
||||||
MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(
|
|
||||||
fTypeListView->ItemAt(fTypeListView->CurrentSelection()));
|
|
||||||
if (item != NULL)
|
|
||||||
fTypeListView->UpdateItem(item);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1030,11 +1051,23 @@ FileTypesWindow::MessageReceived(BMessage* message)
|
|||||||
|| message->FindInt32("be:which", &which) != B_OK)
|
|| message->FindInt32("be:which", &which) != B_OK)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (fCurrentType.Type() != NULL && !strcasecmp(fCurrentType.Type(), type)) {
|
if (fCurrentType.Type() == NULL)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!strcasecmp(fCurrentType.Type(), type)) {
|
||||||
if (which != B_MIME_TYPE_DELETED)
|
if (which != B_MIME_TYPE_DELETED)
|
||||||
_SetType(&fCurrentType, true);
|
_SetType(&fCurrentType, which);
|
||||||
else
|
else
|
||||||
_SetType(NULL);
|
_SetType(NULL);
|
||||||
|
} else {
|
||||||
|
// this change could still affect our current type
|
||||||
|
|
||||||
|
if (which == B_MIME_TYPE_DELETED
|
||||||
|
|| which == B_PREFERRED_APP_CHANGED
|
||||||
|
|| which == B_ICON_FOR_TYPE_CHANGED) {
|
||||||
|
_UpdatePreferredApps(&fCurrentType);
|
||||||
|
_UpdateIcon(&fCurrentType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ class FileTypesWindow : public BWindow {
|
|||||||
void _UpdateExtensions(BMimeType* type);
|
void _UpdateExtensions(BMimeType* type);
|
||||||
void _AddSignature(BMenuItem* item, const char* signature);
|
void _AddSignature(BMenuItem* item, const char* signature);
|
||||||
void _UpdatePreferredApps(BMimeType* type);
|
void _UpdatePreferredApps(BMimeType* type);
|
||||||
void _SetType(BMimeType* type, bool forceUpdate = false);
|
void _UpdateIcon(BMimeType* type);
|
||||||
|
void _SetType(BMimeType* type, int32 forceUpdate = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BMimeType fCurrentType;
|
BMimeType fCurrentType;
|
||||||
|
|||||||
Reference in New Issue
Block a user