[poppler] qt4/demos

Pino Toscano pino at kemper.freedesktop.org
Wed Feb 27 03:01:30 PST 2008


 qt4/demos/CMakeLists.txt |    1 
 qt4/demos/Makefile.am    |    3 ++
 qt4/demos/optcontent.cpp |   55 +++++++++++++++++++++++++++++++++++++++++++++++
 qt4/demos/optcontent.h   |   43 ++++++++++++++++++++++++++++++++++++
 qt4/demos/viewer.cpp     |    7 +++++
 5 files changed, 109 insertions(+)

New commits:
commit 39fe905be8f2ae79d9c26cd87547f3ea2608411e
Author: Pino Toscano <pino at kde.org>
Date:   Wed Feb 27 12:00:29 2008 +0100

    Add a dock for showing the optional content tree.

diff --git a/qt4/demos/CMakeLists.txt b/qt4/demos/CMakeLists.txt
index 4fe984f..3401337 100644
--- a/qt4/demos/CMakeLists.txt
+++ b/qt4/demos/CMakeLists.txt
@@ -17,6 +17,7 @@ set(poppler_qt4viewer_SRCS
   main_viewer.cpp
   metadata.cpp
   navigationtoolbar.cpp
+  optcontent.cpp
   pageview.cpp
   permissions.cpp
   toc.cpp
diff --git a/qt4/demos/Makefile.am b/qt4/demos/Makefile.am
index 7014300..6e22288 100644
--- a/qt4/demos/Makefile.am
+++ b/qt4/demos/Makefile.am
@@ -36,6 +36,8 @@ poppler_qt4viewer_SOURCES =			\
 	metadata.h				\
 	navigationtoolbar.cpp			\
 	navigationtoolbar.h			\
+	optcontent.cpp				\
+	optcontent.h				\
 	pageview.cpp				\
 	pageview.h				\
 	permissions.cpp				\
@@ -51,6 +53,7 @@ fonts.$(OBJEXT): fonts.moc
 info.$(OBJEXT): info.moc
 metadata.$(OBJEXT): metadata.moc
 navigationtoolbar.$(OBJEXT): navigationtoolbar.moc
+optcontent.$(OBJEXT): optcontent.moc
 pageview.$(OBJEXT): pageview.moc
 permissions.$(OBJEXT): permissions.moc
 toc.$(OBJEXT): toc.moc
diff --git a/qt4/demos/optcontent.cpp b/qt4/demos/optcontent.cpp
new file mode 100644
index 0000000..2f8bebe
--- /dev/null
+++ b/qt4/demos/optcontent.cpp
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "optcontent.h"
+
+#include <poppler-qt4.h>
+
+#include <QtGui/QTreeView>
+
+OptContentDock::OptContentDock(QWidget *parent)
+    : AbstractInfoDock(parent)
+{
+    m_view = new QTreeView(this);
+    setWidget(m_view);
+    setWindowTitle(tr("Optional content"));
+#if QT_VERSION >= 0x040200
+    m_view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
+#endif
+}
+
+OptContentDock::~OptContentDock()
+{
+}
+
+void OptContentDock::fillInfo()
+{
+    if (!document()->hasOptionalContent()) {
+        return;
+    }
+
+    m_view->setModel(document()->optionalContentModel());
+}
+
+void OptContentDock::documentClosed()
+{
+    m_view->setModel(0);
+    AbstractInfoDock::documentClosed();
+}
+
+#include "optcontent.moc"
diff --git a/qt4/demos/optcontent.h b/qt4/demos/optcontent.h
new file mode 100644
index 0000000..6189601
--- /dev/null
+++ b/qt4/demos/optcontent.h
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2008, Pino Toscano <pino at kde.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef OPTCONTENT_H
+#define OPTCONTENT_H
+
+#include "abstractinfodock.h"
+
+class QTreeView;
+
+class OptContentDock : public AbstractInfoDock
+{
+    Q_OBJECT
+
+public:
+    OptContentDock(QWidget *parent = 0);
+    ~OptContentDock();
+
+    /*virtual*/ void documentClosed();
+
+protected:
+    /*virtual*/ void fillInfo();
+
+private:
+    QTreeView *m_view;
+};
+
+#endif
diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index 7d55e0d..6fb9495 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -23,6 +23,7 @@
 #include "info.h"
 #include "metadata.h"
 #include "navigationtoolbar.h"
+#include "optcontent.h"
 #include "pageview.h"
 #include "permissions.h"
 #include "toc.h"
@@ -127,6 +128,12 @@ PdfViewer::PdfViewer()
     viewMenu->addAction(metadataDock->toggleViewAction());
     m_observers.append(metadataDock);
 
+    OptContentDock *optContentDock = new OptContentDock(this);
+    addDockWidget(Qt::LeftDockWidgetArea, optContentDock);
+    optContentDock->hide();
+    viewMenu->addAction(optContentDock->toggleViewAction());
+    m_observers.append(optContentDock);
+
     Q_FOREACH(DocumentObserver *obs, m_observers) {
         obs->m_viewer = this;
     }


More information about the poppler mailing list