Changeset View
Changeset View
Standalone View
Standalone View
mobile/components/documentitem.cpp
Show All 16 Lines | |||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "documentitem.h" | 20 | #include "documentitem.h" | ||
21 | 21 | | |||
22 | #include <QtQml> // krazy:exclude=includes | 22 | #include <QtQml> // krazy:exclude=includes | ||
23 | #include <QMimeDatabase> | 23 | #include <QMimeDatabase> | ||
24 | 24 | | |||
25 | #ifdef Q_OS_ANDROID | ||||
26 | #include <QAndroidJniObject> | ||||
27 | #include <QtAndroid> | ||||
28 | #endif | ||||
29 | | ||||
25 | #include <core/document_p.h> | 30 | #include <core/document_p.h> | ||
26 | #include <core/page.h> | 31 | #include <core/page.h> | ||
27 | #include <core/bookmarkmanager.h> | 32 | #include <core/bookmarkmanager.h> | ||
28 | 33 | | |||
29 | #include "ui/tocmodel.h" | 34 | #include "ui/tocmodel.h" | ||
30 | 35 | | |||
31 | DocumentItem::DocumentItem(QObject *parent) | 36 | DocumentItem::DocumentItem(QObject *parent) | ||
32 | : QObject(parent), | 37 | : QObject(parent), | ||
Show All 21 Lines | |||||
54 | } | 59 | } | ||
55 | 60 | | |||
56 | void DocumentItem::setUrl(const QUrl & url) | 61 | void DocumentItem::setUrl(const QUrl & url) | ||
57 | { | 62 | { | ||
58 | m_document->closeDocument(); | 63 | m_document->closeDocument(); | ||
59 | //TODO: password | 64 | //TODO: password | ||
60 | QMimeDatabase db; | 65 | QMimeDatabase db; | ||
61 | 66 | | |||
62 | const QString path = url.isLocalFile() ? url.toLocalFile() : QStringLiteral("-"); | 67 | QUrl realUrl = url; | ||
68 | | ||||
69 | #ifdef Q_OS_ANDROID | ||||
70 | realUrl = QUrl(QtAndroid::androidActivity().callObjectMethod("contentUrlToFd", | ||||
71 | "(Ljava/lang/String;)Ljava/lang/String;", | ||||
72 | QAndroidJniObject::fromString(url.toString()).object<jstring>() | ||||
73 | ).toString()); | ||||
74 | #endif | ||||
75 | | ||||
76 | const QString path = realUrl.isLocalFile() ? realUrl.toLocalFile() : QStringLiteral("-"); | ||||
63 | 77 | | |||
64 | m_document->openDocument(path, url, db.mimeTypeForUrl(url)); | 78 | m_document->openDocument(path, realUrl, db.mimeTypeForUrl(realUrl)); | ||
65 | 79 | | |||
66 | m_tocModel->clear(); | 80 | m_tocModel->clear(); | ||
67 | m_tocModel->fill(m_document->documentSynopsis()); | 81 | m_tocModel->fill(m_document->documentSynopsis()); | ||
68 | m_tocModel->setCurrentViewport(m_document->viewport()); | 82 | m_tocModel->setCurrentViewport(m_document->viewport()); | ||
69 | 83 | | |||
70 | m_matchingPages.clear(); | 84 | m_matchingPages.clear(); | ||
71 | for (uint i = 0; i < m_document->pages(); ++i) { | 85 | for (uint i = 0; i < m_document->pages(); ++i) { | ||
72 | m_matchingPages << (int)i; | 86 | m_matchingPages << (int)i; | ||
▲ Show 20 Lines • Show All 197 Lines • Show Last 20 Lines |