summaryrefslogtreecommitdiffstats
path: root/noatun-plugins/oblique/selector.h
blob: 6ce57dddbd93c96f4df5d925fd6e620b24c213d1 (plain)
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
// Copyright (c) 2003 Charles Samuels <[email protected]>
// See the file COPYING for redistribution terms.

#ifndef SELECTOR_H
#define SELECTOR_H

#include <noatun/playlist.h>
#include "file.h"

class Item : public PlaylistItemData
{
	File mFile;

public:
	Item(const File &file);

	File itemFile() const { return mFile; }

	virtual TQString property(const TQString &key, const TQString &def=0) const;
	virtual void setProperty(const TQString &key, const TQString &property);
	virtual void clearProperty (const TQString &key);
	virtual TQStringList properties() const;

	virtual bool isProperty(const TQString &key) const;

	virtual bool operator==(const PlaylistItemData &d) const;
	virtual void remove();
};

/**
 * a selector is an object that can get items from the
 * playlist in a certain order
 **/
class Selector
{
public:
	Selector();
	virtual ~Selector();
	virtual Item *next()=0;
	virtual Item *previous()=0;
	virtual Item *current()=0;
	virtual void setCurrent(const Item &item)=0;
};

class Tree;
class TreeItem;

class SequentialSelector : public Selector
{
	Tree *mTree;

public:
	SequentialSelector(Tree *tree);
	virtual ~SequentialSelector();
	virtual Item *next();
	virtual Item *previous();
	virtual Item *current();
	virtual void setCurrent(const Item &item);
	virtual void setCurrent(TreeItem *current);
};

class RandomSelector : public Selector
{
	Tree *mTree;
	TreeItem *mPrevious;
public:
	RandomSelector(Tree *tree);

	virtual Item *next();
	virtual Item *previous();
	virtual Item *current();
	virtual void setCurrent(const Item &item);
	virtual void setCurrent(TreeItem *item, TreeItem *previous);
};

#endif