~ubuntu-branches/ubuntu/hoary/kdemultimedia/hoary

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/liszt/Liszt.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Martin Schulze
  • Date: 2003-01-22 15:00:51 UTC
  • Revision ID: james.westby@ubuntu.com-20030122150051-uihwkdoxf15mi1tn
Tags: upstream-2.2.2
ImportĀ upstreamĀ versionĀ 2.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <kcmodule.h>
 
2
 
 
3
#include "Liszt.h"
 
4
#include "PlayLiszt.h"
 
5
#include "EditWidget.h"
 
6
 
 
7
extern "C"
 
8
{
 
9
        Plugin * create_plugin()
 
10
        {
 
11
                return new Liszt;
 
12
        }
 
13
}
 
14
 
 
15
Liszt::Liszt()
 
16
  : Playlist(0, "Liszt"),
 
17
    Plugin()
 
18
{
 
19
}
 
20
 
 
21
  void
 
22
Liszt::init()
 
23
{
 
24
  editWidget_ = new EditWidget;
 
25
 
 
26
  connect(
 
27
      editWidget_,  SIGNAL(skipToTrack(long)),
 
28
      this,         SLOT(slotSkipToTrack(long)));
 
29
 
 
30
  connect(
 
31
      editWidget_,  SIGNAL(closed()),
 
32
      this,         SIGNAL(listHidden()));
 
33
 
 
34
  editWidget_->show();
 
35
 
 
36
  PlayLiszt::instance()->load();
 
37
}
 
38
 
 
39
Liszt::~Liszt()
 
40
{
 
41
  delete editWidget_;
 
42
}
 
43
 
 
44
  void
 
45
Liszt::reset()
 
46
{
 
47
  PlayLiszt::instance()->setCurrentTrack(0);
 
48
  editWidget_->reset();
 
49
}
 
50
 
 
51
  void
 
52
Liszt::clear()
 
53
{
 
54
  PlayLiszt::instance()->clear();
 
55
}
 
56
 
 
57
  void
 
58
Liszt::addFile(const KURL & url, bool)
 
59
{
 
60
  if (url.isLocalFile())
 
61
    PlayLiszt::instance()->addFile(url.path());
 
62
}
 
63
 
 
64
  PlaylistItem *
 
65
Liszt::next()
 
66
{
 
67
  long currentTrack = PlayLiszt::instance()->currentTrack();
 
68
 
 
69
  if (
 
70
      (currentTrack < 0) ||
 
71
      (currentTrack == PlayLiszt::instance()->lastTrack())
 
72
  )
 
73
    currentTrack = 0;
 
74
  else
 
75
    ++currentTrack;
 
76
 
 
77
  Track * t = PlayLiszt::instance()->track(currentTrack);
 
78
 
 
79
  if (0 == t)
 
80
    return 0;
 
81
 
 
82
  PlayLiszt::instance()->setCurrentTrack(currentTrack);
 
83
 
 
84
  return t->lisztItem();
 
85
 
 
86
}
 
87
 
 
88
  PlaylistItem *
 
89
Liszt::current()
 
90
{
 
91
  long currentTrack = PlayLiszt::instance()->currentTrack();
 
92
 
 
93
  if (
 
94
      (currentTrack < 0) ||
 
95
      (currentTrack > PlayLiszt::instance()->lastTrack())
 
96
  )
 
97
    currentTrack = 0;
 
98
 
 
99
  Track * t = PlayLiszt::instance()->track(currentTrack);
 
100
 
 
101
  if (0 == t)
 
102
    return 0;
 
103
 
 
104
  PlayLiszt::instance()->setCurrentTrack(currentTrack);
 
105
 
 
106
  return t->lisztItem();
 
107
}
 
108
 
 
109
  PlaylistItem *
 
110
Liszt::previous()
 
111
{
 
112
  long currentTrack = PlayLiszt::instance()->currentTrack();
 
113
 
 
114
  if (currentTrack <= 0)
 
115
    currentTrack = PlayLiszt::instance()->lastTrack();
 
116
  else
 
117
    --currentTrack;
 
118
 
 
119
  Track * t = PlayLiszt::instance()->track(currentTrack);
 
120
 
 
121
  if (0 == t)
 
122
    return 0;
 
123
 
 
124
  PlayLiszt::instance()->setCurrentTrack(currentTrack);
 
125
 
 
126
  return t->lisztItem();
 
127
}
 
128
 
 
129
  PlaylistItem *
 
130
Liszt::getFirst() const
 
131
{
 
132
  Track * track = PlayLiszt::instance()->all().getFirst();
 
133
  return track ? track->lisztItem() : 0;
 
134
}
 
135
 
 
136
  PlaylistItem *
 
137
Liszt::getAfter(const PlaylistItem * item) const
 
138
{
 
139
  for (TrackListIterator it(PlayLiszt::instance()->all()); it.current(); ++it)
 
140
  {
 
141
    if (it.current()->lisztItem() == item)
 
142
    {
 
143
      ++it;
 
144
      return (it.current() ? it.current()->lisztItem() : 0);
 
145
    }
 
146
  }
 
147
  return 0;
 
148
}
 
149
 
 
150
  bool
 
151
Liszt::listVisible() const
 
152
{
 
153
  return editWidget_->isVisible();
 
154
}
 
155
 
 
156
  void
 
157
Liszt::showList()
 
158
{
 
159
  editWidget_->show();
 
160
}
 
161
 
 
162
  void
 
163
Liszt::hideList()
 
164
{
 
165
  editWidget_->hide();
 
166
}
 
167
 
 
168
  void
 
169
Liszt::toggleList()
 
170
{
 
171
  if (editWidget_->isVisible())
 
172
    editWidget_->hide();
 
173
  else
 
174
    editWidget_->show();
 
175
}
 
176
 
 
177
  void
 
178
Liszt::remove(PlaylistItem *)
 
179
{
 
180
  qDebug("Liszt::remove() - STUB");
 
181
}
 
182
 
 
183
  void
 
184
Liszt::slotSkipToTrack(long l)
 
185
{
 
186
  PlayLiszt::instance()->setCurrentTrack(l);
 
187
  emit(newCurrent());
 
188
  emit(playCurrent());
 
189
}
 
190
 
 
191
#include "Liszt.moc"