1 // Copyright 1999, Be Incorporated. All Rights Reserved.
2 // Copyright 2000-2004, Jun Suzuki. All Rights Reserved.
3 // Copyright 2007, 2009 Stephan Aßmus. All Rights Reserved.
4 // This file may be used under the terms of the Be Sample Code License.
7 #include "MediaFileListView.h"
11 #include <Application.h>
12 #include <MediaFile.h>
13 #include <Messenger.h>
15 #include "MediaConverterWindow.h"
16 #include "MessageConstants.h"
19 // #pragma mark - MediaFileListItem
22 MediaFileListItem::MediaFileListItem(BMediaFile
* file
, const entry_ref
& ref
)
24 BStringItem(ref
.name
),
31 MediaFileListItem::~MediaFileListItem()
37 // #pragma mark - MediaFileListView
40 MediaFileListView::MediaFileListView()
42 BListView("MediaFileListView", B_SINGLE_SELECTION_LIST
, B_WILL_DRAW
43 | B_NAVIGABLE
| B_FRAME_EVENTS
)
49 MediaFileListView::~MediaFileListView()
52 while ((item
= RemoveItem((int32
)0)) != NULL
) {
59 MediaFileListView::SetEnabled(bool enabled
)
61 if (enabled
== fEnabled
)
65 // TODO: visual indication of enabled status?
70 MediaFileListView::IsEnabled() const
77 MediaFileListView::AddMediaItem(BMediaFile
* file
, const entry_ref
& ref
)
79 MediaFileListItem
* item
= new(std::nothrow
) MediaFileListItem(file
, ref
);
80 if (item
== NULL
|| !AddItem(item
)) {
84 be_app_messenger
.SendMessage(FILE_LIST_CHANGE_MESSAGE
);
90 MediaFileListView::KeyDown(const char *bytes
, int32 numBytes
)
95 int32 selection
= CurrentSelection();
97 delete RemoveItem(selection
);
98 // select the previous item
99 int32 count
= CountItems();
100 if (selection
>= count
)
101 selection
= count
- 1;
103 be_app_messenger
.SendMessage(FILE_LIST_CHANGE_MESSAGE
);
108 BListView::KeyDown(bytes
, numBytes
);
114 MediaFileListView::SelectionChanged()
116 MediaConverterWindow
* win
= dynamic_cast<MediaConverterWindow
*>(Window());
118 win
->SourceFileSelectionChanged();