1 /*****************************************************************************
2 * ml_model.hpp ML model
3 *****************************************************************************
4 * Copyright (C) 2008-2011 the VideoLAN Team and AUTHORS
7 * Authors: Antoine Lejeune <phytos@videolan.org>
8 * Jean-Philippe André <jpeg@videolan.org>
9 * Rémi Duraffort <ivoire@videolan.org>
10 * Adrien Maglo <magsoft@videolan.org>
11 * Srikanth Raju <srikiraju#gmail#com>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26 *****************************************************************************/
28 #ifndef _MEDIA_LIBRARY_MLMODEL_H
29 #define _MEDIA_LIBRARY_MLMODEL_H
36 #include <vlc_common.h>
37 #include <vlc_interface.h>
38 #include <vlc_media_library.h>
40 #include "components/playlist/vlc_model.hpp"
41 #include "ml_item.hpp"
46 /** *************************************************************************
47 * \brief Tree model for the result list
48 ****************************************************************************/
49 class MLModel : public VLCModel
54 // Basic QAbstractItemModel implementation
55 MLModel( intf_thread_t *_p_intf, QObject *parent = NULL );
58 virtual int itemId( const QModelIndex & ) const;
60 QVariant data( const QModelIndex &idx, const int role = Qt::DisplayRole ) const;
61 bool setData( const QModelIndex &idx, const QVariant &value,
62 int role = Qt::EditRole );
63 ml_select_e columnType( int column ) const;
65 QModelIndex index( int row, int column,
66 const QModelIndex & parent = QModelIndex() ) const;
67 virtual QModelIndex currentIndex() const;
68 int rowCount( const QModelIndex & parent = QModelIndex() ) const;
69 int columnCount( const QModelIndex & parent = QModelIndex() ) const;
71 QModelIndex parent( const QModelIndex& ) const;
72 QVariant headerData( int, Qt::Orientation, int ) const;
73 Qt::ItemFlags flags( const QModelIndex& ) const;
74 bool isEditable( const QModelIndex& ) const;
76 // Drag and drop: MIME data
77 QMimeData* mimeData( const QModelIndexList & indexes ) const;
80 int insertMedia( ml_media_t *p_media, int row = -1,
81 bool bSignal = true );
82 int appendMedia( ml_media_t *p_media );
83 int insertMediaArray( vlc_array_t *p_media_array, int row = -1,
84 bool bSignal = true );
86 int insertResult( const ml_result_t *p_result, int row = -1,
87 bool bSignal = true );
88 inline int appendResult( const ml_result_t *p_result );
89 int insertResultArray( vlc_array_t *p_result_array, int row = -1,
90 bool bSignal = true );
92 virtual void doDelete( QModelIndexList list );
93 void remove( QModelIndex idx );
96 virtual bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
97 void play( const QModelIndex &idx );
98 QStringList selectedURIs( QModelIndexList * );
99 virtual QString getURI( const QModelIndex &index ) const;
100 virtual QModelIndex rootIndex() const;
101 virtual bool isTree() const;
102 virtual bool canEdit() const;
103 virtual bool isCurrentItem( const QModelIndex &index, playLocation where ) const;
104 QModelIndex getIndexByMLID( int id ) const;
107 void activateItem( const QModelIndex &index );
108 virtual void actionSlot( QAction *action );
111 void remove( MLItem *item );
112 inline MLItem *getItem( QModelIndex index ) const
114 if( index.isValid() )
115 return static_cast<MLItem*>( index.internalPointer() );
120 QList< MLItem* > items;
121 media_library_t* p_ml;