#include "ml_item.hpp"
#include "qt4.hpp"
+#include <QMutex>
+#include <QEvent>
class MLItem;
+/** *************************************************************************
+ * \brief ML Events class because we don't want direct callbacks
+ ****************************************************************************/
+class MLEvent : public QEvent
+{
+public:
+ static const QEvent::Type MediaAdded_Type;
+ static const QEvent::Type MediaRemoved_Type;
+ static const QEvent::Type MediaUpdated_Type;
+ MLEvent( QEvent::Type type, media_library_t *_p_ml, int32_t _ml_media_id ) :
+ QEvent( type ), ml_media_id( _ml_media_id ), p_ml( _p_ml ) {};
+ int32_t ml_media_id;
+ media_library_t * p_ml; /* store instance */
+};
+
/** *************************************************************************
* \brief Tree model for the result list
****************************************************************************/
// 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 itemId( const QModelIndex & ) const;
QVariant data( const QModelIndex &idx, const 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;
+ virtual bool removeRows( int row, int count, const QModelIndex & parent = QModelIndex() );
+ virtual void sort( const int column, Qt::SortOrder order = Qt::AscendingOrder );
// 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 );
-
- virtual void doDelete( QModelIndexList list );
- void remove( MLItem *item );
- 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();
+ bool isEditable( const QModelIndex& ) const;
+ ml_select_e columnType( int column ) const;
+ virtual bool event( QEvent * e );
+
+ QModelIndex getIndexByMLID( int id ) const;
+
+ /* VLCModelSubInterface */
+ virtual void rebuild( playlist_item_t * p = NULL );
+ virtual void doDelete( QModelIndexList selected );
+ virtual void createNode( QModelIndex, QString ) {};
+ virtual void removeAll();
+
+ virtual QModelIndex rootIndex() const;
+ virtual void filter( const QString& search_text, const QModelIndex & root, bool b_recursive );
+ virtual QModelIndex currentIndex() const;
+ virtual QModelIndex indexByPLID( const int i_plid, const int c ) const;
+ virtual QModelIndex indexByInputItemID( const int i_inputitem_id, const int c ) const;
+ virtual bool isTree() const;
+ virtual bool canEdit() const;
+
+ virtual bool action( QAction *action, const QModelIndexList &indexes );
+ virtual bool isSupportedAction( actions action, const QModelIndex & ) const;
+
+ /* VLCModelSubInterface virtual slots */
+ virtual void activateItem( const QModelIndex &index );
+
+protected:
+
+ /* VLCModel subclassing */
+ bool isParent( const QModelIndex &index, const QModelIndex ¤t) const;
+ bool isLeaf( const QModelIndex &index ) const;
private:
+ /* custom */
+ int insertMedia( ml_media_t *p_media, int row = -1 );
+ int insertResultArray( vlc_array_t *p_result_array, int row = -1 );
QList< MLItem* > items;
media_library_t* p_ml;
-
- QModelIndex current_index;
- QModelIndexList current_selection;
};
#endif