summaryrefslogtreecommitdiffstats
path: root/noatun/modules/splitplaylist/view.h
blob: 9bff4335201a552adf80fd83122717ca48a23155 (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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#ifndef VIEW_H
#define VIEW_H

#include <tqevent.h>
#include <tqptrlist.h>
#include <klistview.h>
#include <kmainwindow.h>
#include <tqrect.h>
#include <tqdict.h>
#include <tdeio/global.h>
#include <noatun/downloader.h>

class Finder;
class View;
namespace TDEIO { class ListJob; }


class SafeListViewItem
	: public TQCheckListItem
	, public PlaylistItemData
	, public DownloadItem
{
public:
	SafeListViewItem(TQListView *parent, TQListViewItem *after, const KURL &text);
	SafeListViewItem(TQListView *parent, TQListViewItem *after, const TQMap<TQString,TQString> &properties);
	virtual ~SafeListViewItem();

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

	virtual TQString file() const;

	int compare(TQListViewItem * i, int col, bool ascending) const;
	virtual void remove();

protected:
	virtual void downloaded(int percent);
	virtual void downloadTimeout();
	virtual void downloadFinished();
	virtual void modified();
	virtual void stateChange(bool s);

	void paintCell(TQPainter *p, const TQColorGroup &cg, int column, int width, int align);

private:
	struct Property
	{
		TQString key;
		TQString value;
	};
	TQValueList<Property> mProperties;
	bool removed;
};

class List : public TDEListView
{
Q_OBJECT
  
friend class View;
public:
	List(View *parent);
	virtual ~List();
	TQListViewItem *openGlobal(const KURL&, TQListViewItem * =0);
	TQListViewItem *importGlobal(const KURL&, TQListViewItem * =0);
	TQListViewItem *addFile(const KURL&, bool play=false, TQListViewItem * =0);
	void addDirectoryRecursive(const KURL &dir, TQListViewItem *after= 0);

public slots:
	virtual void clear();

signals:
	void modified(void);
	void deleteCurrentItem();

protected:
	virtual bool acceptDrag(TQDropEvent *event) const;
	virtual void keyPressEvent(TQKeyEvent *e);

protected slots:
	virtual void dropEvent(TQDropEvent *event, TQListViewItem *after);
	void move();

protected:
	TQListViewItem *recursiveAddAfter;

protected slots:
	// used when adding directories via TDEIO::listRecursive
	void slotResult(TDEIO::Job *job);
	void slotEntries(TDEIO::Job *job, const TDEIO::UDSEntryList &entries);
	void slotRedirection(TDEIO::Job *, const KURL & url);

protected:
	void addNextPendingDirectory();
	KURL::List pendingAddDirectories;
	TDEIO::ListJob *listJob;
	KURL currentJobURL;
};

class KFileDialog;
class TDEToggleAction;
class TDEToolBar;

class View : public TDEMainWindow
{
Q_OBJECT
  
public:
	View(SplitPlaylist *mother);
	// load the SM playlist
	void init();
	virtual ~View();
	List *listView() const { return list; }
	TQListViewItem *addFile(const KURL &u, bool play=false)
		{ return list->addFile(u, play, list->lastItem()); }


public slots:
	void deleteSelected();
	void addFiles();
	void addDirectory();
	void save();
	void saveAs();
	void open();
	void openNew();
	void setSorting(bool on, int column = 0);
	void setNoSorting() { setSorting(false); }
	void headerClicked(int column);void find();
	void findIt(Finder *);


private slots:
	void setModified();
	void saveState();

	void configureToolBars();
	void newToolBarConfig();

protected:
	void setupActions();

	bool saveToURL(const KURL &);
	void exportTo(const KURL &);

	void setModified(bool);
	virtual void closeEvent(TQCloseEvent*e);
	virtual void showEvent(TQShowEvent *);
	virtual void hideEvent(TQHideEvent *);

signals:
	void hidden();
	void shown();

private:
	List *list;
	TDEAction *mOpen, *mDelete, *mSave, *mSaveAs, *mOpenpl, *mOpenNew;
	TDEAction *mClose;
	TDEAction *mFind;
	Finder *mFinder;

	KURL mPlaylistFile;
	bool modified;
};

#endif