4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
< |
#include <foreach.hpp> |
7 |
> |
#include <iostream> |
8 |
|
|
9 |
< |
#include <sqlite3.h> |
9 |
> |
#include <foreach.hpp> |
10 |
|
|
11 |
|
#include "MenuList.hpp" |
12 |
|
|
20 |
|
{ |
21 |
|
} |
22 |
|
|
23 |
+ |
MenuList::MenuList(MenuList *parent) : parent(parent), display(parent->display), cursor(0), list(1) |
24 |
+ |
{ |
25 |
+ |
} |
26 |
+ |
|
27 |
|
MenuList::~MenuList() |
28 |
|
{ |
29 |
|
_foreach (std::vector<MenuItem *>, item, list) |
30 |
|
delete *item; |
31 |
+ |
|
32 |
+ |
if (parent != NULL && parent != this) |
33 |
+ |
delete parent; |
34 |
|
} |
35 |
|
|
36 |
|
MenuList *MenuList::Enter() |
50 |
|
|
51 |
|
MenuList *MenuList::Left() |
52 |
|
{ |
53 |
+ |
MenuList *parent(this->parent); |
54 |
+ |
|
55 |
+ |
if (parent != this) |
56 |
+ |
{ |
57 |
+ |
this->parent = NULL; |
58 |
+ |
|
59 |
+ |
delete this; |
60 |
+ |
} |
61 |
+ |
|
62 |
|
return parent; |
63 |
|
} |
64 |
|
|
66 |
|
{ |
67 |
|
display.SetCursorPosition(19, cursor); |
68 |
|
|
69 |
+ |
size_t size(list.size()); |
70 |
+ |
|
71 |
|
if (this != previous || state != old) |
72 |
|
{ |
73 |
< |
display.Set(0, 0, (state.bottom != 0 ? '\x1a' : ' ')); |
73 |
> |
display.Set(0, 0, (state.top != 0 ? '\x1a' : ' ')); |
74 |
|
display.Set(0, 1, '\x12'); |
75 |
|
display.Set(0, 2, '\x13'); |
76 |
< |
display.Set(0, 3, (state.top < list.size() ? '\x1b' : ' ')); |
76 |
> |
display.Set(0, 3, (state.bottom < size ? '\x1b' : ' ')); |
77 |
|
|
78 |
< |
_forall (size_t, index, state.bottom, state.top) |
79 |
< |
{ |
80 |
< |
MenuItem *item(list[index]); |
81 |
< |
std::string value(*item); |
82 |
< |
|
83 |
< |
value.resize(18, ' '); |
84 |
< |
|
85 |
< |
if (BoolItem *item_ = dynamic_cast<BoolItem *>(item)) |
86 |
< |
value += (*item_ ? '\x94' : '\xcf'); |
87 |
< |
else if (dynamic_cast<SubItem *>(item)) |
88 |
< |
value += '\x10'; |
89 |
< |
else |
90 |
< |
value += ' '; |
78 |
> |
_forall (size_t, index, state.top, state.bottom) |
79 |
> |
if (index < size) |
80 |
> |
{ |
81 |
> |
MenuItem *item(list[index]); |
82 |
> |
std::string value(*item); |
83 |
> |
|
84 |
> |
value.resize(18, ' '); |
85 |
> |
|
86 |
> |
if (BoolItem *item_ = dynamic_cast<BoolItem *>(item)) |
87 |
> |
value += (*item_ ? '\x94' : '\xcf'); |
88 |
> |
else if (dynamic_cast<SubItem *>(item)) |
89 |
> |
value += '\x10'; |
90 |
> |
else |
91 |
> |
value += ' '; |
92 |
|
|
93 |
< |
display.Set(1, _index, value); |
94 |
< |
} |
93 |
> |
display.Set(1, _index, value); |
94 |
> |
} |
95 |
> |
else |
96 |
> |
display.Set(1, _index, std::string(19, ' ')); |
97 |
|
} |
98 |
|
else |
99 |
< |
_forall (size_t, index, state.bottom, state.top) |
99 |
> |
_forall (size_t, index, state.top, size < state.bottom ? size : state.bottom) |
100 |
|
if (BoolItem *item = dynamic_cast<BoolItem *>(list[index])) |
101 |
|
display.Set(19, _index, (*item ? _B("\x94") : _B("\xcf"))); |
102 |
|
} |
146 |
|
|
147 |
|
TopList::AppendItem::operator std::string() const |
148 |
|
{ |
149 |
< |
return _B("Append"); |
149 |
> |
return _B("Playlist Append"); |
150 |
|
} |
151 |
|
|
152 |
|
TopList::AppendItem::operator bool() const |
176 |
|
return audacious.IsRunning() ? audacious.IsShuffle() : false; |
177 |
|
} |
178 |
|
|
179 |
< |
TopList::MusicItem::MusicItem(MenuList *list, Audacious::Audacious &audacious) : MenuItem(list), audacious(audacious) |
179 |
> |
TopList::MusicItem::MusicItem(MenuList *list, Audacious::Audacious &audacious, bool &append, MusicLibrary::Library &library) : MenuItem(list), audacious(audacious), append(append), library(library) |
180 |
|
{ |
181 |
|
} |
182 |
|
|
183 |
|
MenuList *TopList::MusicItem::Select() |
184 |
|
{ |
185 |
< |
delete this; |
165 |
< |
|
166 |
< |
return NULL; |
185 |
> |
return new ArtistList(list, audacious, append, library); |
186 |
|
} |
187 |
|
|
188 |
|
TopList::MusicItem::operator std::string() const |
190 |
|
return _B("Music"); |
191 |
|
} |
192 |
|
|
193 |
< |
TopList::TopList(Display &display, Audacious::Audacious &audacious, bool &append) : MenuList(this, display, 3) |
193 |
> |
TopList::TopList(Display &display, Audacious::Audacious &audacious, bool &append, MusicLibrary::Library &library) : MenuList(this, display, 3) |
194 |
|
{ |
195 |
|
previous = NULL; |
196 |
|
list[0] = new AppendItem(this, append); |
197 |
|
list[1] = new ShuffleItem(this, audacious); |
198 |
< |
list[2] = new MusicItem(this, audacious); |
198 |
> |
list[2] = new MusicItem(this, audacious, append, library); |
199 |
> |
} |
200 |
> |
|
201 |
> |
ArtistList::ArtistList(MenuList *parent, Audacious::Audacious &audacious, bool &append, MusicLibrary::Library &library) : MenuList(parent) |
202 |
> |
{ |
203 |
> |
list[0] = new AllItem(this, audacious, append, library); |
204 |
> |
} |
205 |
> |
|
206 |
> |
ArtistList::AllItem::AllItem(MenuList *list, Audacious::Audacious &audacious, bool &append, MusicLibrary::Library &library) : MenuItem(list), audacious(audacious), append(append), library(library) |
207 |
> |
{ |
208 |
> |
} |
209 |
> |
|
210 |
> |
MenuList *ArtistList::AllItem::Select() |
211 |
> |
{ |
212 |
> |
std::cerr << _B("All Artists!") << std::endl; |
213 |
> |
|
214 |
> |
return list; |
215 |
> |
} |
216 |
> |
|
217 |
> |
ArtistList::AllItem::operator std::string() const |
218 |
> |
{ |
219 |
> |
return _B("All Artists"); |
220 |
|
} |