From kde-commits Mon Jul 31 22:10:11 2006 From: George Staikos Date: Mon, 31 Jul 2006 22:10:11 +0000 To: kde-commits Subject: extragear/graphics/kst/src/libkstapp Message-Id: <1154383811.819866.25182.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=115438382128458 SVN commit 568363 by staikos: add a findPlotByName() helper to search through efficiently and find a plot, and remove a dead function M +21 -9 kst2dplot.cpp M +1 -1 kst2dplot.h --- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.cpp #568362:568363 @@ -5263,6 +5263,27 @@ } +Kst2DPlotPtr Kst2DPlot::findPlotByName(const QString& name) { + Kst2DPlotPtr rc; + KstApp *app = KstApp::inst(); + KMdiIterator *it = app->createIterator(); + if (it) { + while (it->currentItem()) { + KstViewWindow *view = dynamic_cast(it->currentItem()); + if (view) { + rc = kst_cast(view->view()->findChild(name)); + if (rc) { + break; + } + } + it->next(); + } + app->deleteIterator(it); + } + return rc; +} + + // FIXME: this does not strip out dupes. Why? Because we can't have them // by definition at present. this might change one day. Unfortunately // removal of dupes makes O(n) code become O(n^2). @@ -5285,15 +5306,6 @@ } -Kst2DPlotList Kst2DPlot::plotListForWindow() { - KstViewObjectPtr v = KstViewObjectPtr(this); - while (v->parent()) { - v = v->parent(); - } - return v->findChildrenType(true); -} - - #ifndef WHEEL_DELTA #define WHEEL_DELTA 120 #endif --- trunk/extragear/graphics/kst/src/libkstapp/kst2dplot.h #568362:568363 @@ -95,7 +95,7 @@ virtual ~Kst2DPlot(); static Kst2DPlotList globalPlotList(); - Kst2DPlotList plotListForWindow(); + static Kst2DPlotPtr findPlotByName(const QString& name); static bool checkRange(double& min_in, double& max_in); static bool checkLRange(double& min_in, double& max_in, bool isLog, double logBase); static void genAxisTickLabel(QString& label, double z, bool isLog, double logBase);