~ubuntu-branches/ubuntu/trusty/digikam/trusty

« back to all changes in this revision

Viewing changes to core/libs/widgets/q3support/drubberband.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-11-26 18:24:20 UTC
  • mfrom: (1.9.1) (3.1.23 experimental)
  • Revision ID: package-import@ubuntu.com-20121126182420-qoy6z0nx4ai0wzcl
Tags: 4:3.0.0~beta3-0ubuntu1
* New upstream release
  - Add build-deps :  libhupnp-dev, libqtgstreamer-dev, libmagickcore-dev
* Merge from debian, remaining changes:
  - Make sure libqt4-opengl-dev, libgl1-mesa-dev and libglu1-mesa-dev only
    install on i386,amd64 and powerpc
  - Depend on libtiff-dev instead of libtiff4-dev
  - Drop digikam breaks/replaces kipi-plugins-common since we're past the
    LTS release now
  - digikam to recommend mplayerthumbs | ffmpegthumbs. We currently only
    have latter in the archives, even though former is also supposed to
    be part of kdemultimedia. (LP: #890059)
  - kipi-plugins to recommend www-browser rather than konqueror directly
    since 2.8 no direct usage of konqueror is present in the flickr
    plugin anymore (LP: #1011211)
  - Keep kubuntu_mysqld_executable_name.diff
  - Don't install libkipi translations
  - Keep deps on libcv-dev, libcvaux-dev
  - Keep split packaging of libraries
  - Replace icons from KDE 3 time in debian/xpm.d/*.xpm with the new
    versions (LP: #658047)
* Update debian/not-installed

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ============================================================
2
 
 *
3
 
 * This file is a part of digiKam project
4
 
 * http://www.digikam.org
5
 
 *
6
 
 * Date        : 2008-09-07
7
 
 * Description : Rubber band for Q3ScrollView
8
 
 *
9
 
 * Copyright (C) 2008-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10
 
 *
11
 
 * This program is free software; you can redistribute it
12
 
 * and/or modify it under the terms of the GNU General
13
 
 * Public License as published by the Free Software Foundation;
14
 
 * either version 2, or (at your option)
15
 
 * any later version.
16
 
 *
17
 
 * This program is distributed in the hope that it will be useful,
18
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 
 * GNU General Public License for more details.
21
 
 *
22
 
 * ============================================================ */
23
 
 
24
 
#include "drubberband.h"
25
 
 
26
 
// Qt includes
27
 
 
28
 
#include <Qt3Support/Q3ScrollView>
29
 
 
30
 
namespace Digikam
31
 
{
32
 
 
33
 
class DRubberBand::DRubberBandPrivate
34
 
{
35
 
public:
36
 
 
37
 
    DRubberBandPrivate()
38
 
    {
39
 
        scrollView = 0;
40
 
        active     = false;
41
 
    }
42
 
 
43
 
    Q3ScrollView* scrollView;
44
 
    bool          active;
45
 
    QPoint        firstPoint;
46
 
    QPoint        secondPoint;
47
 
    QRect         restriction;
48
 
};
49
 
 
50
 
DRubberBand::DRubberBand(Q3ScrollView* scrollView)
51
 
    : QRubberBand(QRubberBand::Rectangle, scrollView->viewport()),
52
 
      d(new DRubberBandPrivate)
53
 
{
54
 
    d->scrollView = scrollView;
55
 
    hide();
56
 
}
57
 
 
58
 
DRubberBand::~DRubberBand()
59
 
{
60
 
    delete d;
61
 
}
62
 
 
63
 
QRect DRubberBand::rubberBandAreaOnContents() const
64
 
{
65
 
    QRect rubber = QRect(d->firstPoint, d->secondPoint);
66
 
    rubber       = rubber.normalized();
67
 
 
68
 
    if (!d->restriction.isNull())
69
 
    {
70
 
        rubber = rubber.intersected(d->restriction);
71
 
    }
72
 
 
73
 
    return rubber;
74
 
}
75
 
 
76
 
bool DRubberBand::isActive() const
77
 
{
78
 
    return d->active;
79
 
}
80
 
 
81
 
void DRubberBand::setActive(bool active)
82
 
{
83
 
    d->active = active;
84
 
 
85
 
    if (d->active)
86
 
    {
87
 
        show();
88
 
    }
89
 
    else
90
 
    {
91
 
        hide();
92
 
    }
93
 
}
94
 
 
95
 
void DRubberBand::setFirstPointOnViewport(const QPoint& p)
96
 
{
97
 
    d->firstPoint = p;
98
 
    d->active     = true;
99
 
}
100
 
 
101
 
void DRubberBand::setFirstPointOnContents(const QPoint& p)
102
 
{
103
 
    setFirstPointOnViewport(d->scrollView->contentsToViewport(p));
104
 
}
105
 
 
106
 
void DRubberBand::setSecondPointOnViewport(const QPoint& p)
107
 
{
108
 
    d->secondPoint = p;
109
 
 
110
 
    updateForContentsPosition(d->scrollView->contentsX(), d->scrollView->contentsY());
111
 
 
112
 
    if (d->active)
113
 
    {
114
 
        show();
115
 
    }
116
 
}
117
 
 
118
 
void DRubberBand::setSecondPointOnContents(const QPoint& p)
119
 
{
120
 
    setSecondPointOnViewport(d->scrollView->contentsToViewport(p));
121
 
}
122
 
 
123
 
void DRubberBand::setRestrictionOnContents(const QRect& rect)
124
 
{
125
 
    d->restriction = rect;
126
 
}
127
 
 
128
 
void DRubberBand::setRectOnContents(const QRect& rect)
129
 
{
130
 
    setFirstPointOnContents(rect.topLeft());
131
 
    setSecondPointOnContents(rect.bottomRight());
132
 
}
133
 
 
134
 
void DRubberBand::setRectOnViewport(const QRect& rect)
135
 
{
136
 
    setFirstPointOnViewport(rect.topLeft());
137
 
    setSecondPointOnViewport(rect.bottomRight());
138
 
}
139
 
 
140
 
void DRubberBand::updateForContentsPosition(int contentsX, int contentsY)
141
 
{
142
 
    QRect rubber = rubberBandAreaOnContents();
143
 
    rubber.translate( - contentsX, - contentsY);
144
 
 
145
 
    move(rubber.x(), rubber.y());
146
 
    resize(rubber.width(), rubber.height());
147
 
}
148
 
 
149
 
} // namespace Digikam