Okular

misc.cpp
1/*
2 SPDX-FileCopyrightText: 2005 Piotr Szymanski <niedakh@gmail.com>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "core/misc.h"
8
9#include <QDebug>
10
11#include "debug_p.h"
12
13using namespace Okular;
14
15class TextSelection::Private
16{
17public:
18 int direction;
19 NormalizedPoint cur[2];
20};
21
23 : d(std::make_unique<Private>())
24{
25 if (end.y - start.y < 0 || (end.y - start.y == 0 && end.x - start.x < 0)) {
26 d->direction = 1;
27 } else {
28 d->direction = 0;
29 }
30
31 d->cur[0] = start;
32 d->cur[1] = end;
33}
34
36
38{
39 return d->cur[d->direction % 2];
40}
41
43{
44 return d->cur[(d->direction + 1) % 2];
45}
NormalizedPoint is a helper class which stores the coordinates of a normalized point.
Definition area.h:117
double x
The normalized x coordinate.
Definition area.h:166
double y
The normalized y coordinate.
Definition area.h:171
NormalizedPoint end() const
Returns the end point of the selection.
Definition misc.cpp:42
~TextSelection()
Destroys the text selection.
NormalizedPoint start() const
Returns the start point of the selection.
Definition misc.cpp:37
TextSelection(const NormalizedPoint &start, const NormalizedPoint &end)
Creates a new text selection with the given start and end point.
Definition misc.cpp:22
Q_SCRIPTABLE Q_NOREPLY void start()
global.h
Definition action.h:17
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:35 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.