Qt: correctly display the right treeView columns
[vlc.git] / modules / gui / qt4 / components / playlist / ml_model.hpp
blobc1994d0893819902cd1a201bd1d8db06d228c8ff
1 /*****************************************************************************
2 * ml_model.hpp ML model
3 *****************************************************************************
4 * Copyright (C) 2008-2011 the VideoLAN Team and AUTHORS
5 * $Id$
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
31 #ifdef HAVE_CONFIG_H
32 # include <config.h>
33 #endif
35 #ifdef MEDIA_LIBRARY
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"
42 #include "qt4.hpp"
44 class MLItem;
46 /** *************************************************************************
47 * \brief Tree model for the result list
48 ****************************************************************************/
49 class MLModel : public VLCModel
51 Q_OBJECT;
53 public:
54 // Basic QAbstractItemModel implementation
55 MLModel( intf_thread_t *_p_intf, QObject *parent = NULL );
56 virtual ~MLModel();
57 inline MLItem *getItem( QModelIndex index ) const
59 if( index.isValid() )
60 return static_cast<MLItem*>( index.internalPointer() );
61 else return NULL;
63 virtual int getId( QModelIndex index ) const;
65 QVariant data( const QModelIndex &idx, const 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;
84 // Custom functions
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 virtual void doDelete( QModelIndexList list );
98 void remove( MLItem *item );
99 void remove( QModelIndex idx );
101 void clear();
102 virtual bool popup( const QModelIndex & index, const QPoint &point, const QModelIndexList &list );
103 void play( const QModelIndex &idx );
104 QStringList selectedURIs();
106 public slots:
107 void activateItem( const QModelIndex &index );
109 protected slots:
110 void popupDel();
111 void popupPlay();
112 void popupInfo();
113 void popupStream();
114 void popupSave();
116 private:
117 QList< MLItem* > items;
118 media_library_t* p_ml;
120 QModelIndex current_index;
121 QModelIndexList current_selection;
124 #endif
125 #endif