00001 #ifndef PLAYLISTEDITORVIEW_H_
00002 #define PLAYLISTEDITORVIEW_H_
00003
00004
00005 #include <QEvent>
00006 #include <QVector>
00007
00008
00009 #include <mythscreentype.h>
00010 #include <mythgenerictree.h>
00011 #include <mythuibuttonlist.h>
00012
00013
00014 #include "musiccommon.h"
00015
00016 class MythUIButtonTree;
00017 class MythUIText;
00018 class MythMenu;
00019
00020
00021 class MPUBLIC MusicButtonItem : public MythUIButtonListItem, public QObject
00022 {
00023 public:
00024 MusicButtonItem(MythUIButtonList *lbtype, const QString& text,
00025 const QString& image = "", bool checkable = false,
00026 CheckState state = CantCheck, bool showArrow = false,
00027 int listPosition = -1):
00028 MythUIButtonListItem(lbtype, text, image, checkable, state, showArrow, listPosition) {}
00029
00030 MusicButtonItem(MythUIButtonList *lbtype, const QString& text, QVariant data, int listPosition = -1) :
00031 MythUIButtonListItem(lbtype, text, data, listPosition) {}
00032 };
00033
00034 class MPUBLIC MusicGenericTree : public MythGenericTree
00035 {
00036 public:
00037 MusicGenericTree(MusicGenericTree *parent, const QString &name,
00038 const QString &action = "",
00039 MythUIButtonListItem::CheckState state = MythUIButtonListItem::CantCheck,
00040 bool showArrow = true);
00041 virtual ~MusicGenericTree();
00042
00043 QString getAction(void) const { return m_action; }
00044
00045 MythUIButtonListItem::CheckState getCheck(void) const { return m_check; }
00046 void setCheck(MythUIButtonListItem::CheckState state);
00047
00048 void setDrawArrow(bool flag);
00049
00050 MythUIButtonListItem *CreateListButton(MythUIButtonList *list);
00051
00052 protected:
00053 QString m_action;
00054 QPointer<MusicButtonItem> m_buttonItem;
00055 MythUIButtonListItem::CheckState m_check;
00056 bool m_showArrow;
00057 bool m_active;
00058 };
00059
00060 Q_DECLARE_METATYPE(MusicGenericTree*)
00061
00062 class PlaylistEditorView : public MusicCommon
00063 {
00064 Q_OBJECT
00065 public:
00066 PlaylistEditorView(MythScreenStack *parent, const QString &layout, bool restorePosition = false);
00067 ~PlaylistEditorView(void);
00068
00069 bool Create(void);
00070 bool keyPressEvent(QKeyEvent *);
00071
00072 void saveTreePosition(void);
00073
00074 virtual void ShowMenu(void);
00075
00076 protected:
00077 void customEvent(QEvent *event);
00078
00079 private slots:
00080 void treeItemClicked(MythUIButtonListItem *item);
00081 void treeItemVisible(MythUIButtonListItem *item);
00082 void treeNodeChanged(MythGenericTree *node);
00083 void smartPLChanged(const QString &category, const QString &name);
00084 void deleteSmartPlaylist(bool ok);
00085 void deletePlaylist(bool ok);
00086
00087 private:
00088 void filterTracks(MusicGenericTree *node);
00089
00090 void getPlaylists(MusicGenericTree *node);
00091 void getPlaylistTracks(MusicGenericTree *node, int playlistID);
00092
00093 void getSmartPlaylistCategories(MusicGenericTree *node);
00094 void getSmartPlaylists(MusicGenericTree *node);
00095 void getSmartPlaylistTracks(MusicGenericTree *node, int playlistID);
00096
00097 void updateSelectedTracks(void);
00098 void updateSelectedTracks(MusicGenericTree *node);
00099
00100 void createRootNode(void);
00101 void reloadTree(void);
00102 void restoreTreePosition(const QStringList &route);
00103
00104 MythMenu* createPlaylistMenu(void);
00105 MythMenu* createSmartPlaylistMenu(void);
00106
00107 private:
00108 QString m_layout;
00109 bool m_restorePosition;
00110 MusicGenericTree *m_rootNode;
00111 QList<MetadataPtrList*> m_deleteList;
00112
00113 MythUIButtonTree *m_playlistTree;
00114 MythUIText *m_breadcrumbsText;
00115 MythUIText *m_positionText;
00116 };
00117
00118 #endif