[rkward-cvs] rkward/rkward/misc rkcommonfunctions.cpp,NONE,1.1 rkcommonfunctions.h,NONE,1.1 Makefile.am,1.9,1.10
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Mon Oct 17 18:53:37 UTC 2005
Update of /cvsroot/rkward/rkward/rkward/misc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23212/rkward/misc
Modified Files:
Makefile.am
Added Files:
rkcommonfunctions.cpp rkcommonfunctions.h
Log Message:
Remove menu/toolbar clutter from RKHelpWindow, RKOutputWindow
--- NEW FILE: rkcommonfunctions.cpp ---
/***************************************************************************
rkcommonfunctions - description
-------------------
begin : Mon Oct 17 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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 "rkcommonfunctions.h"
#include <qstringlist.h>
#include <qdom.h>
#include <kxmlguiclient.h>
namespace RKCommonFunctions {
void removeNamedElementsRecursive (const QStringList &names, QDomNode &parent) {
QDomNode nchild;
for (QDomNode child = parent.firstChild (); !child.isNull (); child = nchild) {
removeNamedElementsRecursive (names, child);
nchild = child.nextSibling (); // need to fetch next sibling here, as we might remove the child below
if (child.isElement ()) {
QDomElement e = child.toElement ();
if (names.contains (e.attribute ("name"))) {
parent.removeChild (child);
}
}
}
}
void removeContainers (KXMLGUIClient *from, const QStringList &names, bool recursive) {
QDomDocument doc = from->xmlguiBuildDocument ();
if (doc.documentElement ().isNull ()) doc = from->domDocument ();
QDomElement e = doc.documentElement ();
removeNamedElementsRecursive (names, e);
from->setXMLGUIBuildDocument (doc);
if (recursive) {
QPtrList <KXMLGUIClient> *children = const_cast<QPtrList <KXMLGUIClient> *> (from->childClients ());
if (children) {
for (KXMLGUIClient *child = children->first (); child; child = children->next ()) {
removeContainers (child, names, true);
}
}
}
}
} // namespace
Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/misc/Makefile.am,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Makefile.am 25 Sep 2005 18:45:44 -0000 1.9
--- Makefile.am 17 Oct 2005 18:53:35 -0000 1.10
***************
*** 3,10 ****
noinst_LIBRARIES = libmisc.a
libmisc_a_SOURCES = rkerrordialog.cpp rkmenu.cpp rkspinbox.cpp \
! getfilenamewidget.cpp rkmenulist.cpp rkobjectlistview.cpp \
! rkcanceldialog.cpp xmlhelper.cpp multistringselector.cpp
! noinst_HEADERS = rkerrordialog.h rkmenu.h rkspinbox.h \
! getfilenamewidget.h rkmenulist.h rkobjectlistview.h rkcanceldialog.h xmlhelper.h \
! multistringselector.h
--- 3,10 ----
noinst_LIBRARIES = libmisc.a
libmisc_a_SOURCES = rkerrordialog.cpp rkmenu.cpp rkspinbox.cpp \
! getfilenamewidget.cpp rkmenulist.cpp rkobjectlistview.cpp rkcanceldialog.cpp xmlhelper.cpp \
! multistringselector.cpp rkcommonfunctions.cpp
! noinst_HEADERS = rkerrordialog.h rkmenu.h rkspinbox.h getfilenamewidget.h \
! rkmenulist.h rkobjectlistview.h rkcanceldialog.h xmlhelper.h multistringselector.h \
! rkcommonfunctions.h
--- NEW FILE: rkcommonfunctions.h ---
/***************************************************************************
rkcommonfunctions - description
-------------------
begin : Mon Oct 17 2005
copyright : (C) 2005 by Thomas Friedrichsmeier
email : tfry at users.sourceforge.net
***************************************************************************/
/***************************************************************************
* *
* 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. *
* *
***************************************************************************/
#ifndef RKCOMMONFUNCTIONS_H
#define RKCOMMONFUNCTIONS_H
class QStringList;
class QDomNode;
class KXMLGUIClient;
/** Some common static helper functions that don't really belong to any class in particular. If ever we have more than a dozen or so functions in here,
we should probably split this file up. Until then, there's no real need.
@author Thomas Friedrichsmeier
*/
namespace RKCommonFunctions {
/** remove QDomElements with attribute 'name="..."' from QDomNode parent, where "..." is any of the strings in names */
void removeNamedElementsRecursive (const QStringList &names, QDomNode &parent);
/** remove containers (actions, menus, etc.) with attribute 'name="..."' from KXMLGUIClient from s XML gui, where "..." is any of the strings in names. If recursive, also removes those containers from child clients. */
void removeContainers (KXMLGUIClient *from, const QStringList &names, bool recursive);
};
#endif
More information about the rkward-tracker
mailing list