* 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:
@@ -54,6 +54,8 @@ const uint32 kMsgSamePreferredAppAs = 'spaa';
|
|||||||
const uint32 kMsgTypeEntered = 'type';
|
const uint32 kMsgTypeEntered = 'type';
|
||||||
const uint32 kMsgDescriptionEntered = 'dsce';
|
const uint32 kMsgDescriptionEntered = 'dsce';
|
||||||
|
|
||||||
|
const uint32 kMsgToggleIcons = 'tgic';
|
||||||
|
|
||||||
const struct type_map {
|
const struct type_map {
|
||||||
const char* name;
|
const char* name;
|
||||||
type_code type;
|
type_code type;
|
||||||
@@ -486,7 +488,12 @@ FileTypesWindow::FileTypesWindow(BRect frame)
|
|||||||
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
|
menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
|
||||||
'Q', B_COMMAND_KEY));
|
'Q', B_COMMAND_KEY));
|
||||||
menu->SetTargetForItems(be_app);
|
menu->SetTargetForItems(be_app);
|
||||||
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
|
menu = new BMenu("Settings");
|
||||||
|
item = new BMenuItem("Show Icons in List", new BMessage(kMsgToggleIcons));
|
||||||
item->SetTarget(this);
|
item->SetTarget(this);
|
||||||
|
menu->AddItem(item);
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
// MIME Types list
|
// MIME Types list
|
||||||
@@ -1093,6 +1100,17 @@ void
|
|||||||
FileTypesWindow::MessageReceived(BMessage* message)
|
FileTypesWindow::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
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:
|
case kMsgTypeSelected:
|
||||||
{
|
{
|
||||||
int32 index;
|
int32 index;
|
||||||
|
|||||||
@@ -235,6 +235,14 @@ MimeTypeItem::AddSubtype()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
MimeTypeItem::ShowIcon(bool showIcon)
|
||||||
|
{
|
||||||
|
fShowIcon = showIcon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/
|
||||||
int
|
int
|
||||||
MimeTypeItem::Compare(const BListItem* a, const BListItem* b)
|
MimeTypeItem::Compare(const BListItem* a, const BListItem* b)
|
||||||
{
|
{
|
||||||
@@ -257,6 +265,7 @@ MimeTypeItem::Compare(const BListItem* a, const BListItem* b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*static*/
|
||||||
int
|
int
|
||||||
MimeTypeItem::CompareLabels(const BListItem* a, const BListItem* b)
|
MimeTypeItem::CompareLabels(const BListItem* a, const BListItem* b)
|
||||||
{
|
{
|
||||||
@@ -592,3 +601,37 @@ MimeTypeListView::UpdateItem(MimeTypeItem* item)
|
|||||||
InvalidateItem(IndexOf(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 UpdateText();
|
||||||
void AddSubtype();
|
void AddSubtype();
|
||||||
|
void ShowIcon(bool showIcon);
|
||||||
|
|
||||||
static int Compare(const BListItem* a, const BListItem* b);
|
static int Compare(const BListItem* a, const BListItem* b);
|
||||||
static int CompareLabels(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 UpdateItem(MimeTypeItem* item);
|
||||||
|
|
||||||
|
void ShowIcons(bool showIcons);
|
||||||
|
bool IsShowingIcons() const { return fShowIcons; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user