[Kst] branches/work/kst/1.5/kst/src/libkstapp
George Staikos
staikos at kde.org
Thu Apr 12 20:09:59 CEST 2007
Please revert. This causes a major performance regression.
On 12-Apr-07, at 2:08 PM, Andrew Walker wrote:
> SVN commit 653146 by arwalker:
>
> BUG:141715 Make the hierarchical view scalars dialog useful
>
> M +86 -8 kstscalarlistview.cpp
> M +8 -0 kstscalarlistview.h
>
>
> --- branches/work/kst/1.5/kst/src/libkstapp/kstscalarlistview.cpp
> #653145:653146
> @@ -41,6 +41,7 @@
> setRenameEnabled(1, false);
> }
> }
> + _remove = false;
> }
>
> QString KstScalarListViewItem::text(int column) const {
> @@ -78,6 +79,14 @@
> }
> }
>
> +bool KstScalarListViewItem::remove() const {
> + return _remove;
> +}
> +
> +void KstScalarListViewItem::setRemove(bool remove) {
> + _remove = remove;
> +}
> +
> /
> *---------------------------------------------------------------------
> -------*/
>
> KstScalarListView::KstScalarListView(QWidget *parent,
> KstObjectCollection<KstScalar> *coll) : KListView(parent), _coll
> (coll) {
> @@ -90,29 +99,98 @@
> update();
> }
>
> -
> -static void addChildItems(KstScalarListViewItem *parentItem,
> KstObjectTreeNode<KstScalar> *parentNode) {
> +void KstScalarListView::addChildItems(KstScalarListViewItem
> *parentItem, KstObjectTreeNode<KstScalar> *parentNode) {
> if (!parentItem || !parentNode) {
> return;
> }
>
> QValueList<KstObjectTreeNode<KstScalar>*> children = parentNode-
> >children().values();
> for (QValueList<KstObjectTreeNode<KstScalar>*>::ConstIterator i
> = children.begin(); i != children.end(); ++i) {
> - KstScalarListViewItem *item = new KstScalarListViewItem
> (parentItem, *i);
> - addChildItems(item, *i);
> + QListViewItem *item = parentItem->firstChild();
> + bool found = false;
> +
> + while (item) {
> + if (item->text(0) == (*i)->nodeTag()) {
> + found = true;
> +
> + KstScalarListViewItem *kItem =
> dynamic_cast<KstScalarListViewItem*>(item);
> + if (kItem) {
> + kItem->setRemove(false);
> + repaintItem(kItem);
> + addChildItems(kItem, *i);
> + }
> +
> + break;
> + }
> + item = item->nextSibling();
> + }
> +
> + if (!found) {
> + KstScalarListViewItem *item = new KstScalarListViewItem
> (parentItem, *i);
> + addChildItems(item, *i);
> + }
> }
> }
>
> void KstScalarListView::update() {
> - clear();
> -
> if (_coll) {
> KstReadLocker(&_coll->lock());
> +
> + {
> + QListViewItemIterator it(this);
> +
> + while (it.current()) {
> + KstScalarListViewItem *kItem =
> dynamic_cast<KstScalarListViewItem*>(it.current());
> + if (kItem) {
> + kItem->setRemove(true);
> + }
> + ++it;
> + }
> + }
> +
> QValueList<KstObjectTreeNode<KstScalar>*> rootItems = _coll-
> >nameTreeRoot()->children().values();
> for (QValueList<KstObjectTreeNode<KstScalar>*>::ConstIterator
> i = rootItems.begin(); i != rootItems.end(); ++i) {
> - KstScalarListViewItem *item = new KstScalarListViewItem
> (this, *i);
> - addChildItems(item, *i);
> + QListViewItem *item = firstChild();
> + bool found = false;
> +
> + while (item) {
> + if (item->text(0) == (*i)->nodeTag()) {
> + found = true;
> +
> + KstScalarListViewItem *kItem =
> dynamic_cast<KstScalarListViewItem*>(item);
> + if (kItem) {
> + kItem->setRemove(false);
> + repaintItem(kItem);
> + addChildItems(kItem, *i);
> + }
> +
> + break;
> + }
> + item = item->nextSibling();
> + }
> +
> + if (!found) {
> + KstScalarListViewItem *item = new KstScalarListViewItem
> (this, *i);
> + addChildItems(item, *i);
> + }
> }
> +
> + {
> + QListViewItemIterator it(this);
> +
> + while (it.current()) {
> + KstScalarListViewItem *kItem =
> dynamic_cast<KstScalarListViewItem*>(it.current());
> + if (kItem) {
> + if (kItem->remove()) {
> + delete it.current();
> + } else {
> + ++it;
> + }
> + } else {
> + ++it;
> + }
> + }
> + }
> }
>
> /*
> --- branches/work/kst/1.5/kst/src/libkstapp/kstscalarlistview.h
> #653145:653146
> @@ -23,6 +23,8 @@
> #include "kstobject.h"
> #include "kstobjectcollection.h"
>
> +class KstScalarListViewItem;
> +
> class KstScalarListView : public KListView
> {
> public:
> @@ -31,6 +33,8 @@
> void update();
>
> private:
> + void addChildItems(KstScalarListViewItem *parentItem,
> KstObjectTreeNode<KstScalar> *parentNode);
> +
> KstObjectCollection<KstScalar> *_coll;
> };
>
> @@ -44,12 +48,16 @@
> QString text(int column) const;
> void setText(int column, const QString& text);
>
> + bool remove() const;
> + void setRemove(bool remove);
> +
> KstObjectTreeNode<KstScalar> *node() const { return _node; }
>
> private:
> void commonConstructor();
>
> QGuardedPtr<KstObjectTreeNode<KstScalar> > _node;
> + bool _remove;
> };
>
> #endif
> _______________________________________________
> Kst mailing list
> Kst at kde.org
> https://mail.kde.org/mailman/listinfo/kst
--
George Staikos
KDE Developer http://www.kde.org/
Staikos Computing Services Inc. http://www.staikos.net/
More information about the Kst
mailing list