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

« back to all changes in this revision

Viewing changes to noatun/noatun/modules/liszt/AlbumItem.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
/*
 
2
 * Copyright (C) 2000 Rik Hemsley (rikkus) <rik@kde.org>. All rights reserved.
 
3
 *
 
4
LICENSE
 
5
 */
 
6
 
 
7
#include <qpixmap.h>
 
8
#include <qpainter.h>
 
9
 
 
10
#include "Static.h"
 
11
#include "AlbumItem.h"
 
12
#include "ArtistItem.h"
 
13
#include "TrackItem.h"
 
14
#include "Track.h"
 
15
 
 
16
AlbumItem::AlbumItem(
 
17
    ArtistItem * parent,
 
18
    QString artist,
 
19
    QString album
 
20
                                      )
 
21
  : CharlatanItem(parent, album),
 
22
    artist_(artist),
 
23
    album_(album)
 
24
{
 
25
  setExpandable(true);
 
26
  setPixmap(0, Static::instance()->pixmap("album"));
 
27
 
 
28
#if 0
 
29
  KConfig * c(KGlobal::config());
 
30
 
 
31
  c->setGroup("General");
 
32
 
 
33
  QStringList l(c->readListEntry("OpenAlbums - " + artist_));
 
34
 
 
35
  if (0 != l.contains(album_))
 
36
    setOpen(true);
 
37
#endif
 
38
}
 
39
 
 
40
AlbumItem::~AlbumItem()
 
41
{
 
42
}
 
43
 
 
44
  void
 
45
AlbumItem::setOpen(bool b)
 
46
{
 
47
  CharlatanItem::setOpen(b);
 
48
#if 0
 
49
 
 
50
  KConfig * c(KGlobal::config());
 
51
 
 
52
  c->setGroup("General");
 
53
 
 
54
  QString key("OpenAlbums - " + artist_);
 
55
 
 
56
  QStringList l(c->readListEntry(key));
 
57
 
 
58
  if (b) {
 
59
    if (0 == l.contains(album_)) {
 
60
      l.append(album_);
 
61
      c->writeEntry(key, l);
 
62
    }
 
63
  } else {
 
64
    QStringList::Iterator it = l.find(album_);
 
65
    if (it != l.end()) {
 
66
      l.remove(it);
 
67
      c->writeEntry(key, l);
 
68
    }
 
69
  }
 
70
#endif
 
71
}
 
72
 
 
73
  void
 
74
AlbumItem::increaseScore()
 
75
{
 
76
  TrackItem * i = static_cast<TrackItem *>(firstChild());
 
77
 
 
78
  while (0 != i) {
 
79
    i->increaseScore();
 
80
    i = static_cast<TrackItem *>(i->nextSibling());
 
81
  }
 
82
}
 
83
 
 
84
  void
 
85
AlbumItem::decreaseScore()
 
86
{
 
87
  TrackItem * i = static_cast<TrackItem *>(firstChild());
 
88
 
 
89
  while (0 != i) {
 
90
    i->decreaseScore();
 
91
    i = static_cast<TrackItem *>(i->nextSibling());
 
92
  }
 
93
}
 
94
 
 
95
  TrackItem *
 
96
AlbumItem::trackItem(QString name)
 
97
{
 
98
  TrackItem * i = static_cast<TrackItem *>(firstChild());
 
99
 
 
100
  while (i) {
 
101
 
 
102
    if (i->track()->name() == name)
 
103
      return i;
 
104
 
 
105
    i = static_cast<TrackItem *>(i->nextSibling());
 
106
  }
 
107
 
 
108
  return 0;
 
109
}
 
110
 
 
111
  TrackItem *
 
112
AlbumItem::trackItem(Track * t)
 
113
{
 
114
  TrackItem * i = static_cast<TrackItem *>(firstChild());
 
115
 
 
116
  while (i) {
 
117
 
 
118
    if (i->track()->name() == t->name())
 
119
      return i;
 
120
 
 
121
    i = static_cast<TrackItem *>(i->nextSibling());
 
122
  }
 
123
 
 
124
  return (new TrackItem(this, t));
 
125
}
 
126