add more spacing
[personal-kdebase.git] / workspace / plasma / dataengines / nowplaying / playercontainer.cpp
blob5ab8d536d29c5e3768d1fd83d972c3d6358a988c
1 /*
2 * Copyright 2008 Alex Merry <alex.merry@kdemail.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #include "playercontainer.h"
22 #include "playercontrol.h"
24 PlayerContainer::PlayerContainer(Player::Ptr m_player, QObject* parent)
25 : DataContainer(parent)
26 , m_player(m_player)
27 , m_controller(0)
29 Q_ASSERT(m_player);
31 setObjectName(m_player->name());
33 connect(this, SIGNAL(updateRequested(DataContainer*)),
34 this, SLOT(updateInfo()));
37 Plasma::Service* PlayerContainer::service(QObject* parent)
39 if (!m_controller) {
40 kDebug() << "Creating controller";
41 m_controller = new PlayerControl(parent, m_player);
42 connect(this, SIGNAL(updateRequested(DataContainer*)),
43 m_controller, SLOT(updateEnabledOperations()));
45 return m_controller;
48 void PlayerContainer::updateInfo()
50 if (!m_player->isRunning()) {
51 kDebug() << objectName() << "isn't running";
52 return;
55 switch(m_player->state()) {
56 case Player::Playing:
57 setData("State", "playing");
58 break;
59 case Player::Paused:
60 setData("State", "paused");
61 break;
62 case Player::Stopped:
63 setData("State", "stopped");
64 break;
67 setData("Artist", m_player->artist());
68 setData("Album", m_player->album());
69 setData("Title", m_player->title());
70 setData("Track number", m_player->trackNumber());
71 setData("Comment", m_player->comment());
72 setData("Genre", m_player->genre());
73 setData("Length", m_player->length());
74 setData("Position", m_player->position());
75 setData("Volume", m_player->volume());
76 setData("Artwork", m_player->artwork());
78 // propagate changes
79 checkForUpdate();
82 #include "playercontainer.moc"