2 * HTMLIndexReportElement.cpp - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
17 #include "HTMLIndexReportElement.h"
18 #include "TableLineInfo.h"
19 #include "tjlib-internal.h"
23 HTMLIndexReportElement::HTMLIndexReportElement(Report* r,
26 HTMLReportElement(r, df, dl)
28 columns.append(new TableColumnInfo(0, "Report"));
29 columns.append(new TableColumnInfo(0, "Comment"));
33 HTMLIndexReportElement::generateReportLine(Report* report, int level)
35 // Deduce report file name relatively to index directory.
36 QString absSourceFilePath = QFileInfo(defFileName).dir(true).canonicalPath();
37 QString absReportFilePath = QFileInfo(report->getFullFileName()).dir(true).canonicalPath();
38 QString reportRelPath = "";
39 for (QString sourceFilePath = defFileName; // .left(defFileName.findRev(QDir().separator())-1);
40 sourceFilePath.find('/') >= 0;
41 sourceFilePath = sourceFilePath.left(sourceFilePath.findRev(QDir().separator())))
43 if (strncmp(sourceFilePath, absReportFilePath, sourceFilePath.length()) == 0)
45 reportRelPath += absReportFilePath.right(absReportFilePath.length() - sourceFilePath.length() - 1);
50 reportRelPath = reportRelPath + ".." + QDir().separator();
54 QString reportRelFile = reportRelPath + QDir().separator() + QFileInfo(report->getFullFileName()).fileName();
55 // Make thumbnail directory in case it does not exists yet
58 QFile reportQFile (report->getFullFileName() );
59 s() << "<TR style=\"background-color:" << colors.getColorName("default") << "; \" ><TD>";
60 s() << "</TD><TD><A HREF='" << reportRelFile << "'>";
61 for (int i = 0 ; i < level; i++)
64 s() << "<strong>" << (report->getHeadline() == "" ? QFileInfo(report->getFullFileName()).fileName() : report->getHeadline()) << "</strong>";
65 for (int i = 0 ; i < level; i++)
70 s() << "<TD><i> ( " << report->getType() << " ) </i></TD>";
71 ElementHolder *elementHolder = dynamic_cast<ElementHolder*>(this);
72 if (elementHolder && elementHolder->getTable()->getCaption() != "")
73 s() << ": " << elementHolder->getTable()->getCaption();
74 else if (report->getCaption() != "")
75 s() << ": " << report->getCaption();
78 for (QPtrListIterator<Report> ri(report->getChildrenReportListIterator()); *ri; ++ri)
81 generateReportLine(*ri, level + 1);
88 HTMLIndexReportElement::generate()
90 QString previousReportType;
94 s() << "<table align=\"center\" cellpadding=\"2\" "
95 << "style=\"background-color:" << colors.getColorName("default") << "\"";
97 s() << " <thead>" << endl
98 << " <tr valign=\"middle\""
99 << " style=\"background-color:" << colors.getColorName("header") << "; "
100 << "font-size:110%; font-weight:bold; text-align:center\"";
102 s() << " </tr>" << endl;
104 for (QPtrListIterator<Report> ri(report->getProject()->getReportListIterator()); *ri != 0; ++ri)
106 // We generate all but Qt*Reports. Those are for the GUI version.
107 if (strncmp((*ri)->getType(), "Qt", 2) != 0
108 && (*ri)->getParentReport() == 0
109 && (*ri) != this->getReport())
111 generateReportLine(*ri);
114 s() << " </thead>\n" << endl;
115 s() << "</table>" << endl;