From e9ae80694875f869892f13f4fcaf1170a00dea41 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- quanta/dialogs/tagdialogs/tagattr.cpp | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 quanta/dialogs/tagdialogs/tagattr.cpp (limited to 'quanta/dialogs/tagdialogs/tagattr.cpp') diff --git a/quanta/dialogs/tagdialogs/tagattr.cpp b/quanta/dialogs/tagdialogs/tagattr.cpp new file mode 100644 index 00000000..772da4fb --- /dev/null +++ b/quanta/dialogs/tagdialogs/tagattr.cpp @@ -0,0 +1,97 @@ +/*************************************************************************** + tagxml.cpp - description + ------------------- + begin : ����25 14:34:07 EEST 2000 + copyright : (C) 2000 by Dmitry Poplavsky & Alexander Yakovlev + (C) 2004 Andras Mantia + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + + +//kde includes +#include +#include +#include +#include + +//qt includes +#include +#include + +//app includes +#include "tagattr.h" +#include "node.h" +#include "colorcombo.h" +#include "qtag.h" +#include "quantacommon.h" + +QString Attr::attrName() const +{ + return name; +} + + +Attr_list::Attr_list( QDomElement const& el, QWidget *w, QTag *dtdTag ) + : Attr(el, w, dtdTag) +{ + combo = (QComboBox *)w; + + QString source = el.attribute("source"); + if (source == "dcop") //fill the list with a result of a DCOP call + { + QString method = el.attribute("method"); + QString interface = el.attribute("interface", "QuantaIf"); + QString arguments = el.attribute("arguments"); + arguments.replace("%tagname%", m_dtdTag->name()); + DCOPReply reply = QuantaCommon::callDCOPMethod(interface, method, arguments); + if (reply.isValid()) + { + QStringList list = reply; + combo->insertStringList(list); + } + } + + for ( QDomElement n = el.firstChild().toElement(); !n.isNull(); n = n.nextSibling().toElement() ) { + if ( n.tagName() == "items" ) { + QDomElement item = n.firstChild().toElement(); + while ( !item.isNull() ) { + combo->insertItem( item.text() ); + item = item.nextSibling().toElement(); + } + } + } + + setValue(""); +} + +void Attr_list::setValue(const QString &value) +{ + + for ( int i=0; icount(); i++ ) + if ( value == combo->text(i) ) { + combo->setCurrentItem(i); + return; + } + + combo->insertItem(value); + combo->setCurrentItem( combo->count() - 1 ); + +} + + +QDomNode findChild( QDomNode &parent, const QString &name ) +{ + for ( QDomNode n = parent.firstChild(); !n.isNull(); n = n.nextSibling() ) + if ( n.nodeName() == name ) + return n; + return QDomNode(); +} + -- cgit v1.2.1