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 );
57 inline MLItem *getItem( QModelIndex index ) const
60 return static_cast<MLItem*>( index.internalPointer() );
63 virtual int getId( QModelIndex index ) const;
65 QVariant data( const QModelIndex &idx, int role = Qt::DisplayRole ) const;
66 bool setData( const QModelIndex &idx, const QVariant &value,
67 int role = Qt::EditRole );
68 ml_select_e columnType( int column ) const;
70 QModelIndex index( int row, int column,
71 const QModelIndex & parent = QModelIndex() ) const;
72 virtual QModelIndex currentIndex() const;
73 int rowCount( const QModelIndex & parent = QModelIndex() ) const;
74 int columnCount( const QModelIndex & parent = QModelIndex() ) const;
76 QModelIndex parent( const QModelIndex& ) const;
77 QVariant headerData( int, Qt::Orientation, int ) const;
78 Qt::ItemFlags flags( const QModelIndex& ) const;
79 bool isEditable( const QModelIndex& ) const;
81 // Drag and drop: MIME data
82 QMimeData* mimeData( const QModelIndexList & indexes ) const;
85 int insertMedia( ml_media_t *p_media, int row = -1,
86 bool bSignal = true );
87 int appendMedia( ml_media_t *p_media );
88 int insertMediaArray( vlc_array_t *p_media_array, int row = -1,
89 bool bSignal = true );
91 int insertResult( const ml_result_t *p_result, int row = -1,
92 bool bSignal = true );
93 inline int appendResult( const ml_result_t *p_result );
94 int insertResultArray( vlc_array_t *p_result_array, int row = -1,
95 bool bSignal = true );
97 void remove( MLItem *item );
98 void remove( QModelIndexList list );
99 void remove( QModelIndex idx );
102 virtual bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
103 void play( const QModelIndex &idx );
104 QStringList selectedURIs();
107 void activateItem( const QModelIndex &index );
117 QList< MLItem* > items;
118 media_library_t* p_ml;
120 QModelIndex current_index;
121 QModelIndexList current_selection;