summaryrefslogtreecommitdiffstats
path: root/noatun/modules/splitplaylist/view.h
blob: 293276caca06eeda5d2ce3b98ea109e01d05618e (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 <kio/global.h>
#include <noatun/downloader.h>

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


class SafeListViewItem
	: public TQCheckListItem
	, public PlaylistItemData
	, public DownloadItem
{
public:
	SafeListViewItem(TQListView *tqparent, TQListViewItem *after, const KURL &text);
	SafeListViewItem(TQListView *tqparent, 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 KListView
{
Q_OBJECT
  TQ_OBJECT
friend class View;
public:
	List(View *tqparent);
	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 KIO::listRecursive
	void slotResult(KIO::Job *job);
	void slotEntries(KIO::Job *job, const KIO::UDSEntryList &entries);
	void slotRedirection(KIO::Job *, const KURL & url);

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

class KFileDialog;
class KToggleAction;
class KToolBar;

class View : public KMainWindow
{
Q_OBJECT
  TQ_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 tqfind();
	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;
	KAction *mOpen, *mDelete, *mSave, *mSaveAs, *mOpenpl, *mOpenNew;
	KAction *mClose;
	KAction *mFind;
	Finder *mFinder;

	KURL mPlaylistFile;
	bool modified;
};

#endif