Commit 240e4ec4 authored by Francois Cartegnie's avatar Francois Cartegnie

Qt: PLModel: rework menu signaling to get rid of popup data storage in model

parent d4a2b748
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
class PLItem; class PLItem;
class PLSelector; class PLSelector;
class PlMimeData; class PlMimeData;
class QSignalMapper;
class PLModel : public VLCModel class PLModel : public VLCModel
{ {
...@@ -128,6 +127,8 @@ public slots: ...@@ -128,6 +127,8 @@ public slots:
virtual void activateItem( const QModelIndex &index ); virtual void activateItem( const QModelIndex &index );
void clearPlaylist(); void clearPlaylist();
void ensureArtRequested( const QModelIndex &index ); void ensureArtRequested( const QModelIndex &index );
virtual void actionSlot( QAction *action );
private: private:
/* General */ /* General */
PLItem *rootItem; PLItem *rootItem;
...@@ -154,7 +155,7 @@ private: ...@@ -154,7 +155,7 @@ private:
return static_cast<PLItem*>( index.internalPointer() ); return static_cast<PLItem*>( index.internalPointer() );
else return rootItem; else return rootItem;
} }
QStringList selectedURIs(); QStringList selectedURIs( QModelIndexList * );
QModelIndex index( PLItem *, const int c ) const; QModelIndex index( PLItem *, const int c ) const;
bool isCurrent( const QModelIndex &index ) const; bool isCurrent( const QModelIndex &index ) const;
bool isParent( const QModelIndex &index, const QModelIndex &current) const; bool isParent( const QModelIndex &index, const QModelIndex &current) const;
...@@ -175,13 +176,7 @@ private: ...@@ -175,13 +176,7 @@ private:
void dropMove( const PlMimeData * data, PLItem *target, int new_pos ); void dropMove( const PlMimeData * data, PLItem *target, int new_pos );
/* */ /* */
void sort( QModelIndex rootIndex, const int column, Qt::SortOrder order ); void sort( QModelIndex caller, QModelIndex rootIndex, const int column, Qt::SortOrder order );
/* Popup */
QModelIndex popupLauncherIndex;
QModelIndexList current_selection;
QMenu *sortingMenu;
QSignalMapper *sortingMapper;
/* Lookups */ /* Lookups */
PLItem *findById( PLItem *, int ) const; PLItem *findById( PLItem *, int ) const;
...@@ -200,15 +195,6 @@ private: ...@@ -200,15 +195,6 @@ private:
QString latestSearch; QString latestSearch;
private slots: private slots:
void popupPlay();
void popupDel();
void popupInfo();
void popupStream();
void popupSave();
void popupExplore();
void popupAddNode();
void popupAddToPlaylist();
void popupSort( int column );
void processInputItemUpdate( input_item_t *); void processInputItemUpdate( input_item_t *);
void processInputItemUpdate( input_thread_t* p_input ); void processInputItemUpdate( input_thread_t* p_input );
void processItemRemoval( int i_id ); void processItemRemoval( int i_id );
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
#include <QPixmapCache> #include <QPixmapCache>
#include <QSize> #include <QSize>
#include <QAbstractItemModel> #include <QAbstractItemModel>
class QAction;
class VLCModel : public QAbstractItemModel class VLCModel : public QAbstractItemModel
{ {
...@@ -60,6 +60,24 @@ public: ...@@ -60,6 +60,24 @@ public:
static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size ); static QPixmap getArtPixmap( const QModelIndex & index, const QSize & size );
static QString getArtUrl( const QModelIndex & index ); static QString getArtUrl( const QModelIndex & index );
struct actionsContainerType
{
enum
{
ACTION_PLAY = 1,
ACTION_INFO,
ACTION_STREAM,
ACTION_SAVE,
ACTION_EXPLORE,
ACTION_ADDTOPLAYLIST,
ACTION_ADDNODE,
ACTION_REMOVE,
ACTION_SORT
} action;
QModelIndexList indexes; /* for passing selection or caller index(es) */
int column; /* for sorting */
};
static int columnToMeta( int _column ) static int columnToMeta( int _column )
{ {
int meta = 1, column = 0; int meta = 1, column = 0;
...@@ -88,11 +106,13 @@ public: ...@@ -88,11 +106,13 @@ public:
public slots: public slots:
virtual void activateItem( const QModelIndex &index ) = 0; virtual void activateItem( const QModelIndex &index ) = 0;
virtual void actionSlot( QAction *action ) = 0;
protected: protected:
intf_thread_t *p_intf; intf_thread_t *p_intf;
}; };
Q_DECLARE_METATYPE(VLCModel::actionsContainerType)
#endif #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