viewmode.h 3.99 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 <qobject.h>
24
#include <qstring.h>
25
#include <qdict.h>
26

27 28
#include "playlistbox.h"

29 30 31
class QPainter;
class QColorGroup;

32 33 34
class SearchPlaylist;

class ViewMode : public QObject
35
{
36 37
    Q_OBJECT

38 39 40 41
public:
    ViewMode(PlaylistBox *b);
    virtual ~ViewMode();

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

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

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

    virtual bool eventFilter(QObject *watched, QEvent *e);
55 56 57
    
protected:
    PlaylistBox *playlistBox() const { return m_playlistBox; }
58
    bool visible() const { return m_visible; }
59
    void setVisible(bool v) { m_visible = v; }
60 61
    void updateIcons(int size);

62
protected:
63
    virtual void updateHeights();
64

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

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

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

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

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

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

class TreeViewMode : public CompactViewMode
{
104 105
    Q_OBJECT

106 107 108 109 110 111
public:
    TreeViewMode(PlaylistBox *l);
    virtual ~TreeViewMode();

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

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

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

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

127
private:
128
    QDict<PlaylistBox::Item> m_searchCategories;    
129 130 131
};

#endif