diff options
author | Pino Toscano <pino@kde.org> | 2008-02-21 00:33:23 +0100 |
---|---|---|
committer | Pino Toscano <pino@kde.org> | 2008-02-21 00:33:23 +0100 |
commit | db2b0778dca364751a1d22294be29f8c7799e2e9 (patch) | |
tree | 67601bb4f569b146cdca9d02c0752b2dbe5aca59 /qt4/demos | |
parent | 51fba47ccb12a66282769fc504bac4c9f5123f75 (diff) |
Add a dock for showing the embedded files.
TODO: show the checksum in a pretty format.
Diffstat (limited to 'qt4/demos')
-rw-r--r-- | qt4/demos/CMakeLists.txt | 1 | ||||
-rw-r--r-- | qt4/demos/Makefile.am | 3 | ||||
-rw-r--r-- | qt4/demos/embeddedfiles.cpp | 75 | ||||
-rw-r--r-- | qt4/demos/embeddedfiles.h | 43 | ||||
-rw-r--r-- | qt4/demos/viewer.cpp | 7 |
5 files changed, 129 insertions, 0 deletions
diff --git a/qt4/demos/CMakeLists.txt b/qt4/demos/CMakeLists.txt index 07ffb52b..2c7b3709 100644 --- a/qt4/demos/CMakeLists.txt +++ b/qt4/demos/CMakeLists.txt @@ -11,6 +11,7 @@ include_directories( set(poppler_qt4viewer_SRCS abstractinfodock.cpp documentobserver.cpp + embeddedfiles.cpp fonts.cpp info.cpp main_viewer.cpp diff --git a/qt4/demos/Makefile.am b/qt4/demos/Makefile.am index c4929860..0592dd76 100644 --- a/qt4/demos/Makefile.am +++ b/qt4/demos/Makefile.am @@ -25,6 +25,8 @@ poppler_qt4viewer_SOURCES = \ abstractinfodock.h \ documentobserver.cpp \ documentobserver.h \ + embeddedfiles.cpp \ + embeddedfiles.h \ fonts.cpp \ fonts.h \ info.cpp \ @@ -42,6 +44,7 @@ poppler_qt4viewer_SOURCES = \ viewer.h abstractinfodock.$(OBJEXT): abstractinfodock.moc +embeddedfiles.cpp.$(OBJEXT): embeddedfiles.moc fonts.$(OBJEXT): fonts.moc info.$(OBJEXT): info.moc navigationtoolbar.$(OBJEXT): navigationtoolbar.moc diff --git a/qt4/demos/embeddedfiles.cpp b/qt4/demos/embeddedfiles.cpp new file mode 100644 index 00000000..a91d8dd0 --- /dev/null +++ b/qt4/demos/embeddedfiles.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2008, Pino Toscano <pino@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 "embeddedfiles.h" + +#include <poppler-qt4.h> + +#include <QtGui/QTableWidget> + +EmbeddedFilesDock::EmbeddedFilesDock(QWidget *parent) + : AbstractInfoDock(parent) +{ + m_table = new QTableWidget(this); + setWidget(m_table); + setWindowTitle(tr("Embedded files")); + m_table->setColumnCount(6); + m_table->setHorizontalHeaderLabels( + QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date") + << tr("Modification date") << tr("Checksum")); +#if QT_VERSION >= 0x040200 + m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); +#endif +} + +EmbeddedFilesDock::~EmbeddedFilesDock() +{ +} + +void EmbeddedFilesDock::fillInfo() +{ + m_table->setHorizontalHeaderLabels( + QStringList() << tr("Name") << tr("Description") << tr("Size") << tr("Creation date") + << tr("Modification date") << tr("Checksum")); + if (!document()->hasEmbeddedFiles()) { + m_table->setItem(0, 0, new QTableWidgetItem(tr("No files"))); + return; + } + + const QList<Poppler::EmbeddedFile*> files = document()->embeddedFiles(); + m_table->setRowCount(files.count()); + int i = 0; + Q_FOREACH(Poppler::EmbeddedFile *file, files) { + m_table->setItem(i, 0, new QTableWidgetItem(file->name())); + m_table->setItem(i, 1, new QTableWidgetItem(file->description())); + m_table->setItem(i, 2, new QTableWidgetItem(QString::number(file->size()))); + m_table->setItem(i, 3, new QTableWidgetItem(file->createDate().toString(Qt::SystemLocaleDate))); + m_table->setItem(i, 4, new QTableWidgetItem(file->modDate().toString(Qt::SystemLocaleDate))); + m_table->setItem(i, 5, new QTableWidgetItem("n/a")); // ### FIXME pretty display of the HEX checksum + ++i; + } +} + +void EmbeddedFilesDock::documentClosed() +{ + m_table->clear(); + m_table->setRowCount(0); + AbstractInfoDock::documentClosed(); +} + +#include "embeddedfiles.moc" diff --git a/qt4/demos/embeddedfiles.h b/qt4/demos/embeddedfiles.h new file mode 100644 index 00000000..b1b0d00c --- /dev/null +++ b/qt4/demos/embeddedfiles.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2008, Pino Toscano <pino@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 ATTACHMENTS_H +#define ATTACHMENTS_H + +#include "abstractinfodock.h" + +class QTableWidget; + +class EmbeddedFilesDock : public AbstractInfoDock +{ + Q_OBJECT + +public: + EmbeddedFilesDock(QWidget *parent = 0); + ~EmbeddedFilesDock(); + + /*virtual*/ void documentClosed(); + +protected: + /*virtual*/ void fillInfo(); + +private: + QTableWidget *m_table; +}; + +#endif diff --git a/qt4/demos/viewer.cpp b/qt4/demos/viewer.cpp index ea673ae0..78e639fd 100644 --- a/qt4/demos/viewer.cpp +++ b/qt4/demos/viewer.cpp @@ -18,6 +18,7 @@ #include "viewer.h" +#include "embeddedfiles.h" #include "fonts.h" #include "info.h" #include "navigationtoolbar.h" @@ -99,6 +100,12 @@ PdfViewer::PdfViewer() viewMenu->addAction(permissionsDock->toggleViewAction()); m_observers.append(permissionsDock); + EmbeddedFilesDock *embfilesDock = new EmbeddedFilesDock(this); + addDockWidget(Qt::BottomDockWidgetArea, embfilesDock); + embfilesDock->hide(); + viewMenu->addAction(embfilesDock->toggleViewAction()); + m_observers.append(embfilesDock); + Q_FOREACH(DocumentObserver *obs, m_observers) { obs->m_viewer = this; } |