viewmode.h 3.34 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
protected:
    PlaylistBox *playlistBox() const { return m_playlistBox; }
52
    bool visible() const { return m_visible; }
53
    void setVisible(bool v) { m_visible = v; }
54
    void updateIcons(int size);
55
    virtual void updateHeights();
56
    static void paintDropIndicator(QPainter *painter, int width, int height);
57

58
private:
59 60
    QStringList lines(const PlaylistBox::Item *item, const QFontMetrics &fm, int width) const;

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

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

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

79
    virtual void paintCell(PlaylistBox::Item *item,
80 81 82
                           QPainter *painter,
                           const QColorGroup &colorGroup,
                           int column, int width, int align);
83 84 85 86
protected:
    /**
     * Override the implementation from the base class.  This isn't needed here.
     */
87
    virtual void updateHeights();
88 89 90 91 92 93
};

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

class TreeViewMode : public CompactViewMode
{
94 95
    Q_OBJECT

96 97 98 99 100 101
public:
    TreeViewMode(PlaylistBox *l);
    virtual ~TreeViewMode();

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

104
private:
105 106
    void setupCategory(const QString &searchCategory, const QStringList &members,
		       int column, bool exact = true);
107
private:
108
    QDict<PlaylistBox::Item> m_searchCategories;    
109 110 111
};

#endif