Commit ed89fe73 authored by Srikanth Raju's avatar Srikanth Raju

Qt/ML: ML Model and Item

ML Model/Item which queries the module and provides a QAbstractItemModel Interface
parent e51eb917
......@@ -60,6 +60,8 @@ nodist_SOURCES_qt4 = \
components/epg/EPGWidget.moc.cpp \
components/playlist/views.moc.cpp \
components/playlist/vlc_model.moc.cpp \
components/playlist/ml_item.moc.cpp \
components/playlist/ml_model.moc.cpp \
components/playlist/playlist_model.moc.cpp \
components/playlist/playlist.moc.cpp \
components/playlist/standardpanel.moc.cpp \
......@@ -276,6 +278,8 @@ SOURCES_qt4 = qt4.cpp \
components/epg/EPGView.cpp \
components/epg/EPGWidget.cpp \
components/playlist/views.cpp \
components/playlist/ml_item.cpp \
components/playlist/ml_model.cpp \
components/playlist/vlc_model.cpp \
components/playlist/playlist_model.cpp \
components/playlist/playlist_item.cpp \
......@@ -343,6 +347,8 @@ noinst_HEADERS = \
components/epg/EPGView.hpp \
components/epg/EPGWidget.hpp \
components/playlist/views.hpp \
components/playlist/ml_item.hpp \
components/playlist/ml_model.hpp \
components/playlist/vlc_model.hpp \
components/playlist/playlist_model.hpp \
components/playlist/playlist_item.hpp \
......
This diff is collapsed.
/*****************************************************************************
* ml_item.hpp: the media library's result item
*****************************************************************************
* Copyright (C) 2008-2011 the VideoLAN Team and AUTHORS
* $Id$
*
* Authors: Antoine Lejeune <phytos@videolan.org>
* Jean-Philippe André <jpeg@videolan.org>
* Rémi Duraffort <ivoire@videolan.org>
* Adrien Maglo <magsoft@videolan.org>
* Srikanth Raju <srikiraju#gmail#com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _MEDIA_LIBRARY_MLITEM_H
#define _MEDIA_LIBRARY_MLITEM_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef MEDIA_LIBRARY
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_media_library.h>
#include "ml_model.hpp"
#include "qt4.hpp"
class MLModel;
class MLItem
{
public:
MLItem( const MLModel *p_model, intf_thread_t *_p_intf,
ml_media_t *p_media, MLItem *p_parent );
virtual ~MLItem();
void addChild( MLItem *child, int row = -1 );
void delChild( int row );
void clearChildren();
MLItem* child( int row ) const;
int childCount() const;
MLItem* parent() const;
QVariant data( int column ) const;
bool setData( ml_select_e meta, const QVariant &data );
int rowOfChild( MLItem *item ) const;
// Media structure connections
int id() const;
ml_media_t* getMedia() const;
QUrl getUri() const;
bool operator<( MLItem* item );
private:
ml_media_t* media;
intf_thread_t* p_intf;
media_library_t* p_ml;
QList< MLItem* > children;
MLItem *parentItem;
const MLModel *model;
};
#endif
#endif
This diff is collapsed.
/*****************************************************************************
* ml_model.hpp ML model
*****************************************************************************
* Copyright (C) 2008-2011 the VideoLAN Team and AUTHORS
* $Id$
*
* Authors: Antoine Lejeune <phytos@videolan.org>
* Jean-Philippe André <jpeg@videolan.org>
* Rémi Duraffort <ivoire@videolan.org>
* Adrien Maglo <magsoft@videolan.org>
* Srikanth Raju <srikiraju#gmail#com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _MEDIA_LIBRARY_MLMODEL_H
#define _MEDIA_LIBRARY_MLMODEL_H
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef MEDIA_LIBRARY
#include <vlc_common.h>
#include <vlc_interface.h>
#include <vlc_media_library.h>
#include "components/playlist/vlc_model.hpp"
#include "ml_item.hpp"
#include "qt4.hpp"
class MLItem;
/** *************************************************************************
* \brief Tree model for the result list
****************************************************************************/
class MLModel : public VLCModel
{
Q_OBJECT;
public:
// Basic QAbstractItemModel implementation
MLModel( intf_thread_t *_p_intf, QObject *parent = NULL );
virtual ~MLModel();
inline MLItem *getItem( QModelIndex index ) const
{
if( index.isValid() )
return static_cast<MLItem*>( index.internalPointer() );
else return NULL;
}
virtual int getId( QModelIndex index ) const;
QVariant data( const QModelIndex &idx, int role = Qt::DisplayRole ) const;
bool setData( const QModelIndex &idx, const QVariant &value,
int role = Qt::EditRole );
ml_select_e columnType( int column ) const;
QModelIndex index( int row, int column,
const QModelIndex & parent = QModelIndex() ) const;
virtual QModelIndex currentIndex() const;
int rowCount( const QModelIndex & parent = QModelIndex() ) const;
int columnCount( const QModelIndex & parent = QModelIndex() ) const;
QModelIndex parent( const QModelIndex& ) const;
QVariant headerData( int, Qt::Orientation, int ) const;
Qt::ItemFlags flags( const QModelIndex& ) const;
bool isEditable( const QModelIndex& ) const;
// Drag and drop: MIME data
QMimeData* mimeData( const QModelIndexList & indexes ) const;
// Custom functions
int insertMedia( ml_media_t *p_media, int row = -1,
bool bSignal = true );
int appendMedia( ml_media_t *p_media );
int insertMediaArray( vlc_array_t *p_media_array, int row = -1,
bool bSignal = true );
int insertResult( const ml_result_t *p_result, int row = -1,
bool bSignal = true );
inline int appendResult( const ml_result_t *p_result );
int insertResultArray( vlc_array_t *p_result_array, int row = -1,
bool bSignal = true );
void remove( MLItem *item );
void remove( QModelIndexList list );
void remove( QModelIndex idx );
void clear();
virtual bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
void play( const QModelIndex &idx );
QStringList selectedURIs();
public slots:
void activateItem( const QModelIndex &index );
protected slots:
void popupDel();
void popupPlay();
void popupInfo();
void popupStream();
void popupSave();
private:
QList< MLItem* > items;
media_library_t* p_ml;
QModelIndex current_index;
QModelIndexList current_selection;
};
#endif
#endif
/*****************************************************************************
* sorting.h : commun sorting & column display code
****************************************************************************
* Copyright © 2008 the VideoLAN team
* Copyright © 2008 the VideoLAN team and AUTHORS
* $Id$
*
* Authors: Rafaël Carré <funman@videolanorg>
......@@ -21,6 +21,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef _SORTING_H_
#define _SORTING_H_
#include <vlc_media_library.h>
/* You can use these numbers with | and & to determine what you want to show */
enum
{
......@@ -33,10 +36,12 @@ enum
COLUMN_DESCRIPTION = 0x0040,
COLUMN_URI = 0x0080,
COLUMN_NUMBER = 0x0100,
COLUMN_RATING = 0x0200,
COLUMN_COVER = 0x0400,
/* Add new entries here and update the COLUMN_END value*/
COLUMN_END = 0x0200
COLUMN_END = 0x0800
};
#define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
......@@ -55,6 +60,8 @@ static inline const char * psz_column_title( uint32_t i_column )
case COLUMN_TRACK_NUMBER: return VLC_META_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return VLC_META_DESCRIPTION;
case COLUMN_URI: return _("URI");
case COLUMN_RATING: return VLC_META_RATING;
case COLUMN_COVER: return VLC_META_ART_URL;
default: abort();
}
}
......@@ -88,6 +95,10 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
return input_item_GetDescription( p_item );
case COLUMN_URI:
return input_item_GetURI( p_item );
case COLUMN_RATING:
return input_item_GetRating( p_item );
case COLUMN_COVER:
return input_item_GetArtworkURL( p_item );
default:
abort();
}
......@@ -107,6 +118,28 @@ static inline int i_column_sorting( uint32_t i_column )
case COLUMN_TRACK_NUMBER: return SORT_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return SORT_DESCRIPTION;
case COLUMN_URI: return SORT_URI;
case COLUMN_RATING: return SORT_RATING;
default: abort();
}
}
static inline ml_select_e meta_to_mlmeta( uint32_t i_column )
{
switch( i_column )
{
case COLUMN_NUMBER: return ML_ID;
case COLUMN_TITLE: return ML_TITLE;
case COLUMN_DURATION: return ML_DURATION;
case COLUMN_ARTIST: return ML_ARTIST;
case COLUMN_GENRE: return ML_GENRE;
case COLUMN_ALBUM: return ML_ALBUM;
case COLUMN_TRACK_NUMBER: return ML_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return ML_EXTRA;
case COLUMN_URI: return ML_URI;
case COLUMN_RATING: return ML_VOTE;
case COLUMN_COVER: return ML_COVER;
default: abort();
}
}
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment