/* 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( TQWidget *parent , const char * name ) : TQWidget( parent, name ) { TQBoxLayout *topLayout = new TQVBoxLayout( this ); m_bugDesc = new TDEHTMLPart( this, "m_bugDesc" ); connect( m_bugDesc->browserExtension(), TQT_SIGNAL( openURLRequest( const KURL &, const KParts::URLArgs & ) ), this, TQT_SLOT( handleOpenURLRequest( const KURL &, const KParts::URLArgs & ) ) ); topLayout->addWidget( m_bugDesc->view() ); } CWBugDetails::~CWBugDetails() { } void CWBugDetails::setBug( const Bug &bug, const BugDetails &details ) { TQColorGroup cg = m_bugDesc->view()->palette().active(); TQString text = "\n" "\n" "\n" ) .arg( cg.highlight().name() ) .arg( cg.highlightedText().name() ) ); text.append( "\n" ); TQString highlightStyle = TQString( "background: %1; color: %2; " ) .arg( cg.highlight().name() ) .arg( cg.highlightedText().name() ); TQString borderBottomStyle = TQString( "border-bottom: solid %1 1px; " ) .arg( cg.foreground().name() ); TQString borderTopStyle = TQString( "border-top: solid %1 1px; " ) .arg( cg.foreground().name() ); TQString 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( TQString( "
" "" ) .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( "
" ); TQString sender = (*it).sender.fullName( true ); TQString date = TDEGlobal::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() + TQString("#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" ); } TQValueList atts = details.attachmentDetails(); if ( atts.count() > 0 ) { text.append( "" ); text.append( TQString( "") .arg( i18n( "Attachment List") ) ); text.append( TQString("") .arg( i18n("Description") ) .arg( i18n("Date") ) .arg( i18n("View") ) .arg( i18n("Edit") ) ); TQValueList::iterator it; for ( it = atts.begin() ; it != atts.end() ; ++it ) { text.append( TQString("").arg( (*it).description ) ) ; text.append( TQString("").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 ); } TQString CWBugDetails::textBugDetailsAttribute( const TQString &value, const TQString &name ) { TQString text = ""; if ( !value.isEmpty() ) { text.append( "" "" ); } return text; } TQString CWBugDetails::source() const { return mSource; } TQString CWBugDetails::selectedText() const { return m_bugDesc->selectedText(); } #include "cwbugdetails.moc"
%1
%1 %2 %3 %4
%1%1server()->attachmentViewLink( (*it).id ).url() + "\">" + i18n("View") + "server()->attachmentEditLink( (*it).id ).url() + "\">" + i18n("Edit") + "
" + name + "" + value + "