viewmode.h 3.69 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


Laurent Montel's avatar
Laurent Montel committed
20 21 22
#include <q3dict.h>
//Added by qt3to4:
#include <QEvent>
23

24 25
#include "playlistbox.h"

26 27 28
class QPainter;
class QColorGroup;

29 30 31
class SearchPlaylist;

class ViewMode : public QObject
32
{
33 34
    Q_OBJECT

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

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

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

47
    virtual bool eventFilter(QObject *watched, QEvent *e);
48
    
49 50 51

    void queueRefresh() { m_needsRefresh = true; }

52 53
    virtual void setupItem(PlaylistBox::Item *item) const;

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

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

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

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

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

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

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

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

95 96
class TreeViewItemPlaylist;

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
    void setupCategories();
108

109 110
public slots:
    void slotRemoveItem(const QString &item, unsigned column);
111
    void slotAddItems(const QStringList &items, unsigned column);
112

113 114
    void slotCanDeletePlaylist(bool canDelete);

115 116 117
signals:
    void signalPlaylistDestroyed(Playlist*);

118
private:
Laurent Montel's avatar
Laurent Montel committed
119 120
    Q3Dict<PlaylistBox::Item> m_searchCategories;    
    Q3Dict<TreeViewItemPlaylist> m_treeViewItems;
121 122
    QStringList m_pendingItemsToRemove;
    bool m_canDeletePlaylists;
123 124 125
};

#endif