Added start of new Medialib view
This commit is contained in:
parent
219327ca20
commit
d114edf75f
12 changed files with 194 additions and 27 deletions
42
MedialibTreeModel.cpp
Normal file
42
MedialibTreeModel.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
#include "XMMSSocket.h"
|
||||
#include "MedialibTreeModel.h"
|
||||
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
MedialibTreeModel::MedialibTreeModel (QObject *parent) : QAbstractTableModel (parent), m_socket ("PromoeMedialibTree")
|
||||
{
|
||||
m_socket.connect (getenv ("XMMS_PATH"));
|
||||
}
|
||||
|
||||
/* QModel overrides */
|
||||
int
|
||||
MedialibTreeModel::rowCount (const QModelIndex &parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
int
|
||||
MedialibTreeModel::columnCount (const QModelIndex &parent) const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant
|
||||
MedialibTreeModel::data (const QModelIndex &parent,
|
||||
int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
return QVariant("hej");
|
||||
return QVariant ();
|
||||
}
|
||||
|
||||
QVariant
|
||||
MedialibTreeModel::headerData (int section,
|
||||
Qt::Orientation orientation,
|
||||
int role) const
|
||||
{
|
||||
if (role == Qt::DisplayRole)
|
||||
return QVariant("header");
|
||||
return QVariant ();
|
||||
}
|
||||
|
24
MedialibTreeModel.h
Normal file
24
MedialibTreeModel.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#ifndef __MEDIALIBTREEMODEL_H__
|
||||
#define __MEDIALIBTREEMODEL_H__
|
||||
|
||||
#include "XMMSSocket.h"
|
||||
#include <QAbstractTableModel>
|
||||
|
||||
class MedialibTreeModel : public QAbstractTableModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MedialibTreeModel (QObject *parent);
|
||||
MedialibTreeModel::~MedialibTreeModel () {};
|
||||
|
||||
/* QModel overrides */
|
||||
int rowCount (const QModelIndex &parent) const;
|
||||
int columnCount (const QModelIndex &parent) const;
|
||||
QVariant data (const QModelIndex &parent, int role = Qt::DisplayRole) const;
|
||||
QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
|
||||
private:
|
||||
XMMSSocket m_socket;
|
||||
};
|
||||
|
||||
#endif
|
8
MedialibView.cpp
Normal file
8
MedialibView.cpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include "MedialibView.h"
|
||||
|
||||
#include <QTreeView>
|
||||
|
||||
|
||||
MedialibView::MedialibView (QWidget *parent) : QTreeView (parent)
|
||||
{
|
||||
}
|
16
MedialibView.h
Normal file
16
MedialibView.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#ifndef __MEDIALIBVIEW_H__
|
||||
#define __MEDIALIBVIEW_H__
|
||||
|
||||
#include "XMMSSocket.h"
|
||||
#include <QTreeView>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class MedialibView : public QTreeView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MedialibView (QWidget *parent);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
21
MedialibWindow.cpp
Normal file
21
MedialibWindow.cpp
Normal file
|
@ -0,0 +1,21 @@
|
|||
#include "XMMSSocket.h"
|
||||
#include "MedialibWindow.h"
|
||||
#include "MedialibView.h"
|
||||
#include "MedialibTreeModel.h"
|
||||
|
||||
#include <QMainWindow>
|
||||
|
||||
MedialibWindow::MedialibWindow (QWidget *parent) : QMainWindow (parent)
|
||||
{
|
||||
#ifndef _WIN32
|
||||
setWindowIcon (QIcon (":icon.png"));
|
||||
#endif
|
||||
|
||||
setWindowFlags (Qt::Dialog);
|
||||
setAttribute (Qt::WA_DeleteOnClose);
|
||||
|
||||
m_view = new MedialibView (this);
|
||||
m_view->setModel (new MedialibTreeModel (this));
|
||||
|
||||
setCentralWidget (m_view);
|
||||
}
|
17
MedialibWindow.h
Normal file
17
MedialibWindow.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#ifndef __MEDIALIBWINDOW_H__
|
||||
#define __MEDIALIBWINDOW_H__
|
||||
|
||||
#include "MedialibView.h"
|
||||
#include <QMainWindow>
|
||||
|
||||
class MedialibWindow : public QMainWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MedialibWindow (QWidget *parent);
|
||||
|
||||
private:
|
||||
QTreeView *m_view;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -2,9 +2,7 @@
|
|||
#include "TitleBar.h"
|
||||
#include "Display.h"
|
||||
#include "SkinChooser.h"
|
||||
/*
|
||||
#include "Medialib.h"
|
||||
*/
|
||||
#include "MedialibWindow.h"
|
||||
#include "SettingsWindow.h"
|
||||
#include "Button.h"
|
||||
|
||||
|
@ -45,9 +43,7 @@ TitleBar::showMenu (void)
|
|||
|
||||
a = new QAction (tr ("Medialib browser"), this);
|
||||
a->setShortcut (tr ("Alt+M"));
|
||||
/*
|
||||
connect (a, SIGNAL (triggered ()), this, SLOT (showMlib ()));
|
||||
*/
|
||||
qm.addAction (a);
|
||||
qm.addSeparator ();
|
||||
a = new QAction (tr ("Theme settings"), this);
|
||||
|
@ -74,10 +70,8 @@ TitleBar::showMenu (void)
|
|||
void
|
||||
TitleBar::showMlib ()
|
||||
{
|
||||
/*
|
||||
MedialibWindow *mw = new MedialibWindow (window ());
|
||||
mw->show ();
|
||||
*/
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
#include "XmmsQT4.h"
|
||||
#include "XMMSSocket.h"
|
||||
#include "XMMSHandler.h"
|
||||
|
||||
#include <cstdlib>
|
||||
|
@ -29,7 +30,7 @@ XMMSHandler &XMMSHandler::getInstance ()
|
|||
return singleton;
|
||||
}
|
||||
|
||||
XMMSHandler::XMMSHandler () : QObject (), m_client ("promoe")
|
||||
XMMSHandler::XMMSHandler () : QObject (), XMMSSocket ()
|
||||
{
|
||||
connect (std::getenv ( "XMMS_PATH" ));
|
||||
}
|
||||
|
@ -37,17 +38,8 @@ XMMSHandler::XMMSHandler () : QObject (), m_client ("promoe")
|
|||
bool
|
||||
XMMSHandler::connect (const char *path)
|
||||
{
|
||||
try {
|
||||
m_client.connect (path ? path : "");
|
||||
}
|
||||
catch (Xmms::connection_error& e) {
|
||||
QErrorMessage *err = new QErrorMessage ();
|
||||
err->showMessage ("Couldn't connect to XMMS2, please try again.");
|
||||
err->exec ();
|
||||
delete err;
|
||||
if (!XMMSSocket::connect (path))
|
||||
return false;
|
||||
}
|
||||
m_client.setMainloop (new XmmsQT4 (m_client.getConnection ()));
|
||||
|
||||
using Xmms::bind;
|
||||
m_client.playlist.list (bind (&XMMSHandler::playlist_list, this));
|
||||
|
@ -345,6 +337,3 @@ void XMMSHandler::prev ()
|
|||
m_client.playback.tickle (&log);
|
||||
}
|
||||
|
||||
XMMSHandler::~XMMSHandler ()
|
||||
{
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
#include "XmmsQT4.h"
|
||||
#include "XMMSSocket.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QHash>
|
||||
#include <QTimer>
|
||||
|
||||
class XMMSHandler : public QObject {
|
||||
class XMMSHandler : public QObject, XMMSSocket {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static XMMSHandler &getInstance ();
|
||||
~XMMSHandler ();
|
||||
|
||||
bool connect (const char *path);
|
||||
|
||||
|
@ -76,11 +76,10 @@ class XMMSHandler : public QObject {
|
|||
void getVolume (uint);
|
||||
|
||||
private:
|
||||
Xmms::Client m_client;
|
||||
|
||||
QTimer m_playtime_timer;
|
||||
|
||||
XMMSHandler ();
|
||||
~XMMSHandler () {};
|
||||
void DictToQHash (const std::string &key,
|
||||
const Xmms::Dict::Variant &value,
|
||||
QHash<QString, QString> &hash);
|
||||
|
|
29
XMMSSocket.cpp
Normal file
29
XMMSSocket.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
#include <QErrorMessage>
|
||||
#include "XMMSSocket.h"
|
||||
|
||||
XMMSSocket::XMMSSocket (const char *name) :
|
||||
m_client (name)
|
||||
{
|
||||
}
|
||||
|
||||
bool
|
||||
XMMSSocket::connect (const char *path)
|
||||
{
|
||||
try {
|
||||
m_client.connect (path ? path : "");
|
||||
}
|
||||
catch (Xmms::connection_error& e) {
|
||||
QErrorMessage *err = new QErrorMessage ();
|
||||
err->showMessage ("Couldn't connect to XMMS2, please try again.");
|
||||
err->exec ();
|
||||
delete err;
|
||||
return false;
|
||||
}
|
||||
|
||||
m_client.setMainloop (new XmmsQT4 (m_client.getConnection ()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
20
XMMSSocket.h
Normal file
20
XMMSSocket.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef __XMMSSOCKET_H__
|
||||
#define __XMMSSOCKET_H__
|
||||
|
||||
#include <xmmsclient/xmmsclient++.h>
|
||||
|
||||
#include "XmmsQT4.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QTimer>
|
||||
|
||||
class XMMSSocket
|
||||
{
|
||||
public:
|
||||
XMMSSocket (const char *name = "promoe");
|
||||
~XMMSSocket () { qDebug("destroy"); };
|
||||
bool connect (const char *path);
|
||||
Xmms::Client m_client;
|
||||
};
|
||||
|
||||
#endif
|
12
promoe.pro
12
promoe.pro
|
@ -10,6 +10,7 @@ SOURCES += XmmsQT4.cpp \
|
|||
NumberDisplay.cpp \
|
||||
TimeDisplay.cpp \
|
||||
XMMSHandler.cpp \
|
||||
XMMSSocket.cpp \
|
||||
SmallNumberDisplay.cpp \
|
||||
StereoMono.cpp \
|
||||
Slider.cpp \
|
||||
|
@ -25,7 +26,10 @@ SOURCES += XmmsQT4.cpp \
|
|||
VolumeSlider.cpp \
|
||||
ClutterBar.cpp \
|
||||
Equalizer.cpp \
|
||||
FileDialog.cpp
|
||||
FileDialog.cpp \
|
||||
MedialibView.cpp \
|
||||
MedialibWindow.cpp \
|
||||
MedialibTreeModel.cpp
|
||||
|
||||
|
||||
HEADERS += XmmsQT4.h \
|
||||
|
@ -40,6 +44,7 @@ HEADERS += XmmsQT4.h \
|
|||
NumberDisplay.h \
|
||||
TimeDisplay.h \
|
||||
XMMSHandler.h \
|
||||
XMMSSocket.h \
|
||||
SmallNumberDisplay.h \
|
||||
StereoMono.h \
|
||||
Slider.h \
|
||||
|
@ -55,7 +60,10 @@ HEADERS += XmmsQT4.h \
|
|||
VolumeSlider.h \
|
||||
ClutterBar.h \
|
||||
Equalizer.h \
|
||||
FileDialog.h
|
||||
FileDialog.h \
|
||||
MedialibView.h \
|
||||
MedialibWindow.h \
|
||||
MedialibTreeModel.h
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue