/* cwbugdetails.cpp - Details of a bug report copyright : (c) 2001 by Martijn Klingens email : klingens@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 of the License, or * * (at your option) any later version. * * * ************************************************************************* */ #include #include #include #include #include "cwbugdetails.h" #include "kbbprefs.h" #include "bugsystem.h" #include "bugserver.h" #include #include #include #include #include #include #include using namespace KBugBusterMainWindow; CWBugDetails::CWBugDetails( QWidget *parent , const char * name ) : QWidget( parent, name ) { QBoxLayout *topLayout = new QVBoxLayout( this ); m_bugDesc = new KHTMLPart( this, "m_bugDesc" ); connect( m_bugDesc->browserExtension(), SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, SLOT( handleOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) ); topLayout->addWidget( m_bugDesc->view() ); } CWBugDetails::~CWBugDetails() { } void CWBugDetails::setBug( const Bug &bug, const BugDetails &details ) { QColorGroup cg = m_bugDesc->view()->palette().active(); QString text = "\n" "\n" "\n" ) .arg( cg.highlight().name() ) .arg( cg.highlightedText().name() ) ); text.append( "\n" ); QString highlightStyle = QString( "background: %1; color: %2; " ) .arg( cg.highlight().name() ) .arg( cg.highlightedText().name() ); QString borderBottomStyle = QString( "border-bottom: solid %1 1px; " ) .arg( cg.foreground().name() ); QString borderTopStyle = QString( "border-top: solid %1 1px; " ) .arg( cg.foreground().name() ); QString submitter = bug.submitter().fullName( true ); int age = details.age(); text.append( "
" ); text.append( "server()->bugLink( bug ).url() + "\">" + i18n("Bug Report from %1 " ) .arg( submitter ) ); int replies = details.parts().count() - 1; if ( replies >= 1 ) text += i18n( "(1 reply)", "(%n replies)", replies ); text += "
"; text += "
" + i18n( "1 day old", "%n days old", age ) + "
\n"; text.append( QString( "
" "" ) .arg( cg.background().name() ) .arg( cg.foreground().name() ) ); text.append( textBugDetailsAttribute( details.version(), i18n("Version") ) ); text.append( textBugDetailsAttribute( details.source(), i18n("Source") ) ); text.append( textBugDetailsAttribute( details.compiler(), i18n("Compiler") ) ); text.append( textBugDetailsAttribute( details.os(), i18n("OS") ) ); text.append( "
\n" ); BugDetailsPart::List bdp = details.parts(); BugDetailsPart::List::ConstIterator it; bool firstHeader = true; for ( it = bdp.begin(); it != bdp.end(); ++it ) { if ( bdp.count() > 1 ) { text.append( "
" ); QString sender = (*it).sender.fullName( true ); QString date = KGlobal::locale()->formatDateTime( (*it).date, false ); BugDetailsPart::List::ConstIterator it2 = it; if ( ++it2 == bdp.end() ) text.append( "server()->bugLink( bug ).url() + "\">" + i18n("Bug Report from %1") .arg( sender ) ); else { text.append( "server()->bugLink( bug ).url() + QString("#c%1").arg( replies ) + "\">" + i18n("Reply #%1 from %2") .arg( replies ).arg( sender ) ); replies--; } text.append( "
\n" ); text += "
" + date + "
\n"; firstHeader = false; } // Adding of
 tags is now done by BugDetailsJob::processNode. This
        // was breaking the display of attachments because they have 
\n // after each line -> two newlines with
        text.append( "
" ); text.append( (*it).text ); text.append( "
\n" ); } QValueList atts = details.attachmentDetails(); if ( atts.count() > 0 ) { text.append( "" ); text.append( QString( "") .arg( i18n( "Attachment List") ) ); text.append( QString("") .arg( i18n("Description") ) .arg( i18n("Date") ) .arg( i18n("View") ) .arg( i18n("Edit") ) ); QValueList::iterator it; for ( it = atts.begin() ; it != atts.end() ; ++it ) { text.append( QString("").arg( (*it).description ) ) ; text.append( QString("").arg( (*it).date ) ); text.append( "" ); text.append( "" ); text.append( "" ); } } text.append( "" ); //kdDebug() << "BEGIN OUTPUT" << text << "END OUTPUT" << endl; m_bugDesc->view()->setContentsPos(0,0); m_bugDesc->begin(); m_bugDesc->write( text ); m_bugDesc->end(); if ( KBBPrefs::instance()->mDebugMode ) mSource = text; } void CWBugDetails::handleOpenURLRequest( const KURL &url, const KParts::URLArgs & ) { new KRun( url ); } QString CWBugDetails::textBugDetailsAttribute( const QString &value, const QString &name ) { QString text = ""; if ( !value.isEmpty() ) { text.append( "" "" ); } return text; } QString CWBugDetails::source() const { return mSource; } QString CWBugDetails::selectedText() const { return m_bugDesc->selectedText(); } #include "cwbugdetails.moc" /* vim: set et ts=4 sw=4 softtabstop=4: */
%1
%1 %2 %3 %4
%1%1server()->attachmentViewLink( (*it).id ).url() + "\">" + i18n("View") + "server()->attachmentEditLink( (*it).id ).url() + "\">" + i18n("Edit") + "
" + name + "" + value + "