]> Git trees. - libqmvoc.git/commitdiff
fix the use of <picture>-tag
authorCarsten Niehaus <cniehaus@gmx.de>
Sun, 24 Jul 2005 12:06:03 +0000 (12:06 +0000)
committerCarsten Niehaus <cniehaus@gmx.de>
Sun, 24 Jul 2005 12:06:03 +0000 (12:06 +0000)
svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=438119

kdeeduui/kdeeduglossary.cpp
kdeeduui/kdeeduglossary.h

index 3a1da51071e69b56e8a5d3c5fcd06f2773efaf97..797902871a7880044aea3a4561254f73a67ac044 100644 (file)
@@ -70,11 +70,13 @@ bool Glossary::isEmpty() const
 }
 
 
-Glossary* Glossary::readFromXML( const KURL& url )
+Glossary* Glossary::readFromXML( const KURL& url, const QString& path )
 {
        QDomDocument doc( "document" );
 
        Glossary *glossary = new Glossary();
+       
+       glossary->setPicturePath( path );
 
        if ( glossary->loadLayout( doc, url ) )
        {
@@ -98,8 +100,8 @@ void Glossary::fixImagePath()
 
        for ( ; it != itEnd ; ++it )
        {
-               ( *it )->desc().replace("[img]", firstpart );
-               ( *it )->desc().replace("[/img]", "\" />" );
+               ( *it )->setDesc( ( *it )->desc().replace("[img]", firstpart ) );
+               ( *it )->setDesc( ( *it )->desc().replace("[/img]", "\" />" ) );
        }
 }
        
@@ -124,9 +126,11 @@ QValueList<GlossaryItem*> Glossary::readItems( QDomDocument &itemDocument )
                
                QDomNode nameNode = itemElement.namedItem( "name" );
                QDomNode descNode = itemElement.namedItem( "desc" );
+               QString picName = itemElement.namedItem( "picture" ).toElement().text();
                QDomElement refNode = ( const QDomElement& ) itemElement.namedItem( "references" ).toElement();
 
                QString desc = descNode.toElement().text();
+               desc.prepend("[img]"+picName +"[/img]" );
                desc.replace("[b]", "<b>" );
                desc.replace("[/b]", "</b>" );
                desc.replace("[i]", "<i>" );
@@ -151,9 +155,9 @@ QValueList<GlossaryItem*> Glossary::readItems( QDomDocument &itemDocument )
 
 
 GlossaryDialog::GlossaryDialog( bool folded, QWidget *parent, const char *name)
-    : KDialogBase( Plain, i18n( "Glossary" ), Close, Close, parent, name, false )
+    : KDialogBase( Plain, i18n( "Glossary" ), Close, NoDefault, parent, name, false )
 {
-       //this string will be used for all items. If a backgroundpicutures should
+       //this string will be used for all items. If a backgroundpicture should
        //be used call Glossary::setBackgroundPicture().
        m_htmlbasestring = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><html><body>" ;
 
@@ -236,8 +240,8 @@ void GlossaryDialog::updateTree()
 {
        m_glosstree->clear();
 
-       QValueList<Glossary*>::iterator itGl = m_glossaries.begin();
-       const QValueList<Glossary*>::iterator itGlEnd = m_glossaries.end();
+       QValueList<Glossary*>::const_iterator itGl = m_glossaries.begin();
+       const QValueList<Glossary*>::const_iterator itGlEnd = m_glossaries.end();
        
        for ( ; itGl != itGlEnd ; ++itGl )
        {
@@ -316,8 +320,8 @@ void GlossaryDialog::slotClicked( QListViewItem *item )
        while ( !found && itGl != itGlEnd )
        {
                QValueList<GlossaryItem*> items = ( *itGl )->itemlist();
-               QValueList<GlossaryItem*>::iterator it = items.begin();
-               const QValueList<GlossaryItem*>::iterator itEnd = items.end();
+               QValueList<GlossaryItem*>::const_iterator it = items.begin();
+               const QValueList<GlossaryItem*>::const_iterator itEnd = items.end();
                while ( !found && it != itEnd )
                {
                        if ( ( *it )->name() == item->text( 0 ) )
@@ -345,7 +349,6 @@ void GlossaryDialog::slotClicked( QListViewItem *item )
                m_htmlpart->begin();
                m_htmlpart->write( html );
 
-               kdDebug() << "the html " << html << endl;
                m_htmlpart->end();
                return;
        }
index 0eaf6324c1fd71ab92985441f9d207e610201b96..bd60958bf78b5db7085f504d04da4213e942f399 100644 (file)
@@ -89,11 +89,12 @@ class Glossary
                 * Read a glossary from an XML file.
                 *
                 * @param url The path of the file to load
+                * @param path The path of the pictures. Will be used as m_picturepath
                 *
                 * @return a pointer to the loaded glossary. Even in case of
                 *         error, this won't return 0 but an empty Glossary.
                 */
-               static Glossary* readFromXML( const KURL& url );
+               static Glossary* readFromXML( const KURL& url, const QString& path = 0 );
 
                /**
                 * Every glossaryitem can show pictures. [img src="foo.png]