viewmode.h 4.03 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/***************************************************************************
                          viewmode.h
                             -------------------
    begin                : Sat Jun 7 2003
    copyright            : (C) 2003 by Scott Wheeler, 
    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

#include <klocale.h>

23
#include <qdict.h>
24

25 26
#include "playlistbox.h"

27 28 29
class QPainter;
class QColorGroup;

30 31 32
class SearchPlaylist;

class ViewMode : public QObject
33
{
34 35
    Q_OBJECT

36 37 38 39
public:
    ViewMode(PlaylistBox *b);
    virtual ~ViewMode();

40
    virtual QString name() const { return i18n("Default"); }
41 42
    virtual void setShown(bool shown);

43
    virtual void paintCell(PlaylistBox::Item *item,
44 45 46
                           QPainter *painter, 
                           const QColorGroup &colorGroup,
                           int column, int width, int align);
47 48 49 50

    virtual PlaylistBox::Item *createSearchItem(PlaylistBox *box,
                                                SearchPlaylist *playlist,
                                                const QString &searchCategory);
51 52

    virtual bool eventFilter(QObject *watched, QEvent *e);
53
    
54 55 56

    void queueRefresh() { m_needsRefresh = true; }

57 58
protected:
    PlaylistBox *playlistBox() const { return m_playlistBox; }
59
    bool visible() const { return m_visible; }
60
    void setVisible(bool v) { m_visible = v; }
61 62
    void updateIcons(int size);

63
protected:
64
    virtual void updateHeights();
65

66 67 68 69 70
signals:
    void signalCreateSearchList(const PlaylistSearch &search,
                                const QString &searchCategory,
                                const QString &name);
    
71
private:
72 73
    QStringList lines(const PlaylistBox::Item *item, const QFontMetrics &fm, int width) const;

74 75
    PlaylistBox *m_playlistBox;
    bool m_visible;
76
    bool m_needsRefresh;
77
    QMap<PlaylistBox::Item *, QStringList> m_lines;
78 79 80 81 82 83 84 85 86 87 88 89 90
};

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

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

91
    virtual void paintCell(PlaylistBox::Item *item,
92 93 94
                           QPainter *painter,
                           const QColorGroup &colorGroup,
                           int column, int width, int align);
95 96 97 98
protected:
    /**
     * Override the implementation from the base class.  This isn't needed here.
     */
99
    virtual void updateHeights();
100 101 102 103 104 105
};

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

class TreeViewMode : public CompactViewMode
{
106 107
    Q_OBJECT

108 109 110 111 112 113
public:
    TreeViewMode(PlaylistBox *l);
    virtual ~TreeViewMode();

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

115 116 117 118
    virtual PlaylistBox::Item *createSearchItem(PlaylistBox *box,
                                                SearchPlaylist *playlist,
                                                const QString &searchCategory);

119
private:
120 121
    void setupCategory(const QString &searchCategory, const QStringList &members,
		       int column, bool exact = true);
122

123 124 125 126 127 128
private slots:
    /**
     * Setup all of the categories.
     */
    void slotSetupCategories();

129
private:
130
    QDict<PlaylistBox::Item> m_searchCategories;    
131 132 133
};

#endif