~ubuntu-branches/ubuntu/intrepid/poppler/intrepid-security

« back to all changes in this revision

Viewing changes to qt4/demos/info.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Loic Minier
  • Date: 2008-05-15 12:33:18 UTC
  • mfrom: (1.1.12 upstream)
  • Revision ID: james.westby@ubuntu.com-20080515123318-4ou7y7oa1wz54f3u
Tags: 0.8.2-2
* Upload to unstable.
* Set myself as Maintainer instead of Uploader, taking over from Ondřej Surý
  but I wish we move to an official team; closes: #481323.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2008, Pino Toscano <pino@kde.org>
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify
 
5
 * it under the terms of the GNU General Public License as published by
 
6
 * the Free Software Foundation; either version 2, or (at your option)
 
7
 * any later version.
 
8
 *
 
9
 * This program is distributed in the hope that it will be useful,
 
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 * GNU General Public License for more details.
 
13
 *
 
14
 * You should have received a copy of the GNU General Public License
 
15
 * along with this program; if not, write to the Free Software
 
16
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
 
17
 */
 
18
 
 
19
#include "info.h"
 
20
 
 
21
#include <poppler-qt4.h>
 
22
 
 
23
#include <QtGui/QTableWidget>
 
24
 
 
25
InfoDock::InfoDock(QWidget *parent)
 
26
    : AbstractInfoDock(parent)
 
27
{
 
28
    m_table = new QTableWidget(this);
 
29
    setWidget(m_table);
 
30
    setWindowTitle(tr("Information"));
 
31
    m_table->setColumnCount(2);
 
32
    m_table->setHorizontalHeaderLabels(QStringList() << tr("Key") << tr("Value"));
 
33
#if QT_VERSION >= 0x040200
 
34
    m_table->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel);
 
35
#endif
 
36
}
 
37
 
 
38
InfoDock::~InfoDock()
 
39
{
 
40
}
 
41
 
 
42
void InfoDock::fillInfo()
 
43
{
 
44
    QStringList keys = document()->infoKeys();
 
45
    m_table->setHorizontalHeaderLabels(QStringList() << tr("Key") << tr("Value"));
 
46
    m_table->setRowCount(keys.count());
 
47
    QStringList dateKeys;
 
48
    dateKeys << QString::fromLatin1("CreationDate");
 
49
    dateKeys << QString::fromLatin1("ModDate");
 
50
    int i = 0;
 
51
    Q_FOREACH(const QString &date, dateKeys) {
 
52
        const int id = keys.indexOf(date);
 
53
        if (id != -1) {
 
54
            m_table->setItem(i, 0, new QTableWidgetItem(date));
 
55
            m_table->setItem(i, 1, new QTableWidgetItem(document()->date(date).toString(Qt::SystemLocaleDate)));
 
56
            ++i;
 
57
            keys.removeAt(id);
 
58
        }
 
59
    }
 
60
    Q_FOREACH(const QString &key, keys) {
 
61
        m_table->setItem(i, 0, new QTableWidgetItem(key));
 
62
        m_table->setItem(i, 1, new QTableWidgetItem(document()->info(key)));
 
63
        ++i;
 
64
    }
 
65
}
 
66
 
 
67
void InfoDock::documentClosed()
 
68
{
 
69
    m_table->clear();
 
70
    m_table->setRowCount(0);
 
71
    AbstractInfoDock::documentClosed();
 
72
}
 
73
 
 
74
#include "info.moc"