[poppler] qt4/demos

Pino Toscano pino at kemper.freedesktop.org
Wed Feb 20 17:01:45 PST 2008


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

New commits:
commit bf6dd890994150406b4464e45355a4a99870fc60
Author: Pino Toscano <pino at kde.org>
Date:   Thu Feb 21 01:23:07 2008 +0100

    Add a dock for showing the document metadata.

diff --git a/qt4/demos/CMakeLists.txt b/qt4/demos/CMakeLists.txt
index 2c7b370..4fe984f 100644
--- a/qt4/demos/CMakeLists.txt
+++ b/qt4/demos/CMakeLists.txt
@@ -15,6 +15,7 @@ set(poppler_qt4viewer_SRCS
   fonts.cpp
   info.cpp
   main_viewer.cpp
+  metadata.cpp
   navigationtoolbar.cpp
   pageview.cpp
   permissions.cpp
diff --git a/qt4/demos/Makefile.am b/qt4/demos/Makefile.am
index 0592dd7..b0cd838 100644
--- a/qt4/demos/Makefile.am
+++ b/qt4/demos/Makefile.am
@@ -32,6 +32,8 @@ poppler_qt4viewer_SOURCES =			\
 	info.cpp				\
 	info.h					\
 	main_viewer.cpp				\
+	metadata.cpp				\
+	metadata.h				\
 	navigationtoolbar.cpp			\
 	navigationtoolbar.h			\
 	pageview.cpp				\
@@ -47,6 +49,7 @@ abstractinfodock.$(OBJEXT): abstractinfodock.moc
 embeddedfiles.cpp.$(OBJEXT): embeddedfiles.moc
 fonts.$(OBJEXT): fonts.moc
 info.$(OBJEXT): info.moc
+metadata.$(OBJEXT): metadata.moc
 navigationtoolbar.$(OBJEXT): navigationtoolbar.moc
 pageview.$(OBJEXT): pageview.moc
 permissions.$(OBJEXT): permissions.moc
diff --git a/qt4/demos/metadata.cpp b/qt4/demos/metadata.cpp
new file mode 100644
index 0000000..e5c7111
--- /dev/null
+++ b/qt4/demos/metadata.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "metadata.h"
+
+#include <poppler-qt4.h>
+
+#include <QtGui/QTextEdit>
+
+MetadataDock::MetadataDock(QWidget *parent)
+    : AbstractInfoDock(parent)
+{
+    m_edit = new QTextEdit(this);
+    setWidget(m_edit);
+    setWindowTitle(tr("Metadata"));
+    m_edit->setAcceptRichText(false);
+    m_edit->setReadOnly(true);
+}
+
+MetadataDock::~MetadataDock()
+{
+}
+
+void MetadataDock::fillInfo()
+{
+    m_edit->setPlainText(document()->metadata());
+}
+
+void MetadataDock::documentClosed()
+{
+    m_edit->clear();
+    AbstractInfoDock::documentClosed();
+}
+
+#include "metadata.moc"
diff --git a/qt4/demos/metadata.h b/qt4/demos/metadata.h
new file mode 100644
index 0000000..6f1507a
--- /dev/null
+++ b/qt4/demos/metadata.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 METADATA_H
+#define METADATA_H
+
+#include "abstractinfodock.h"
+
+class QTextEdit;
+
+class MetadataDock : public AbstractInfoDock
+{
+    Q_OBJECT
+
+public:
+    MetadataDock(QWidget *parent = 0);
+    ~MetadataDock();
+
+    /*virtual*/ void documentClosed();
+
+protected:
+    /*virtual*/ void fillInfo();
+
+private:
+    QTextEdit *m_edit;
+};
+
+#endif
diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp
index b8c69c4..7d55e0d 100644
--- a/qt4/demos/viewer.cpp
+++ b/qt4/demos/viewer.cpp
@@ -21,6 +21,7 @@
 #include "embeddedfiles.h"
 #include "fonts.h"
 #include "info.h"
+#include "metadata.h"
 #include "navigationtoolbar.h"
 #include "pageview.h"
 #include "permissions.h"
@@ -120,6 +121,12 @@ PdfViewer::PdfViewer()
     viewMenu->addAction(embfilesDock->toggleViewAction());
     m_observers.append(embfilesDock);
 
+    MetadataDock *metadataDock = new MetadataDock(this);
+    addDockWidget(Qt::BottomDockWidgetArea, metadataDock);
+    metadataDock->hide();
+    viewMenu->addAction(metadataDock->toggleViewAction());
+    m_observers.append(metadataDock);
+
     Q_FOREACH(DocumentObserver *obs, m_observers) {
         obs->m_viewer = this;
     }


More information about the poppler mailing list