summaryrefslogtreecommitdiffstats
path: root/noatun-plugins/dub/dub/dubplaylist.cpp
blob: f1fd2562d93abf55622a6dfb2592c381a8b366f2 (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
//
//
// C++ Implementation: dubplaylist.cpp
//
// Description:
//
//
// Author: Eray Ozkural (exa) <erayo@cs.bilkent.edu.tr>, (C) 2001
//
// Copyright: See COPYING file that comes with this distribution
//
//

//#include dubplaylist.cpp

#include <tdemessagebox.h>
#include <kdebug.h>
#include <noatun/playlist.h>
#include <tdelocale.h>

#include "dub.h"
#include "dubconfigmodule.h"

#include "dubplaylist.h"

// plugin interface
extern "C"
{
	TDE_EXPORT Plugin* create_plugin()
	{
		TDEGlobal::locale()->insertCatalogue("dub");
		DubPlaylist* dub = new DubPlaylist;
		return dub;
	}
}

/** Construct playlist object */
DubPlaylist::DubPlaylist()
 : Playlist(0, "Dub Playlist")
 , dub(0)
 , visible(false)
{
  kdDebug(90010) << "dub: cons playlist" << endl;
}

DubPlaylist::~DubPlaylist(){
  kdDebug(90010) << "dub: destruct playlist " << endl;
  // destroy app
  delete dub;
}

void DubPlaylist::reset() {
  kdDebug(90010) << "dub: reset" << endl;
}

void DubPlaylist::clear() {
  kdDebug(90010) << "dub: clear" << endl;
}

void DubPlaylist::addFile(const KURL&, bool play) {
  KMessageBox::information(0, i18n("Adding files not supported yet, see configuration"));
}

PlaylistItem DubPlaylist::next() {
  kdDebug(90010) << "dub: next" << endl;
  dub->selectNextFile();
  updateCurrent();
  return currentItem;
}

PlaylistItem DubPlaylist::current() {
  if (!currentItem.isNull())
    kdDebug(90010) << "dub: current item:" << currentItem.data()->url().prettyURL() << endl;
  return currentItem;
}

PlaylistItem DubPlaylist::previous() {
  kdDebug(90010) << "dub: previous" << endl;
  dub->selectPreviousFile();
  updateCurrent();
  return currentItem;
}

PlaylistItem DubPlaylist::getFirst() const {
  kdDebug(90010) << "dub: getFirst" << endl;
  const KFileItem* first = dub->queryFirstFile();
  if (first) {
    kdDebug(90010) << "dub: first " << first->url() << endl;
    DubPlaylistItem* firstData = new DubPlaylistItem(*first);
    return PlaylistItem(firstData);
  }
  else
    return 0;
}

PlaylistItem DubPlaylist::getAfter(const PlaylistItem &item) const {
  kdDebug(90010) << "dub: getAfter" << endl;
  return 0;
}

bool DubPlaylist::listVisible() const {
  kdDebug(90010) << "dub: listVisible" << endl;
  return visible;
}

void DubPlaylist::init() {
  kdDebug(90010) << "dub: init" << endl;
  dubconfig = new DubConfigModule(this); // we pass this around to dub app
  dub = new Dub(this);
  kdDebug(90010) << "dub: init: test playlist() " << endl;
  playlist();
}

void DubPlaylist::showList() {
  kdDebug(90010) << "dub: showList" << endl;
  visible = true;
  Q_ASSERT(dub);
  dub->show();
}

void DubPlaylist::hideList() {
  kdDebug(90010) << "dub: hideList" << endl;
  visible = false;
  Q_ASSERT(dub);
  dub->hide();
}

//void DubPlaylist::remove(const PlaylistItem&) {
//  KMessageBox::information(0, "Removing files not supported yet, see configuration");
//}

//void DubPlaylist::sort() {
//  kdDebug(90010) << "sort" << endl;
//}

Playlist* DubPlaylist::playlist() {
  kdDebug(90010) << "dub: playlist pointer " << this << endl;
  return static_cast<Playlist*>(this);
}

void DubPlaylist::setCurrent(const KFileItem* file, bool play) {
  Q_ASSERT(file);
  currentItem = new DubPlaylistItem(*file);
  if (play)
    emit playCurrent();
}

void DubPlaylist::setCurrent(const PlaylistItem &play)
{
  currentItem=play;
  emit playCurrent();
}

/** No descriptions */
void DubPlaylist::updateCurrent() {
  KFileItem* active = dub->getActiveFile();
  if ( active ) {
    currentItem = new DubPlaylistItem(*active);
    emit playCurrent();
  }
}