LinkItem::LinkItem( DOM::Element link ) : m_valid( false ) { DOM::NamedNodeMap attrs = link.attributes(); DOM::Node href = attrs.getNamedItem( "href" ); // Load source address of images too DOM::Node src = attrs.getNamedItem( "src" ); if ( href.nodeValue().string().isEmpty() && !src.nodeValue().string().isEmpty() ) href = src; // qDebug("*** href: %s", href.nodeValue().string().latin1() ); QString urlString = link.ownerDocument().completeURL( href.nodeValue() ).string(); if ( urlString.isEmpty() ) return; url = KUrl( urlString ); if ( !KProtocolManager::supportsReading( url ) ) return; // somehow getElementsByTagName("#text") doesn't work :( DOM::NodeList children = link.childNodes(); for ( uint i = 0; i < children.length(); i++ ) { DOM::Node node = children.item( i ); if ( node.nodeType() == DOM::Node::TEXT_NODE ) text.append( node.nodeValue().string() ); } // force "local file" mimetype determination KMimeType::Ptr mt = KMimeType::findByUrl( url, 0, true, true); icon = mt->iconName(); mimeType = mt->comment(); m_valid = true; }