aboutsummaryrefslogtreecommitdiff
path: root/src/views/mpannablewidgetview.cpp
blob: 172ed3e828732ae31330610a7ab77ac446c1b553 (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
/***************************************************************************
**
** 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.
**
****************************************************************************/

#include "mpannablewidgetview.h"
#include "mpannablewidgetview_p.h"

#include <QPainter>

#include "mtheme.h"
#include "mpannablewidget.h"
#include "mviewcreator.h"

MPannableWidgetViewPrivate::MPannableWidgetViewPrivate() :
    q_ptr(0), controller(0)
{
}

MPannableWidgetViewPrivate::~MPannableWidgetViewPrivate()
{
}

void MPannableWidgetViewPrivate::_q_applyStyleToPhysics()
{
    Q_Q(MPannableWidgetView);

    controller->model()->setPanThreshold(q->style()->panThreshold());
    controller->model()->setPanClickThreshold(q->style()->panClickThreshold());

    controller->physics()->setPointerSpringK(q->style()->pointerSpringK());
    controller->physics()->setFriction(q->style()->frictionC());
    controller->physics()->setSlidingFriction(q->style()->slidingFrictionC());
    controller->physics()->setBorderSpringK(q->style()->borderSpringK());
    controller->physics()->setBorderFriction(q->style()->borderFrictionC());
    controller->physics()->setPanDirection(controller->panDirection());
}

MPannableWidgetView::MPannableWidgetView(MPannableWidget *controller) :
    MWidgetView(controller),
    d_ptr(new MPannableWidgetViewPrivate)
{
    Q_D(MPannableWidgetView);
    d->q_ptr = this;
    d->controller = controller;
    connect(d->controller, SIGNAL(physicsChanged()), this, SLOT(_q_applyStyleToPhysics()));
}

MPannableWidgetView::~MPannableWidgetView()
{
    delete d_ptr;
}

void MPannableWidgetView::drawContents(QPainter *painter, const QStyleOptionGraphicsItem *option) const
{
    Q_UNUSED(painter);
    Q_UNUSED(option);
}

void MPannableWidgetView::applyStyle()
{
    Q_D(MPannableWidgetView);

    d->_q_applyStyleToPhysics();
    MWidgetView::applyStyle();
}

M_REGISTER_VIEW_NEW(MPannableWidgetView, MPannableWidget)

#include "moc_mpannablewidgetview.cpp"