summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarco Martin <notmart@gmail.com>2015-09-23 12:34:12 (GMT)
committerMarco Martin <notmart@gmail.com>2015-09-23 12:34:12 (GMT)
commitbb5c4291e28123f48519261327176e93642b06f5 (patch)
treec6b3d0eb79a39b9774cae11354f82f5f0b642659
parentc8db5970524eb9676e6f87a1dcc030ec35294e17 (diff)
fix and port the Table of Contents browser
-rw-r--r--mobile/app/package/contents/ui/TableOfContents.qml16
-rw-r--r--mobile/app/package/contents/ui/Thumbnails.qml1
-rw-r--r--mobile/app/package/contents/ui/TreeDelegate.qml13
-rw-r--r--mobile/components/documentitem.cpp3
-rw-r--r--ui/tocmodel.cpp9
-rw-r--r--ui/tocmodel.h13
6 files changed, 43 insertions, 12 deletions
diff --git a/mobile/app/package/contents/ui/TableOfContents.qml b/mobile/app/package/contents/ui/TableOfContents.qml
index 79b0451..b5a9bc9 100644
--- a/mobile/app/package/contents/ui/TableOfContents.qml
+++ b/mobile/app/package/contents/ui/TableOfContents.qml
@@ -21,16 +21,22 @@ import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.extras 2.0 as PlasmaExtras
-import org.kde.plasma.mobilecomponents 2.0 as MobileComponents
+import org.kde.plasma.mobilecomponents 0.2 as MobileComponents
PlasmaComponents.Page {
+ id: root
property alias contentY: flickable.contentY
property alias contentHeight: flickable.contentHeight
- tools: MobileComponents.ViewSearch {
- id: searchField
- anchors.centerIn: parent
- busy: documentItem.searchInProgress
+ tools: Item {
+ id: toolBarContent
+ width: root.width
+ height: searchField.height
+ PlasmaComponents.TextField {
+ id: searchField
+ clearButtonShown: true
+ anchors.centerIn: parent
+ }
}
PlasmaExtras.ScrollArea {
anchors.fill: parent
diff --git a/mobile/app/package/contents/ui/Thumbnails.qml b/mobile/app/package/contents/ui/Thumbnails.qml
index 00223f6..c3a4f84 100644
--- a/mobile/app/package/contents/ui/Thumbnails.qml
+++ b/mobile/app/package/contents/ui/Thumbnails.qml
@@ -33,6 +33,7 @@ ThumbnailsBase {
height: searchField.height
PlasmaComponents.TextField {
id: searchField
+ clearButtonShown: true
enabled: documentItem.supportsSearch
anchors.centerIn: parent
onTextChanged: {
diff --git a/mobile/app/package/contents/ui/TreeDelegate.qml b/mobile/app/package/contents/ui/TreeDelegate.qml
index 88c5b68..e696d35 100644
--- a/mobile/app/package/contents/ui/TreeDelegate.qml
+++ b/mobile/app/package/contents/ui/TreeDelegate.qml
@@ -20,7 +20,7 @@
import QtQuick 2.1
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.core 2.0 as PlasmaCore
-import org.kde.qtextracomponents 2.0
+import org.kde.kquickcontrolsaddons 2.0
Column {
id: treeDelegate
@@ -28,13 +28,13 @@ Column {
property int rowIndex: index
width: parent.width
- property bool matches: searchField.searchQuery.length < 3 || display.toLowerCase().indexOf(searchField.searchQuery.toLowerCase()) !== -1
+ property bool matches: display.toLowerCase().indexOf(searchField.text.toLowerCase()) !== -1
MouseArea {
id: delegateArea
width: parent.width
- height: label.height
+ height: matches ? label.height : 0
opacity: matches ? 1 : 0
Behavior on opacity {
NumberAnimation {
@@ -56,6 +56,7 @@ Column {
width: theme.smallIconSize
height: width
anchors.verticalCenter: parent.verticalCenter
+ x: units.largeSpacing
}
PlasmaComponents.Label {
id: label
@@ -63,10 +64,10 @@ Column {
verticalAlignment: Text.AlignBottom
anchors.left: icon.right
}
- //there isn't a sane way to do a dotted line in QML1
+ //there isn't a sane way to do a dotted line in QML
Rectangle {
color: theme.textColor
- opacity: 2.0
+ opacity: 0.3
height: 1
anchors {
bottom: parent.bottom
@@ -79,7 +80,7 @@ Column {
text: pageLabel ? pageLabel : page
anchors.right: parent.right
verticalAlignment: Text.AlignBottom
- anchors.rightMargin: 40
+ anchors.rightMargin: units.largeSpacing
}
}
Column {
diff --git a/mobile/components/documentitem.cpp b/mobile/components/documentitem.cpp
index 973e055..3282d15 100644
--- a/mobile/components/documentitem.cpp
+++ b/mobile/components/documentitem.cpp
@@ -60,9 +60,10 @@ void DocumentItem::setPath(const QString &path)
QMimeDatabase db;
m_document->openDocument(path, QUrl::fromLocalFile(path), db.mimeTypeForUrl(QUrl::fromLocalFile(path)));
+ m_tocModel->clear();
m_tocModel->fill(m_document->documentSynopsis());
m_tocModel->setCurrentViewport(m_document->viewport());
-
+qWarning()<<"LLL"<<m_tocModel->count();
m_matchingPages.clear();
for (uint i = 0; i < m_document->pages(); ++i) {
m_matchingPages << (int)i;
diff --git a/ui/tocmodel.cpp b/ui/tocmodel.cpp
index 8bd35f8..ed472fc 100644
--- a/ui/tocmodel.cpp
+++ b/ui/tocmodel.cpp
@@ -132,6 +132,7 @@ void TOCModelPrivate::addChildren( const QDomNode & parentNode, TOCItem * parent
itemsToOpen.append( currentItem );
n = n.nextSibling();
+ emit q->countChanged();
}
}
@@ -169,6 +170,14 @@ TOCModel::~TOCModel()
delete d;
}
+QHash<int, QByteArray> TOCModel::roleNames() const
+{
+ QHash<int, QByteArray> roles = QAbstractItemModel::roleNames();
+ roles[(int)PageItemDelegate::PageRole] = "page";
+ roles[(int)PageItemDelegate::PageLabelRole] = "pageLabel";
+ return roles;
+}
+
int TOCModel::columnCount( const QModelIndex &parent ) const
{
Q_UNUSED( parent )
diff --git a/ui/tocmodel.h b/ui/tocmodel.h
index ce64743..4c56a88 100644
--- a/ui/tocmodel.h
+++ b/ui/tocmodel.h
@@ -24,12 +24,17 @@ class TOCModelPrivate;
class TOCModel : public QAbstractItemModel
{
Q_OBJECT
+ /**
+ * How many items are in this model, useful for QML
+ */
+ Q_PROPERTY(int count READ count NOTIFY countChanged)
public:
explicit TOCModel( Okular::Document *document, QObject *parent = Q_NULLPTR );
virtual ~TOCModel();
// reimplementations from QAbstractItemModel
+ QHash<int, QByteArray> roleNames() const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const Q_DECL_OVERRIDE;
bool hasChildren( const QModelIndex &parent = QModelIndex() ) const Q_DECL_OVERRIDE;
@@ -52,6 +57,14 @@ class TOCModel : public QAbstractItemModel
Okular::DocumentViewport viewportForIndex( const QModelIndex &index ) const;
QString urlForIndex( const QModelIndex &index ) const;
+ int count() const
+ {
+ return rowCount();
+ }
+
+ Q_SIGNALS:
+ void countChanged();
+
private:
// storage
friend class TOCModelPrivate;