summaryrefslogtreecommitdiff
path: root/src/kpage.cpp
blob: e1e39dfddb2b505eb63d37f1276e6e61e7afddcc (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
#include "kpage.h"
#include <QList>
#include "selection.h"

using namespace std;

KPage::KPage() :
		links(NULL),
		inverted_colors(false),
		text(NULL) {
	for (int i = 0; i < 3; i++) {
		status[i] = 0;
		rotation[i] = 0;
	}
}

KPage::~KPage() {
	if (links != NULL) {
		Q_FOREACH(Poppler::Link *l, *links) {
			delete l;
		}
	}
	delete links;
	if (text != NULL) {
		Q_FOREACH(SelectionLine *line, *text) {
			delete line;
		}
	}
	delete text;
}

const QImage *KPage::get_image(int index) const {
	// return any available image, try the right index first
	for (int i = 3; i > 0; i--) {
		if (!img[(index + i) % 3].isNull()) {
			return &img[(index + i) % 3];
		}
	}
	if (thumbnail.isNull()) {
		return NULL;
	} else {
		return &thumbnail;
	}
}

int KPage::get_width(int index) const {
	return status[index];
}

char KPage::get_rotation(int index) const {
	return rotation[index];
}

const QList<SelectionLine *> *KPage::get_text() const {
	return text;
}

//QString KPage::get_label() const {
//	return label;
//}