20 #include "ippreportdlg.h"
21 #include "ipprequest.h"
24 #include <tdelocale.h>
26 #include <tdemessagebox.h>
28 #include <ktextedit.h>
29 #include <tqsimplerichtext.h>
30 #include <tqpainter.h>
31 #include <tqpaintdevicemetrics.h>
33 IppReportDlg::IppReportDlg(TQWidget *parent,
const char *name)
34 : KDialogBase(parent, name, true, i18n(
"IPP Report"), Close|User1, Close, false, KGuiItem(i18n(
"&Print"),
"document-print"))
36 m_edit =
new KTextEdit(
this);
37 m_edit->setReadOnly(
true);
38 setMainWidget(m_edit);
40 setFocusProxy(m_edit);
41 setButtonGuiItem(User1, KGuiItem(i18n(
"&Print"),
"document-print"));
44 void IppReportDlg::slotUser1()
49 if (printer.
setup(
this))
51 TQPainter painter(&printer);
52 TQPaintDeviceMetrics metrics(&printer);
55 TQSimpleRichText rich(m_edit->text(), font());
56 rich.setWidth(&painter, metrics.width());
57 int margin = (int)(1.5 / 2.54 * metrics.logicalDpiY());
58 TQRect r(margin, margin, metrics.width()-2*margin, metrics.height()-2*margin);
59 int hh = rich.height(), page(1);
62 rich.draw(&painter, margin, margin, r, colorGroup());
63 TQString s = caption() +
": " + TQString::number(page);
64 TQRect br = painter.fontMetrics().boundingRect(s);
65 painter.drawText(r.right()-br.width()-5, r.top()-br.height()-4, br.width()+5, br.height()+4, TQt::AlignRight|TQt::AlignTop, s);
66 r.moveBy(0, r.height()-10);
67 painter.translate(0, -(r.height()-10));
79 void IppReportDlg::report(IppRequest *req,
int group,
const TQString& caption)
82 TQTextStream t(&str_report, IO_WriteOnly);
84 if (req->htmlReport(group, t))
87 if (!caption.isEmpty())
88 dlg.setCaption(caption);
89 dlg.m_edit->setText(str_report);
93 KMessageBox::error(0, i18n(
"Internal error: unable to generate HTML report."));
96 #include "ippreportdlg.moc"
This class is the main interface to access the TDE print framework.
bool newPage()
See TQPrinter::newPage().
bool setup(TQWidget *parent=0, const TQString &caption=TQString::null, bool forceExpand=false)
Sets up the KPrinter object using the print dialog, returns true if the user clicked OK.
void setFullPage(bool)
See TQPrinter::setFullPage().
void setDocName(const TQString &)
See TQPrinter::setDocName().