* The MimeTypeListView now supports switching to icon mode and back without
needing to reconstruct it. * The file types list can now show icons, too (you can enable it using the menu) git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16418 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
688b1b719c
commit
84506c140e
@ -54,6 +54,8 @@ const uint32 kMsgSamePreferredAppAs = 'spaa';
|
||||
const uint32 kMsgTypeEntered = 'type';
|
||||
const uint32 kMsgDescriptionEntered = 'dsce';
|
||||
|
||||
const uint32 kMsgToggleIcons = 'tgic';
|
||||
|
||||
const struct type_map {
|
||||
const char* name;
|
||||
type_code type;
|
||||
@ -486,7 +488,12 @@ FileTypesWindow::FileTypesWindow(BRect frame)
|
||||
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
|
||||
'Q', B_COMMAND_KEY));
|
||||
menu->SetTargetForItems(be_app);
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
menu = new BMenu("Settings");
|
||||
item = new BMenuItem("Show Icons in List", new BMessage(kMsgToggleIcons));
|
||||
item->SetTarget(this);
|
||||
menu->AddItem(item);
|
||||
menuBar->AddItem(menu);
|
||||
|
||||
// MIME Types list
|
||||
@ -1093,6 +1100,17 @@ void
|
||||
FileTypesWindow::MessageReceived(BMessage* message)
|
||||
{
|
||||
switch (message->what) {
|
||||
case kMsgToggleIcons:
|
||||
{
|
||||
BMenuItem* item;
|
||||
if (message->FindPointer("source", (void **)&item) != B_OK)
|
||||
break;
|
||||
|
||||
item->SetMarked(!fTypeListView->IsShowingIcons());
|
||||
fTypeListView->ShowIcons(item->IsMarked());
|
||||
break;
|
||||
}
|
||||
|
||||
case kMsgTypeSelected:
|
||||
{
|
||||
int32 index;
|
||||
|
@ -235,6 +235,14 @@ MimeTypeItem::AddSubtype()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MimeTypeItem::ShowIcon(bool showIcon)
|
||||
{
|
||||
fShowIcon = showIcon;
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
int
|
||||
MimeTypeItem::Compare(const BListItem* a, const BListItem* b)
|
||||
{
|
||||
@ -257,6 +265,7 @@ MimeTypeItem::Compare(const BListItem* a, const BListItem* b)
|
||||
}
|
||||
|
||||
|
||||
/*static*/
|
||||
int
|
||||
MimeTypeItem::CompareLabels(const BListItem* a, const BListItem* b)
|
||||
{
|
||||
@ -592,3 +601,37 @@ MimeTypeListView::UpdateItem(MimeTypeItem* item)
|
||||
InvalidateItem(IndexOf(item));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MimeTypeListView::ShowIcons(bool showIcons)
|
||||
{
|
||||
if (showIcons == fShowIcons)
|
||||
return;
|
||||
|
||||
fShowIcons = showIcons;
|
||||
|
||||
if (Window() == NULL)
|
||||
return;
|
||||
|
||||
// update items
|
||||
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
|
||||
for (int32 i = FullListCountItems(); i-- > 0;) {
|
||||
MimeTypeItem* item = dynamic_cast<MimeTypeItem*>(FullListItemAt(i));
|
||||
if (item == NULL)
|
||||
continue;
|
||||
|
||||
if (!item->IsSupertypeOnly())
|
||||
item->ShowIcon(showIcons);
|
||||
|
||||
item->Update(this, &font);
|
||||
}
|
||||
|
||||
FrameResized(Bounds().Width(), Bounds().Height());
|
||||
// update scroller
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,7 @@ class MimeTypeItem : public BStringItem {
|
||||
|
||||
void UpdateText();
|
||||
void AddSubtype();
|
||||
void ShowIcon(bool showIcon);
|
||||
|
||||
static int Compare(const BListItem* a, const BListItem* b);
|
||||
static int CompareLabels(const BListItem* a, const BListItem* b);
|
||||
@ -62,6 +63,9 @@ class MimeTypeListView : public BOutlineListView {
|
||||
|
||||
void UpdateItem(MimeTypeItem* item);
|
||||
|
||||
void ShowIcons(bool showIcons);
|
||||
bool IsShowingIcons() const { return fShowIcons; }
|
||||
|
||||
protected:
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
|
Loading…
Reference in New Issue
Block a user