]> Git trees. - libqmvoc.git/commitdiff
* small improvements
authorPino Toscano <pino@kde.org>
Mon, 12 Sep 2005 14:30:04 +0000 (14:30 +0000)
committerPino Toscano <pino@kde.org>
Mon, 12 Sep 2005 14:30:04 +0000 (14:30 +0000)
* purged the unuseful closed() signal of the dialog

svn path=/trunk/KDE/kdeedu/libkdeedu/; revision=459961

kdeeduui/kdeeduglossary.cpp
kdeeduui/kdeeduglossary.h

index 89cc3e749788a66eb48c595c166cac0084265671..40a3c466390a440b281ef08daf7a8546794ea595 100644 (file)
@@ -51,44 +51,45 @@ void Glossary::init( const KURL& url, const QString& path )
        // setting a generic name for a new glossary
        m_name = i18n( "Glossary" );
 
-       if ( url.isEmpty() )
-               return;
-
-       QDomDocument doc( "document" );
-
        setPicturePath( path );
 
-       if ( loadLayout( doc, url ) )
+       if ( !url.isEmpty() )
        {
-               setItemlist( readItems( doc ) );
-               if ( !m_picturepath.isEmpty() )
-                       fixImagePath();
+
+               QDomDocument doc( "document" );
+
+               if ( loadLayout( doc, url ) )
+               {
+                       setItemlist( readItems( doc ) );
+                       if ( !m_picturepath.isEmpty() )
+                               fixImagePath();
+               }
        }
 }
 
 bool Glossary::loadLayout( QDomDocument &Document, const KURL& url )
 {
-        QFile layoutFile( url.path() );
+       QFile layoutFile( url.path() );
 
-        if (!layoutFile.exists())
+       if ( !layoutFile.exists() )
        {
                kdDebug() << "no such file: " << layoutFile.name() << endl;
                return false;
        }
 
-        if (!layoutFile.open(QIODevice::ReadOnly))
-                return false;
+       if ( !layoutFile.open( QIODevice::ReadOnly ) )
+               return false;
 
-        // check if document is well-formed
-        if (!Document.setContent(&layoutFile))
-        {
-                kdDebug() << "wrong xml" << endl;
-                layoutFile.close();
-                return false;
-        }
-        layoutFile.close();
+       // check if document is well-formed
+       if ( !Document.setContent( &layoutFile ) )
+       {
+               kdDebug() << "wrong xml of " << layoutFile.name() << endl;
+               layoutFile.close();
+               return false;
+       }
+       layoutFile.close();
 
-        return true;
+       return true;
 }
 
 bool Glossary::isEmpty() const
@@ -161,23 +162,22 @@ QList<GlossaryItem*> Glossary::readItems( QDomDocument &itemDocument )
                QString picName = itemElement.namedItem( "picture" ).toElement().text();
                QDomElement refNode = ( const QDomElement& ) itemElement.namedItem( "references" ).toElement();
 
-               QString desc = descNode.toElement().text();
+               QString desc = descNode.toElement().text().utf8();
                if ( !picName.isEmpty() )
                        desc.prepend("[img]"+picName +"[/img]" );
 
                item->setName( i18n( nameNode.toElement( ).text().utf8() ) );
                
-               item->setDesc( desc.replace("[b]", "<b>" ) );
-               item->setDesc( item->desc().replace("[/b]", "</b>" ) );
-               item->setDesc( item->desc().replace("[i]", "<i>" ) );
-               item->setDesc( item->desc().replace("[/i]", "</i>" ) );
-               item->setDesc( item->desc().replace("[sub]", "<sub>" ) );
-               item->setDesc( item->desc().replace("[/sub]", "</sub>" ) );
-               item->setDesc( item->desc().replace("[sup]", "<sup>" ) );
-               item->setDesc( item->desc().replace("[/sup]", "</sup>" ) );
-               item->setDesc( item->desc().replace("[br]", "<br />" ) );
-               
-               item->setDesc( i18n( item->desc().utf8() ) );
+               desc = desc.replace("[b]", "<b>" );
+               desc = desc.replace("[/b]", "</b>" );
+               desc = desc.replace("[i]", "<i>" );
+               desc = desc.replace("[/i]", "</i>" );
+               desc = desc.replace("[sub]", "<sub>" );
+               desc = desc.replace("[/sub]", "</sub>" );
+               desc = desc.replace("[sup]", "<sup>" );
+               desc = desc.replace("[/sup]", "</sup>" );
+               desc = desc.replace("[br]", "<br />" );
+               item->setDesc( desc );
 
                refNodeList = refNode.elementsByTagName( "refitem" );
                for ( int it = 0; it < refNodeList.count(); it++ )
@@ -394,12 +394,6 @@ void GlossaryDialog::slotClicked( Q3ListViewItem *item )
        }
 }
 
-void GlossaryDialog::slotClose()
-{
-       emit closed();
-       accept();
-}
-
 QString GlossaryItem::toHtml() const
 {
        QString code = "<h1>" + m_name + "</h1>" + m_desc;
index 8b2dd284523753df712a1b3dd1d4e376cbaf44e8..80606fa497c798876feb93e995183722129a3634 100644 (file)
@@ -253,8 +253,6 @@ class GlossaryDialog : public KDialogBase
                GlossaryDialog( bool folded = true, QWidget *parent=0, const char *name=0);
                ~GlossaryDialog();
 
-               void keyPressEvent(QKeyEvent*);
-
                /**
                 * Add a new glossary.
                 *
@@ -262,6 +260,9 @@ class GlossaryDialog : public KDialogBase
                 */
                void addGlossary( Glossary* newgloss );
 
+       protected:
+               void keyPressEvent(QKeyEvent*);
+
        private:
                QList<Glossary*> m_glossaries;
 
@@ -285,15 +286,9 @@ class GlossaryDialog : public KDialogBase
        private slots:
                void slotClicked( Q3ListViewItem * );
                /**
-                * The user clicked on a href. Emit the corresponding item
+                * The user clicked on a href. Find and display the right item
                 */
                void displayItem( const KURL& url, const KParts::URLArgs& args );
-
-       protected slots:
-               virtual void slotClose();
-       
-       signals:
-               void closed();
 };
 
 #endif // KDEEDUGLOSSARY_H