File: TjHTMLReport.cpp

package info (click to toggle)
taskjuggler 2.4.3-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 13,156 kB
  • ctags: 3,713
  • sloc: cpp: 37,683; sh: 13,617; xml: 6,021; perl: 5,207; lisp: 538; makefile: 283; python: 258
file content (90 lines) | stat: -rw-r--r-- 2,098 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*
 * The TaskJuggler Project Management Software
 *
 * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger <cs@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2 of the GNU General Public License as
 * published by the Free Software Foundation.
 *
 * $Id$
 */

#include "TjHTMLReport.h"

#include <qlayout.h>

#include <klocale.h>
#include <khtml_part.h>
#include <khtmlview.h>
#include <krun.h>

#include <HTMLReport.h>

TjHTMLReport::TjHTMLReport(QWidget* p, ReportManager* m, Report* rDef,
                                 const QString& n) :
    TjUIReportBase(p, m, rDef, n)
{
    QVBoxLayout* hl = new QVBoxLayout(this, 0);
    hl->setAutoAdd(true);
    browser = new KHTMLPart(this);

    /* It is very unlikely that we need these advanced KHTML features, so
     * let's disable them for security reasons. */
    browser->setJScriptEnabled(false);
    browser->setJavaEnabled(false);
    browser->setMetaRefreshEnabled(false);
    browser->setPluginsEnabled(false);
    browser->setOnlyLocalReferences(true);

    connect(browser->browserExtension(),
            SIGNAL(openURLRequest(const KURL &, const KParts::URLArgs&)),
            this, SLOT(openURLRequest(const KURL &, const KParts::URLArgs&)));
    connect(browser, SIGNAL(onURL(const QString&)),
            this, SLOT(showURLinStatusBar(const QString&)));
}

bool
TjHTMLReport::generateReport()
{
    HTMLReport* htmlReport = dynamic_cast<HTMLReport*>(report);
    if (!htmlReport->generate())
        return false;
    KURL reportURL = KURL::fromPathOrURL(report->getFullFileName());
    browser->openURL(reportURL);

    return true;
}

void
TjHTMLReport::print()
{
    browser->view()->print();
}

void
TjHTMLReport::show()
{
    QWidget::show();
}

void
TjHTMLReport::hide()
{
    QWidget::hide();
}

void
TjHTMLReport::showURLinStatusBar(const QString& url)
{
    emit signalChangeStatusBar(url);
}

void
TjHTMLReport::openURLRequest(const KURL &url, const KParts::URLArgs&)
{
    KRun::runURL(url, "text/html");
}

#include "TjHTMLReport.moc"