-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathContentColumnView.h
More file actions
117 lines (98 loc) · 3.01 KB
/
ContentColumnView.h
File metadata and controls
117 lines (98 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef CONTENT_COLUMN_VIEW_H
#define CONTENT_COLUMN_VIEW_H
#include "MediaItem.h"
#include "Messages.h"
#include <ColumnListView.h>
#include <ColumnTypes.h>
#include <MessageFilter.h>
#include <PopUpMenu.h>
#include <map>
#include <vector>
/**
* @class ContentColumnView
* @brief The main list view displaying the audio library.
*
* It supports:
* - Multi-column display (Title, Artist, Album, etc.).
* - Sorting by clicking column headers.
* - Drag & Drop of items.
* - Context menus.
* - Asynchronous chunked loading to keep the UI responsive.
* - Graying out missing files.
*/
class ContentColumnView : public BColumnListView {
public:
ContentColumnView(const char *name);
virtual ~ContentColumnView();
/**
* @brief Adds a single media item to the view.
*/
void AddEntry(const MediaItem &mi);
/**
* @brief Adds a list of items asynchronously (chunked).
*/
void AddEntries(const std::vector<MediaItem> &items);
void ClearEntries();
void RefreshScrollbars();
static constexpr uint32 kMsgShowCtx = MSG_SHOW_CONTEXT_MENU;
const MediaItem *SelectedItem() const;
const MediaItem *ItemAt(int32 index) const;
bool IsRowMissing(BRow *row) const;
/**
* @brief Sets the path of the currently playing track.
* The row with this path will be rendered in bold.
*/
void SetNowPlayingPath(const BString &path);
const BString &NowPlayingPath() const { return fNowPlayingPath; }
/**
* @brief Updates the rating display for a specific file path.
* @param path The file path to update
* @param rating The new rating value (0-10)
*/
void UpdateRating(const BString &path, int32 rating);
/**
* @brief Reloads metadata for a single file from disk.
*/
void ReloadEntry(const BString &path);
void SaveState(BMessage *msg);
void LoadState(BMessage *msg);
protected:
bool InitiateDrag(BPoint point, bool wasSelected) override;
void KeyDown(const char *bytes, int32 numBytes) override;
void MouseMoved(BPoint where, uint32 transit,
const BMessage *dragMsg) override;
void AttachedToWindow() override;
void DetachedFromWindow() override;
void MessageReceived(BMessage *msg) override;
private:
/** @name Filters */
///@{
class RightClickFilter;
class DropFilter;
RightClickFilter *fRCFilter = nullptr;
DropFilter *fDropFilter = nullptr;
///@}
void ShowContextMenu(BPoint screenWhere);
/**
* @note fRowMap seemed unused in the .cpp, but keeping declaration if needed
* later.
*/
std::map<BRow *, MediaItem> fRowMap;
/** @name Chunked loading state */
///@{
std::vector<MediaItem> fPendingItems;
size_t fPendingIndex = 0;
void _AddBatch(size_t count);
static constexpr uint32 kMsgChunkAdd = 'chnk';
///@}
/** @name Internal drag-drop reordering */
///@{
int32 fDragSourceIndex = -1;
BPoint fLastDropPoint;
///@}
/** @name Now playing indicator */
///@{
BString fNowPlayingPath;
///@}
};
#endif