OTHER: get rid of XMMSHandler and update classes using it

This commit is contained in:
Thomas Frauendorfer 2008-11-04 19:50:28 +01:00
parent 786b745d55
commit 982660510a
33 changed files with 145 additions and 266 deletions

View file

@ -13,14 +13,14 @@
* GNU General Public License for more details.
*/
#include "XMMSHandler.h"
#include <xmmsclient/xmmsclient++.h>
#include "xclient.h"
#include "xclientcache.h"
#include "application.h"
#include "playlistshade.h"
#include "playlistwindow.h"
#include "pixmapbutton.h"
#include "Skin.h"
#include <QSettings>
#include <QPainter>
@ -29,7 +29,7 @@
PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
{
QSettings s;
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
const XClient *client = App->client ();
if (!s.contains ("playlist/shadedsize"))
s.setValue ("playlist/shadedsize", 8);
@ -47,7 +47,7 @@ PlaylistShade::PlaylistShade (PlaylistWindow *parent) : QWidget (parent)
connect (m_unshadebtn, SIGNAL (clicked ()),
parent, SLOT (switchDisplay ()));
connect (xmmsh.cache (), SIGNAL (activeEntryChanged (QVariantHash)),
connect (client->cache (), SIGNAL (activeEntryChanged (QVariantHash)),
this, SLOT (setMediainfo (QVariantHash)));
connect (App, SIGNAL(settingsChanged ()),

View file

@ -16,15 +16,14 @@
#ifndef __PLAYLISTSHADE_H__
#define __PLAYLISTSHADE_H__
#include <xmmsclient/xmmsclient++.h>
#include "Skin.h"
#include <QWidget>
#include <QHash>
#include <QVariant>
typedef QHash<QString, QVariant> QVariantHash;
class Skin;
class QResizeEvent;
class PixmapButton;
class PlaylistWindow;

View file

@ -13,9 +13,7 @@
* GNU General Public License for more details.
*/
// FIXME should not need those two
#include <xmmsclient/xmmsclient++.h>
#include "XMMSHandler.h"
#include "xclient.h"
#include "xplayback.h"
#include "application.h"
@ -136,12 +134,12 @@ PlaylistView::PlaylistView (QWidget *parent) : QListView (parent)
m_font = NULL;
m_fontmetrics = NULL;
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
const XClient *client = App->client ();
connect (App, SIGNAL (settingsChanged ()),
this, SLOT (settingsChanged ()));
connect (xmmsh.xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
connect (client->xplayback (), SIGNAL(playbackStatusChanged(Xmms::Playback::Status)),
this, SLOT(handleStatus(Xmms::Playback::Status)));
}
@ -278,18 +276,18 @@ PlaylistView::mouseDoubleClickEvent (QMouseEvent *event)
return;
}
XMMSHandler &xmmsh = XMMSHandler::getInstance ();
xmmsh.xplayback ()->setPos (index.row());
const XClient *client = App->client ();
client->xplayback ()->setPos (index.row());
if (m_status == XMMS_PLAYBACK_STATUS_STOP ||
m_status == XMMS_PLAYBACK_STATUS_PAUSE) {
xmmsh.xplayback ()->play ();
client->xplayback ()->play ();
}
}
void
PlaylistView::showEntryInfo (void)
{
XMMSHandler &client = XMMSHandler::getInstance ();
const XClient *client = App->client ();
QModelIndex current = selectionModel ()->currentIndex ();
if (current.isValid ()) {
uint32_t id = model ()->data (current, PlaylistModel::MedialibIdRole)
@ -297,7 +295,7 @@ PlaylistView::showEntryInfo (void)
// If no infodialog exists, create one, else set the selected Item as
// displayed item
if (!m_entry_info) {
m_entry_info = new EntryInfo (this, client.cache (), id);
m_entry_info = new EntryInfo (this, client->cache (), id);
} else {
m_entry_info->raise ();
m_entry_info->setId (id);

View file

@ -13,7 +13,10 @@
* GNU General Public License for more details.
*/
#include "XMMSHandler.h"
#include "xclient.h"
#include "playlistmodel.h"
#include "xcollection.h"
#include "xplayback.h"
#include "application.h"
#include "mainwindow.h"
@ -23,10 +26,6 @@
#include "playlistview.h"
#include "playlistcontrols.h"
#include "playlistmodel.h"
#include "xcollection.h"
#include "xplayback.h"
#include "pixmapbutton.h"
#include "playlistshade.h"
#include "playlistmenu.h"
@ -196,7 +195,7 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
m_view->move (10, 20);
// m_view->resize (size().width()-30, size().height()-20-38);
// TODO: creation of Playlistmodel should be done elsewhere
m_view->setModel (XMMSHandler::getInstance().getPlaylistModel());
m_view->setModel (App->client ()->active_playlist ());
/*
* This is a hack to make PlaylistScrollBar work with PlaylistView.
@ -219,20 +218,20 @@ PlaylistWidget::PlaylistWidget (PlaylistWindow *parent) : QWidget (parent)
addButtons ();
XMMSHandler &client = XMMSHandler::getInstance ();
const XClient *client = App->client ();
m_controls = new PlaylistControls (this);
// connect buttons
connect (m_controls, SIGNAL (prev ()),
client.xplayback (), SLOT (prev ()));
client->xplayback (), SLOT (prev ()));
connect (m_controls, SIGNAL (play ()),
client.xplayback (), SLOT (play ()));
client->xplayback (), SLOT (play ()));
connect (m_controls, SIGNAL (pause ()),
client.xplayback (), SLOT (pause ()));
client->xplayback (), SLOT (pause ()));
connect (m_controls, SIGNAL (stop ()),
client.xplayback (), SLOT (stop ()));
client->xplayback (), SLOT (stop ()));
connect (m_controls, SIGNAL (next ()),
client.xplayback (), SLOT (next ()));
client->xplayback (), SLOT (next ()));
// TODO: eject
connect (m_controls, SIGNAL (toggleTime ()),
App, SLOT (toggleTime()));
@ -269,7 +268,7 @@ PlaylistWidget::addButtons ()
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_ALL_0,
Skin::PLS_DEL_ALL_1);
connect (b, SIGNAL (activated ()),
XMMSHandler::getInstance().xcollection (),
App->client ()->xcollection (),
SLOT (playlistClear ()));
b = new PlaylistMenuButton (m_del, Skin::PLS_DEL_CRP_0,
Skin::PLS_DEL_CRP_1);
@ -324,8 +323,8 @@ PlaylistWidget::addButtons ()
void
PlaylistWidget::menuAddUrl ()
{
XMMSHandler &client = XMMSHandler::getInstance ();
UrlOpen *tmp = new UrlOpen (this, client.xcollection ());
const XClient *client = App->client ();
UrlOpen *tmp = new UrlOpen (this, client->xcollection ());
tmp->show ();
}
@ -343,7 +342,7 @@ PlaylistWidget::diveDir (const QString &dir)
diveDir (fileInfo.filePath ());
} else {
QString fname = fileInfo.filePath();
XMMSHandler::getInstance ().playlistAddURL ("file://" + fname);
App->client ()->xcollection ()->playlistAddUrl ("file://" + fname);
}
}
}
@ -374,7 +373,7 @@ PlaylistWidget::menuAddFile ()
BrowseDialog bd (window ());
files = bd.getFiles ();
for (int i = 0; i < files.count(); i++) {
XMMSHandler::getInstance ().playlistAddURL (files.value (i));
App->client ()->xcollection ()->playlistAddUrl (files.value (i));
}
} else {
FileDialog fd (this, "playlist_add_files");
@ -382,7 +381,7 @@ PlaylistWidget::menuAddFile ()
files = fd.getFiles ();
for (int i = 0; i < files.count(); i++) {
XMMSHandler::getInstance ().playlistAddURL ("file://" + files.value(i));
App->client ()->xcollection ()->playlistAddUrl ("file://" + files.value(i));
}
}
@ -397,9 +396,9 @@ PlaylistWidget::menuAddPls ()
files = fd.getFiles ();
if (files.count () > 0) {
XMMSHandler::getInstance ().xcollection ()->playlistClear ();
App->client ()->xcollection ()->playlistClear ();
QString file = files[0];
XMMSHandler::getInstance ().xcollection ()->addPlsFile (QUrl (file));
App->client ()->xcollection ()->addPlsFile (QUrl (file));
}
}
@ -590,8 +589,8 @@ PlaylistWidget::paintEvent (QPaintEvent *event)
void
PlaylistWidget::openPlaylistChooser ()
{
XMMSHandler &client = XMMSHandler::getInstance ();
PlaylistChooser *tmp = new PlaylistChooser (this, client.xcollection ());
const XClient *client = App->client ();
PlaylistChooser *tmp = new PlaylistChooser (this, client->xcollection ());
tmp->show ();
}

View file

@ -16,8 +16,6 @@
#ifndef __PLAYLISTWIDGET_H__
#define __PLAYLISTWIDGET_H__
#include "XMMSHandler.h"
#include <QScrollBar>
#include <QSizeGrip>
#include <QWidget>
@ -35,7 +33,7 @@ class PixmapButton;
class PlaylistSizeGrip : public QSizeGrip {
Q_OBJECT
public:
PlaylistSizeGrip (QWidget *parent) : QSizeGrip (parent) {}
~PlaylistSizeGrip () {}

View file

@ -13,13 +13,12 @@
* GNU General Public License for more details.
*/
#include "XMMSHandler.h"
#include "playlistwindow.h"
#include <QMoveEvent>
#include <QResizeEvent>
#include <QPoint>
#include <QIcon>
#include "playlistwidget.h"
#include "playlistshade.h"