viewmode.h 3.86 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 20
    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>

21
#include <qdict.h>
22

23 24
#include "playlistbox.h"

25 26 27
class QPainter;
class QColorGroup;

28 29 30
class SearchPlaylist;

class ViewMode : public QObject
31
{
32 33
    Q_OBJECT

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

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

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

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

    virtual bool eventFilter(QObject *watched, QEvent *e);
51
    
52 53 54

    void queueRefresh() { m_needsRefresh = true; }

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

63
private:
64 65
    QStringList lines(const PlaylistBox::Item *item, const QFontMetrics &fm, int width) const;

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

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

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

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

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

class TreeViewMode : public CompactViewMode
{
99 100
    Q_OBJECT

101 102 103 104 105 106
public:
    TreeViewMode(PlaylistBox *l);
    virtual ~TreeViewMode();

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

108 109 110 111
    virtual PlaylistBox::Item *createSearchItem(PlaylistBox *box,
                                                SearchPlaylist *playlist,
                                                const QString &searchCategory);

112
private:
113 114
    void setupCategory(const QString &searchCategory, const QStringList &members,
		       int column, bool exact = true);
115

116 117 118 119 120 121
private slots:
    /**
     * Setup all of the categories.
     */
    void slotSetupCategories();

122
private:
123
    QDict<PlaylistBox::Item> m_searchCategories;    
124 125 126
};

#endif