aboutsummaryrefslogtreecommitdiff
path: root/src/views/mcontentitemview.h
blob: 82493cd0e8bd6686068045dfad2d7e3d233c267b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/***************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (directui@nokia.com)
**
** This file is part of libmeegotouch.
**
** If you have questions regarding the use of this file, please contact
** Nokia at directui@nokia.com.
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation
** and appearing in the file LICENSE.LGPL included in the packaging
** of this file.
**
****************************************************************************/

#ifndef MCONTENTITEMVIEW_H__
#define MCONTENTITEMVIEW_H__

#include "mwidgetview.h"
#include "mcontentitemmodel.h"
#include "mcontentitemstyle.h"

class MContentItem;
class MContentItemViewPrivate;

/*!
    \class MContentItemView
    \brief View class for MContentItem.

    \ingroup views

    \section MContentItemView Overview
        MContentItemView draws MContentItem as a 2 text lines and a thumbnail and any combination of those depending
        on the style.

        MContentItemView supports 4 different layouts for text and thumnbail. They have to be set through MContentItem::setItemStyle().

        \image html content-item-styles.png

        MContentItemView supports different modes which has to be set through MContentItem::setItemMode()

        \image html content-item-modes.png
  */
class M_VIEWS_EXPORT MContentItemView : public MWidgetView
{
    Q_OBJECT
    M_VIEW(MContentItemModel, MContentItemStyle)

public:
    MContentItemView(MContentItem *controller);
    virtual ~MContentItemView();

protected slots:
    virtual void updateData(const QList<const char *> &modifications);

protected:
    //! \reimp
    virtual void drawBackground(QPainter *painter, const QStyleOptionGraphicsItem *option) const;
    virtual void setupModel();
    virtual void applyStyle();
    virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
    virtual void cancelEvent(MCancelEvent *event);
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);

    virtual void tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGesture *gesture);
    //! \reimp_end

    void setSelected(bool selected);

    //! \internal
    MContentItemView(MContentItemViewPrivate &dd, MContentItem *controller);
    //! \internal_end

private:
    Q_DISABLE_COPY(MContentItemView)
    Q_DECLARE_PRIVATE(MContentItemView)
    Q_PRIVATE_SLOT(d_func(), void _q_applyQueuedStyleModeChange())
};

#endif