~ubuntu-branches/ubuntu/maverick/datakiosk/maverick

« back to all changes in this revision

Viewing changes to src/datakiosk/src/viewmode.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2005-06-27 22:48:06 UTC
  • Revision ID: james.westby@ubuntu.com-20050627224806-8farkci1dc2onhbs
Tags: upstream-0.7
ImportĀ upstreamĀ versionĀ 0.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *   Copyright (C) 2005 by Adam Treat                                      *
 
3
 *   treat@kde.org                                                         *
 
4
 *                                                                         *
 
5
 *   Copyright (C) 2004 by Scott Wheeler                                   *
 
6
 *   wheeler@kde.org                                                       *
 
7
 *                                                                         *
 
8
 *   This program is free software; you can redistribute it and/or modify  *
 
9
 *   it under the terms of the GNU General Public License as published by  *
 
10
 *   the Free Software Foundation; either version 2 of the License, or     *
 
11
 *   (at your option) any later version.                                   *
 
12
 *                                                                         *
 
13
 ***************************************************************************/
 
14
 
 
15
#ifndef VIEWMODE_H
 
16
#define VIEWMODE_H
 
17
 
 
18
#include <qdict.h>
 
19
 
 
20
#include "datatablebox.h"
 
21
 
 
22
class QString;
 
23
class QPainter;
 
24
class QColorGroup;
 
25
class SearchDataTable;
 
26
 
 
27
class ViewMode : public QObject
 
28
{
 
29
    Q_OBJECT
 
30
 
 
31
public:
 
32
    ViewMode( DataTableBox *b );
 
33
    virtual ~ViewMode();
 
34
 
 
35
    virtual QString name() const
 
36
    {
 
37
        return i18n( "Default" );
 
38
    }
 
39
    virtual void setShown( bool shown );
 
40
 
 
41
    virtual void paintCell( DataTableBox::Item *item,
 
42
                            QPainter *painter,
 
43
                            const QColorGroup &colorGroup,
 
44
                            int column, int width, int align );
 
45
 
 
46
    virtual bool eventFilter( QObject *watched, QEvent *e );
 
47
 
 
48
    virtual void setupItem( DataTableBox::Item *item ) const;
 
49
 
 
50
    void queueRefresh()
 
51
    {
 
52
        m_needsRefresh = true;
 
53
    }
 
54
    bool needsRefresh()
 
55
    {
 
56
        return m_needsRefresh;
 
57
    }
 
58
    void setNeedsRefresh( bool refresh )
 
59
    {
 
60
        m_needsRefresh = refresh;
 
61
    }
 
62
 
 
63
protected:
 
64
    DataTableBox *dataTableBox() const
 
65
    {
 
66
        return m_dataTableBox;
 
67
    }
 
68
    bool visible() const
 
69
    {
 
70
        return m_visible;
 
71
    }
 
72
    void setVisible( bool v )
 
73
    {
 
74
        m_visible = v;
 
75
    }
 
76
    void updateIcons( int size );
 
77
    virtual void updateHeights();
 
78
    static void paintDropIndicator( QPainter *painter, int width, int height );
 
79
 
 
80
    static QStringList lines( const DataTableBox::Item *item, const QFontMetrics &fm, int width );
 
81
 
 
82
    DataTableBox *m_dataTableBox;
 
83
    bool m_visible;
 
84
    bool m_needsRefresh;
 
85
    QMap<DataTableBox::Item *, QStringList> m_lines;
 
86
    static const int border = 4;
 
87
};
 
88
 
 
89
class CompactViewMode : public ViewMode
 
90
{
 
91
public:
 
92
    CompactViewMode( DataTableBox *b );
 
93
    virtual ~CompactViewMode();
 
94
 
 
95
    virtual QString name() const
 
96
    {
 
97
        return i18n( "Compact" );
 
98
    }
 
99
    virtual void setShown( bool shown );
 
100
 
 
101
    virtual void paintCell( DataTableBox::Item *item,
 
102
                            QPainter *painter,
 
103
                            const QColorGroup &colorGroup,
 
104
                            int column, int width, int align );
 
105
 
 
106
    virtual void setupItem( DataTableBox::Item *item ) const;
 
107
 
 
108
protected:
 
109
    virtual void updateHeights();
 
110
};
 
111
 
 
112
class TreeViewItemDataTable;
 
113
 
 
114
class TreeViewMode : public CompactViewMode
 
115
{
 
116
    Q_OBJECT
 
117
 
 
118
public:
 
119
    TreeViewMode( DataTableBox *l );
 
120
    virtual ~TreeViewMode();
 
121
 
 
122
    virtual QString name() const
 
123
    {
 
124
        return i18n( "Tree" );
 
125
    }
 
126
    virtual void setShown( bool shown );
 
127
};
 
128
 
 
129
#endif