viewmode.h 3.54 KB
Newer Older
1 2
/***************************************************************************
    begin                : Sat Jun 7 2003
3
    copyright            : (C) 2003 - 2004 by Scott Wheeler, 
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
    email                : wheeler@kde.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef VIEWMODE_H
#define VIEWMODE_H


20
#include <qdict.h>
21

22 23
#include "playlistbox.h"

24 25 26
class QPainter;
class QColorGroup;

27 28 29
class SearchPlaylist;

class ViewMode : public QObject
30
{
31 32
    Q_OBJECT

33 34 35 36
public:
    ViewMode(PlaylistBox *b);
    virtual ~ViewMode();

37
    virtual QString name() const { return i18n("Default"); }
38 39
    virtual void setShown(bool shown);

40
    virtual void paintCell(PlaylistBox::Item *item,
41 42 43
                           QPainter *painter, 
                           const QColorGroup &colorGroup,
                           int column, int width, int align);
44

45
    virtual bool eventFilter(QObject *watched, QEvent *e);
46
    
47 48 49

    void queueRefresh() { m_needsRefresh = true; }

50 51
    virtual void setupItem(PlaylistBox::Item *item) const;

52 53
protected:
    PlaylistBox *playlistBox() const { return m_playlistBox; }
54
    bool visible() const { return m_visible; }
55
    void setVisible(bool v) { m_visible = v; }
56
    void updateIcons(int size);
57
    virtual void updateHeights();
58
    static void paintDropIndicator(QPainter *painter, int width, int height);
59

60
private:
61
    static QStringList lines(const PlaylistBox::Item *item, const QFontMetrics &fm, int width);
62

63 64
    PlaylistBox *m_playlistBox;
    bool m_visible;
65
    bool m_needsRefresh;
66
    QMap<PlaylistBox::Item *, QStringList> m_lines;
67
    static const int border = 4;
68 69 70 71 72 73 74 75 76 77 78 79 80
};

////////////////////////////////////////////////////////////////////////////////

class CompactViewMode : public ViewMode
{
public:
    CompactViewMode(PlaylistBox *b);
    virtual ~CompactViewMode();
    
    virtual QString name() const { return i18n("Compact"); }
    virtual void setShown(bool shown);

81
    virtual void paintCell(PlaylistBox::Item *item,
82 83 84
                           QPainter *painter,
                           const QColorGroup &colorGroup,
                           int column, int width, int align);
85 86

    virtual void setupItem(PlaylistBox::Item *item) const { item->KListViewItem::setup(); }
87
protected:
88
    virtual void updateHeights();
89 90 91 92
};

////////////////////////////////////////////////////////////////////////////////

93 94
class TreeViewItemPlaylist;

95 96
class TreeViewMode : public CompactViewMode
{
97 98
    Q_OBJECT

99 100 101 102 103 104
public:
    TreeViewMode(PlaylistBox *l);
    virtual ~TreeViewMode();

    virtual QString name() const { return i18n("Tree"); }
    virtual void setShown(bool shown);
105
    void setupCategories();
106

107 108 109 110 111 112 113
public slots:
    void slotRemoveItem(const QString &item, unsigned column);
    void slotAddItem(const QString &item, unsigned column);

signals:
    void signalPlaylistDestroyed(Playlist*);

114
private:
115
    QDict<PlaylistBox::Item> m_searchCategories;    
116
    QMap<QString, TreeViewItemPlaylist*> m_treeViewItems;
117 118 119
};

#endif